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 { ...@@ -103,6 +103,10 @@ class RepeatingBackgroundProject extends Project {
void updateTestIsolatePhrase(String message) { void updateTestIsolatePhrase(String message) {
final String newMainContents = main.replaceFirst('Isolate thread', 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 { ...@@ -53,6 +53,10 @@ class HotReloadConstProject extends Project {
'final int field = 2;', 'final int field = 2;',
'// 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 { ...@@ -95,6 +95,10 @@ class HotReloadProject extends Project {
'// printHotReloadWorked();', '// printHotReloadWorked();',
'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 { ...@@ -55,6 +55,10 @@ class MyApp extends StatelessWidget {
'LOADED DATA', 'LOADED DATA',
'SECOND 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 { ...@@ -75,7 +75,11 @@ class SingleWidgetReloadProject extends Project {
'// printHotReloadWorked();', '// printHotReloadWorked();',
'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() { void modifyFunction() {
...@@ -83,6 +87,10 @@ class SingleWidgetReloadProject extends Project { ...@@ -83,6 +87,10 @@ class SingleWidgetReloadProject extends Project {
'(((((RELOAD WORKED)))))', '(((((RELOAD WORKED)))))',
'(((((RELOAD WORKED 2)))))', '(((((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 { ...@@ -74,6 +74,10 @@ class HotReloadProject extends Project {
void toggleState() { void toggleState() {
stateful = !stateful; 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) { ...@@ -33,18 +33,22 @@ Directory createResolvedTempDirectorySync(String prefix) {
return fileSystem.directory(tempDirectory.resolveSymbolicLinksSync()); return fileSystem.directory(tempDirectory.resolveSymbolicLinksSync());
} }
void writeFile(String path, String content) { void writeFile(String path, String content, {bool writeFutureModifiedDate = false}) {
fileSystem.file(path) final File file = fileSystem.file(path)
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsStringSync(content) ..writeAsStringSync(content);
..setLastModifiedSync(DateTime.now().add(const Duration(seconds: 10))); // 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) { void writeBytesFile(String path, List<int> content) {
fileSystem.file(path) fileSystem.file(path)
..createSync(recursive: true) ..createSync(recursive: true)
..writeAsBytesSync(content) ..writeAsBytesSync(content);
..setLastModifiedSync(DateTime.now().add(const Duration(seconds: 10)));
} }
void writePackages(String folder) { 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