Commit 67374590 authored by Luke Church's avatar Luke Church Committed by GitHub

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

* Use touch to avoid race condition in file modification test

* Remove unused import
parent 9990f397
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io'; import 'dart:io';
import 'dart:async';
import 'package:flutter_tools/src/asset.dart'; import 'package:flutter_tools/src/asset.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
...@@ -46,12 +45,12 @@ void main() { ...@@ -46,12 +45,12 @@ void main() {
file.writeAsBytesSync(<int>[1, 2, 3, 4, 5, 6, 7]); file.writeAsBytesSync(<int>[1, 2, 3, 4, 5, 6, 7]);
await devFS.update(); await devFS.update();
expect(devFSOperations.contains('writeFile test foo/bar.txt'), isTrue); 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 { testUsingContext('modify existing file on local file system', () async {
File file = new File(path.join(basePath, filePath)); 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 file.writeAsBytes(<int>[1, 2, 3, 4, 5, 6]);
await devFS.update(); await devFS.update();
expect(devFSOperations.contains('writeFile test bar/foo.txt'), isTrue); expect(devFSOperations.contains('writeFile test bar/foo.txt'), isTrue);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment