Unverified Commit 5fd1d36e authored by Danny Tuppeny's avatar Danny Tuppeny Committed by GitHub

Limit 10 second future modification-date in integration test to only where...

Limit 10 second future modification-date in integration test to only where required for reloads (#91300)

This prevents all of the `flutter run` calls immediately re-running `flutter pub get` when it has already been run by test setup code.
parent 2e97e3cf
......@@ -103,6 +103,10 @@ class RepeatingBackgroundProject extends Project {
void updateTestIsolatePhrase(String message) {
final String newMainContents = main.replaceFirst('Isolate thread', message);
writeFile(fileSystem.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
writeFile(
fileSystem.path.join(dir.path, 'lib', 'main.dart'),
newMainContents,
writeFutureModifiedDate: true,
);
}
}
......@@ -53,6 +53,10 @@ class HotReloadConstProject extends Project {
'final int field = 2;',
'// final int field = 2;',
);
writeFile(fileSystem.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
writeFile(
fileSystem.path.join(dir.path, 'lib', 'main.dart'),
newMainContents,
writeFutureModifiedDate: true,
);
}
}
......@@ -95,6 +95,10 @@ class HotReloadProject extends Project {
'// printHotReloadWorked();',
'printHotReloadWorked();',
);
writeFile(fileSystem.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
writeFile(
fileSystem.path.join(dir.path, 'lib', 'main.dart'),
newMainContents,
writeFutureModifiedDate: true,
);
}
}
......@@ -55,6 +55,10 @@ class MyApp extends StatelessWidget {
'LOADED DATA',
'SECOND DATA',
);
writeFile(fileSystem.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
writeFile(
fileSystem.path.join(dir.path, 'lib', 'main.dart'),
newMainContents,
writeFutureModifiedDate: true,
);
}
}
......@@ -75,7 +75,11 @@ class SingleWidgetReloadProject extends Project {
'// printHotReloadWorked();',
'printHotReloadWorked();',
);
writeFile(fileSystem.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
writeFile(
fileSystem.path.join(dir.path, 'lib', 'main.dart'),
newMainContents,
writeFutureModifiedDate: true,
);
}
void modifyFunction() {
......@@ -83,6 +87,10 @@ class SingleWidgetReloadProject extends Project {
'(((((RELOAD WORKED)))))',
'(((((RELOAD WORKED 2)))))',
);
writeFile(fileSystem.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
writeFile(
fileSystem.path.join(dir.path, 'lib', 'main.dart'),
newMainContents,
writeFutureModifiedDate: true,
);
}
}
......@@ -74,6 +74,10 @@ class HotReloadProject extends Project {
void toggleState() {
stateful = !stateful;
writeFile(fileSystem.path.join(dir.path, 'lib', 'main.dart'), getCode(stateful));
writeFile(
fileSystem.path.join(dir.path, 'lib', 'main.dart'),
getCode(stateful),
writeFutureModifiedDate: true,
);
}
}
......@@ -33,18 +33,22 @@ Directory createResolvedTempDirectorySync(String prefix) {
return fileSystem.directory(tempDirectory.resolveSymbolicLinksSync());
}
void writeFile(String path, String content) {
fileSystem.file(path)
void writeFile(String path, String content, {bool writeFutureModifiedDate = false}) {
final File file = fileSystem.file(path)
..createSync(recursive: true)
..writeAsStringSync(content)
..setLastModifiedSync(DateTime.now().add(const Duration(seconds: 10)));
..writeAsStringSync(content);
// Some integration tests on Windows to not see this file as being modified
// recently enough for the hot reload to pick this change up unless the
// modified time is written in the future.
if (writeFutureModifiedDate) {
file.setLastModifiedSync(DateTime.now().add(const Duration(seconds: 5)));
}
}
void writeBytesFile(String path, List<int> content) {
fileSystem.file(path)
..createSync(recursive: true)
..writeAsBytesSync(content)
..setLastModifiedSync(DateTime.now().add(const Duration(seconds: 10)));
..writeAsBytesSync(content);
}
void writePackages(String folder) {
......
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