Unverified Commit 1e062800 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[devicelab] dont use set modified for hot reload bench (#70965)

parent c07661cb
...@@ -19,6 +19,11 @@ const String kSourceLine = 'fontSize: (orientation == Orientation.portrait) ? 32 ...@@ -19,6 +19,11 @@ const String kSourceLine = 'fontSize: (orientation == Orientation.portrait) ? 32
const String kReplacementLine = 'fontSize: (orientation == Orientation.portrait) ? 34.0 : 24.0'; const String kReplacementLine = 'fontSize: (orientation == Orientation.portrait) ? 34.0 : 24.0';
TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> environment}) { TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> environment}) {
// This file is modified during the test and needs to be restored at the end.
final File flutterFrameworkSource = file(path.join(
flutterDirectory.path, 'packages/flutter/lib/src/widgets/framework.dart',
));
final String oldContents = flutterFrameworkSource.readAsStringSync();
return () async { return () async {
if (deviceIdOverride == null) { if (deviceIdOverride == null) {
final Device device = await devices.workingDevice; final Device device = await devices.workingDevice;
...@@ -42,6 +47,7 @@ TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> env ...@@ -42,6 +47,7 @@ TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> env
mkdirs(_editedFlutterGalleryDir); mkdirs(_editedFlutterGalleryDir);
recursiveCopy(flutterGalleryDir, _editedFlutterGalleryDir); recursiveCopy(flutterGalleryDir, _editedFlutterGalleryDir);
try {
await inDirectory<void>(_editedFlutterGalleryDir, () async { await inDirectory<void>(_editedFlutterGalleryDir, () async {
smallReloadData = await captureReloadData(options, environment, benchmarkFile, (String line, Process process) { smallReloadData = await captureReloadData(options, environment, benchmarkFile, (String line, Process process) {
if (!line.contains('Reloaded ')) { if (!line.contains('Reloaded ')) {
...@@ -88,10 +94,9 @@ TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> env ...@@ -88,10 +94,9 @@ TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> env
} }
if (hotReloadCount == 2) { if (hotReloadCount == 2) {
// Trigger a framework invalidation (370 libraries) without modifying the source // Trigger a framework invalidation (370 libraries) without modifying the source
final File flutterFrameworkSource = file(path.join( flutterFrameworkSource.writeAsStringSync(
flutterDirectory.path, 'packages/flutter/lib/src/widgets/framework.dart', flutterFrameworkSource.readAsStringSync() + '\n'
)); );
flutterFrameworkSource.setLastModifiedSync(DateTime.now());
process.stdin.writeln('r'); process.stdin.writeln('r');
hotReloadCount += 1; hotReloadCount += 1;
} else { } else {
...@@ -137,6 +142,9 @@ TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> env ...@@ -137,6 +142,9 @@ TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> env
json.decode(benchmarkFile.readAsStringSync()) as Map<String, dynamic>; json.decode(benchmarkFile.readAsStringSync()) as Map<String, dynamic>;
} }
}); });
} finally {
flutterFrameworkSource.writeAsStringSync(oldContents);
}
}); });
return TaskResult.success( return TaskResult.success(
......
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