rebuild the asset bundle if a file has been modified between flutter test
runs (#143569)
Fixes https://github.com/flutter/flutter/issues/143513 Should be cherry-picked to beta.
This commit is contained in:
parent
1b8742b9dc
commit
9a6bda87d9
@ -620,7 +620,10 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final DevFSFileContent entry in entries.values.whereType<DevFSFileContent>()) {
|
final Iterable<DevFSFileContent> files = entries.values
|
||||||
|
.map((AssetBundleEntry asset) => asset.content)
|
||||||
|
.whereType<DevFSFileContent>();
|
||||||
|
for (final DevFSFileContent entry in files) {
|
||||||
// Calling isModified to access file stats first in order for isModifiedAfter
|
// Calling isModified to access file stats first in order for isModifiedAfter
|
||||||
// to work.
|
// to work.
|
||||||
if (entry.isModified && entry.isModifiedAfter(lastModified)) {
|
if (entry.isModified && entry.isModifiedAfter(lastModified)) {
|
||||||
|
@ -955,6 +955,41 @@ dev_dependencies:
|
|||||||
DeviceManager: () => _FakeDeviceManager(<Device>[]),
|
DeviceManager: () => _FakeDeviceManager(<Device>[]),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testUsingContext('Rebuild the asset bundle if an asset file has changed since previous build', () async {
|
||||||
|
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
|
||||||
|
fs.file('asset.txt').writeAsStringSync('1');
|
||||||
|
fs.file('pubspec.yaml').writeAsStringSync('''
|
||||||
|
flutter:
|
||||||
|
assets:
|
||||||
|
- asset.txt
|
||||||
|
dev_dependencies:
|
||||||
|
flutter_test:
|
||||||
|
sdk: flutter
|
||||||
|
integration_test:
|
||||||
|
sdk: flutter''');
|
||||||
|
final TestCommand testCommand = TestCommand(testRunner: testRunner);
|
||||||
|
final CommandRunner<void> commandRunner = createTestCommandRunner(testCommand);
|
||||||
|
|
||||||
|
await commandRunner.run(const <String>[
|
||||||
|
'test',
|
||||||
|
'--no-pub',
|
||||||
|
]);
|
||||||
|
|
||||||
|
fs.file('asset.txt').writeAsStringSync('2');
|
||||||
|
|
||||||
|
await commandRunner.run(const <String>[
|
||||||
|
'test',
|
||||||
|
'--no-pub',
|
||||||
|
]);
|
||||||
|
|
||||||
|
final String fileContent = fs.file(globals.fs.path.join('build', 'unit_test_assets', 'asset.txt')).readAsStringSync();
|
||||||
|
expect(fileContent, '2');
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
FileSystem: () => fs,
|
||||||
|
ProcessManager: () => FakeProcessManager.empty(),
|
||||||
|
DeviceManager: () => _FakeDeviceManager(<Device>[]),
|
||||||
|
});
|
||||||
|
|
||||||
group('Fatal Logs', () {
|
group('Fatal Logs', () {
|
||||||
testUsingContext("doesn't fail when --fatal-warnings is set and no warning output", () async {
|
testUsingContext("doesn't fail when --fatal-warnings is set and no warning output", () async {
|
||||||
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
|
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user