Include .track in file names for cached dill files for builds with --track-widget-creation (#23299)
Ensure that cached dill files for builds with --track-widget-creation
always have .track. in the file name to avoid mixing transformed and
untransformed kernel files.
diff --git a/packages/flutter_tools/test/devfs_test.dart b/packages/flutter_tools/test/devfs_test.dart
index ed4ad97..8aebeb0 100644
--- a/packages/flutter_tools/test/devfs_test.dart
+++ b/packages/flutter_tools/test/devfs_test.dart
@@ -119,13 +119,25 @@
devFSOperations.expectMessages(<String>['create test']);
expect(devFS.assetPathsToEvict, isEmpty);
- final int bytes = await devFS.update(
+ int bytes = await devFS.update(
mainPath: 'lib/foo.txt',
generator: residentCompiler,
pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: false,
);
devFSOperations.expectMessages(<String>[
- 'writeFile test lib/foo.txt.dill',
+ 'writeFile test lib/foo.txt.dill build/app.dill',
+ ]);
+ expect(devFS.assetPathsToEvict, isEmpty);
+
+ bytes = await devFS.update(
+ mainPath: 'lib/foo.txt',
+ generator: residentCompiler,
+ pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: true,
+ );
+ devFSOperations.expectMessages(<String>[
+ 'writeFile test lib/foo.txt.dill build/app.dill.track.dill',
]);
expect(devFS.assetPathsToEvict, isEmpty);
@@ -142,9 +154,10 @@
mainPath: 'lib/foo.txt',
generator: residentCompiler,
pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: false,
);
devFSOperations.expectMessages(<String>[
- 'writeFile test lib/foo.txt.dill',
+ 'writeFile test lib/foo.txt.dill build/app.dill',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 22);
@@ -157,9 +170,10 @@
mainPath: 'lib/foo.txt',
generator: residentCompiler,
pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: false,
);
devFSOperations.expectMessages(<String>[
- 'writeFile test lib/foo.txt.dill',
+ 'writeFile test lib/foo.txt.dill build/app.dill',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 22);
@@ -171,9 +185,10 @@
mainPath: 'lib/foo.txt',
generator: residentCompiler,
pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: false,
);
devFSOperations.expectMessages(<String>[
- 'writeFile test lib/foo.txt.dill',
+ 'writeFile test lib/foo.txt.dill build/app.dill',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 22);
@@ -183,12 +198,41 @@
mainPath: 'lib/foo.txt',
generator: residentCompiler,
pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: false,
);
devFSOperations.expectMessages(<String>[
- 'writeFile test lib/foo.txt.dill',
+ 'writeFile test lib/foo.txt.dill build/app.dill',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 22);
+
+ // Set the last modified time to 5 seconds in the past.
+ updateFileModificationTime(file.path, DateTime.now(), -5);
+ bytes = await devFS.update(
+ mainPath: 'lib/foo.txt',
+ generator: residentCompiler,
+ pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: true,
+ );
+ devFSOperations.expectMessages(<String>[
+ 'writeFile test lib/foo.txt.dill build/app.dill.track.dill',
+ ]);
+ expect(devFS.assetPathsToEvict, isEmpty);
+ expect(bytes, 22);
+
+ await file.writeAsBytes(<int>[1, 2, 3, 4, 5, 6]);
+ bytes = await devFS.update(
+ mainPath: 'lib/foo.txt',
+ generator: residentCompiler,
+ pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: true,
+ );
+ devFSOperations.expectMessages(<String>[
+ 'writeFile test lib/foo.txt.dill build/app.dill.track.dill',
+ ]);
+ expect(devFS.assetPathsToEvict, isEmpty);
+ expect(bytes, 22);
+
}, overrides: <Type, Generator>{
FileSystem: () => fs,
});
@@ -200,10 +244,11 @@
mainPath: 'lib/foo.txt',
generator: residentCompiler,
pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: false,
);
devFSOperations.expectMessages(<String>[
'deleteFile test lib/foo.txt',
- 'writeFile test lib/foo.txt.dill',
+ 'writeFile test lib/foo.txt.dill build/app.dill',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 22);
@@ -213,16 +258,30 @@
testUsingContext('add new package', () async {
await _createPackage(fs, 'newpkg', 'anotherfile.txt');
- final int bytes = await devFS.update(
+ int bytes = await devFS.update(
mainPath: 'lib/foo.txt',
generator: residentCompiler,
pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: false,
);
devFSOperations.expectMessages(<String>[
- 'writeFile test lib/foo.txt.dill',
+ 'writeFile test lib/foo.txt.dill build/app.dill',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 22);
+
+ bytes = await devFS.update(
+ mainPath: 'lib/foo.txt',
+ generator: residentCompiler,
+ pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: true,
+ );
+ devFSOperations.expectMessages(<String>[
+ 'writeFile test lib/foo.txt.dill build/app.dill.track.dill',
+ ]);
+ expect(devFS.assetPathsToEvict, isEmpty);
+ expect(bytes, 22);
+
}, overrides: <Type, Generator>{
FileSystem: () => fs,
});
@@ -248,9 +307,10 @@
fileFilter: fileFilter,
generator: residentCompiler,
pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: false,
);
devFSOperations.expectMessages(<String>[
- 'writeFile test lib/foo.txt.dill',
+ 'writeFile test lib/foo.txt.dill build/app.dill',
]);
expect(devFS.assetPathsToEvict, isEmpty);
expect(bytes, 22);
@@ -266,10 +326,11 @@
bundleDirty: true,
generator: residentCompiler,
pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: false,
);
devFSOperations.expectMessages(<String>[
'writeFile test ${_inAssetBuildDirectory(fs, 'a.txt')}',
- 'writeFile test lib/foo.txt.dill',
+ 'writeFile test lib/foo.txt.dill build/app.dill',
]);
expect(devFS.assetPathsToEvict, unorderedMatches(<String>['a.txt']));
devFS.assetPathsToEvict.clear();
@@ -286,12 +347,13 @@
bundleDirty: true,
generator: residentCompiler,
pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: false,
);
// Expect entire asset bundle written because bundleDirty is true
devFSOperations.expectMessages(<String>[
'writeFile test ${_inAssetBuildDirectory(fs, 'a.txt')}',
'writeFile test ${_inAssetBuildDirectory(fs, 'b.txt')}',
- 'writeFile test lib/foo.txt.dill',
+ 'writeFile test lib/foo.txt.dill build/app.dill',
]);
expect(devFS.assetPathsToEvict, unorderedMatches(<String>[
'a.txt', 'b.txt']));
@@ -308,10 +370,11 @@
bundle: assetBundle,
generator: residentCompiler,
pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: false,
);
devFSOperations.expectMessages(<String>[
'writeFile test ${_inAssetBuildDirectory(fs, 'c.txt')}',
- 'writeFile test lib/foo.txt.dill',
+ 'writeFile test lib/foo.txt.dill build/app.dill',
]);
expect(devFS.assetPathsToEvict, unorderedMatches(<String>[
'c.txt']));
@@ -328,10 +391,11 @@
bundle: assetBundle,
generator: residentCompiler,
pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: false,
);
devFSOperations.expectMessages(<String>[
'deleteFile test ${_inAssetBuildDirectory(fs, 'c.txt')}',
- 'writeFile test lib/foo.txt.dill',
+ 'writeFile test lib/foo.txt.dill build/app.dill',
]);
expect(devFS.assetPathsToEvict, unorderedMatches(<String>['c.txt']));
devFS.assetPathsToEvict.clear();
@@ -348,11 +412,12 @@
bundleDirty: true,
generator: residentCompiler,
pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: false,
);
devFSOperations.expectMessages(<String>[
'deleteFile test ${_inAssetBuildDirectory(fs, 'a.txt')}',
'deleteFile test ${_inAssetBuildDirectory(fs, 'b.txt')}',
- 'writeFile test lib/foo.txt.dill',
+ 'writeFile test lib/foo.txt.dill build/app.dill',
]);
expect(devFS.assetPathsToEvict, unorderedMatches(<String>[
'a.txt', 'b.txt'
@@ -405,6 +470,7 @@
mainPath: 'lib/foo.txt',
generator: residentCompiler,
pathToReload: 'lib/foo.txt.dill',
+ trackWidgetCreation: false,
);
vmService.expectMessages(<String>[
'writeFile test lib/foo.txt.dill',