From 673745901f5a9dc5f4d673f4263fdbeca9e122e8 Mon Sep 17 00:00:00 2001 From: Luke Church Date: Mon, 5 Dec 2016 14:40:45 +0000 Subject: [PATCH] Use touch to avoid race condition in file modification test (#7117) * Use touch to avoid race condition in file modification test * Remove unused import --- packages/flutter_tools/test/devfs_test.dart | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/flutter_tools/test/devfs_test.dart b/packages/flutter_tools/test/devfs_test.dart index 63f554a2c4..eb6907dca7 100644 --- a/packages/flutter_tools/test/devfs_test.dart +++ b/packages/flutter_tools/test/devfs_test.dart @@ -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([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.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', ['-A', '-05', file.path]); + await devFS.update(); await file.writeAsBytes([1, 2, 3, 4, 5, 6]); await devFS.update(); expect(devFSOperations.contains('writeFile test bar/foo.txt'), isTrue);