[flutter_tools] always build test assets (#81341)

This commit is contained in:
Erick 2021-04-28 00:53:57 -03:00 committed by GitHub
parent 1575537ac4
commit aecd5e0302
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 1 deletions

View file

@ -315,7 +315,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
);
}
if (buildTestAssets && flutterProject.manifest.assets.isNotEmpty) {
if (buildTestAssets) {
await _buildTestAsset();
}

View file

@ -604,6 +604,47 @@ dev_dependencies:
FakeDevice('ephemeral', 'ephemeral', ephemeral: true, isSupported: true, type: PlatformType.android),
]),
});
testUsingContext('Builds the asset manifest by default', () async {
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
final TestCommand testCommand = TestCommand(testRunner: testRunner);
final CommandRunner<void> commandRunner = createTestCommandRunner(testCommand);
await commandRunner.run(const <String>[
'test',
'--no-pub',
]);
final bool fileExists = await fs.isFile('build/unit_test_assets/AssetManifest.json');
expect(fileExists, true);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
DeviceManager: () => _FakeDeviceManager(<Device>[]),
});
testUsingContext('Don\'t build the asset manifest if --no-test-assets if informed', () async {
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
final TestCommand testCommand = TestCommand(testRunner: testRunner);
final CommandRunner<void> commandRunner = createTestCommandRunner(testCommand);
await commandRunner.run(const <String>[
'test',
'--no-pub',
'--no-test-assets',
]);
final bool fileExists = await fs.isFile('build/unit_test_assets/AssetManifest.json');
expect(fileExists, false);
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
DeviceManager: () => _FakeDeviceManager(<Device>[]),
});
}
class FakeFlutterTestRunner implements FlutterTestRunner {