Use touch to avoid race condition in file modification test (#7117)

* Use touch to avoid race condition in file modification test

* Remove unused import
This commit is contained in:
Luke Church
2016-12-05 14:40:45 +00:00
committed by GitHub
parent 9990f39745
commit 673745901f

View File

@@ -3,7 +3,6 @@
// found in the LICENSE file.
import 'dart:io';
import 'dart:async';
import 'package:flutter_tools/src/asset.dart';
import 'package:flutter_tools/src/build_info.dart';
@@ -46,12 +45,12 @@ void main() {
file.writeAsBytesSync(<int>[1, 2, 3, 4, 5, 6, 7]);
await devFS.update();
expect(devFSOperations.contains('writeFile test foo/bar.txt'), isTrue);
// Need to delay between when we first write to a file and when
// we modify it.
await new Future<Null>.delayed(new Duration(seconds: 1));
});
testUsingContext('modify existing file on local file system', () async {
File file = new File(path.join(basePath, filePath));
// Set the last modified time to 5 seconds ago.
Process.runSync('touch', <String>['-A', '-05', file.path]);
await devFS.update();
await file.writeAsBytes(<int>[1, 2, 3, 4, 5, 6]);
await devFS.update();
expect(devFSOperations.contains('writeFile test bar/foo.txt'), isTrue);