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