Unverified Commit 90a592bf authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] fix test asset loading (#103667)

parent d3b80f88
...@@ -13,7 +13,6 @@ void main() { ...@@ -13,7 +13,6 @@ void main() {
width: 54, width: 54,
height: 54, height: 54,
fit: BoxFit.none, fit: BoxFit.none,
package: 'flutter_automated_tests',
), ),
); );
}); });
......
...@@ -70,6 +70,6 @@ dependencies: ...@@ -70,6 +70,6 @@ dependencies:
flutter: flutter:
uses-material-design: true uses-material-design: true
assets: assets:
- icon/ - icon/test.png
# PUBSPEC CHECKSUM: 53c0 # PUBSPEC CHECKSUM: 53c0
...@@ -320,8 +320,11 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { ...@@ -320,8 +320,11 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
); );
} }
String testAssetDirectory;
if (buildTestAssets) { if (buildTestAssets) {
await _buildTestAsset(); await _buildTestAsset();
testAssetDirectory = globals.fs.path.
join(flutterProject?.directory?.path ?? '', 'build', 'unit_test_assets');
} }
final bool startPaused = boolArgDeprecated('start-paused'); final bool startPaused = boolArgDeprecated('start-paused');
...@@ -444,7 +447,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { ...@@ -444,7 +447,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
machine: machine, machine: machine,
updateGoldens: boolArgDeprecated('update-goldens'), updateGoldens: boolArgDeprecated('update-goldens'),
concurrency: jobs, concurrency: jobs,
buildTestAssets: buildTestAssets, testAssetDirectory: testAssetDirectory,
flutterProject: flutterProject, flutterProject: flutterProject,
web: stringArgDeprecated('platform') == 'chrome', web: stringArgDeprecated('platform') == 'chrome',
randomSeed: stringArgDeprecated('test-randomize-ordering-seed'), randomSeed: stringArgDeprecated('test-randomize-ordering-seed'),
......
...@@ -55,7 +55,7 @@ FlutterPlatform installHook({ ...@@ -55,7 +55,7 @@ FlutterPlatform installHook({
String precompiledDillPath, String precompiledDillPath,
Map<String, String> precompiledDillFiles, Map<String, String> precompiledDillFiles,
bool updateGoldens = false, bool updateGoldens = false,
bool buildTestAssets = false, String testAssetDirectory,
InternetAddressType serverType = InternetAddressType.IPv4, InternetAddressType serverType = InternetAddressType.IPv4,
Uri projectRootDirectory, Uri projectRootDirectory,
FlutterProject flutterProject, FlutterProject flutterProject,
...@@ -86,7 +86,7 @@ FlutterPlatform installHook({ ...@@ -86,7 +86,7 @@ FlutterPlatform installHook({
precompiledDillPath: precompiledDillPath, precompiledDillPath: precompiledDillPath,
precompiledDillFiles: precompiledDillFiles, precompiledDillFiles: precompiledDillFiles,
updateGoldens: updateGoldens, updateGoldens: updateGoldens,
buildTestAssets: buildTestAssets, testAssetDirectory: testAssetDirectory,
projectRootDirectory: projectRootDirectory, projectRootDirectory: projectRootDirectory,
flutterProject: flutterProject, flutterProject: flutterProject,
icudtlPath: icudtlPath, icudtlPath: icudtlPath,
...@@ -280,7 +280,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -280,7 +280,7 @@ class FlutterPlatform extends PlatformPlugin {
this.precompiledDillPath, this.precompiledDillPath,
this.precompiledDillFiles, this.precompiledDillFiles,
this.updateGoldens, this.updateGoldens,
this.buildTestAssets, this.testAssetDirectory,
this.projectRootDirectory, this.projectRootDirectory,
this.flutterProject, this.flutterProject,
this.icudtlPath, this.icudtlPath,
...@@ -297,7 +297,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -297,7 +297,7 @@ class FlutterPlatform extends PlatformPlugin {
final String precompiledDillPath; final String precompiledDillPath;
final Map<String, String> precompiledDillFiles; final Map<String, String> precompiledDillFiles;
final bool updateGoldens; final bool updateGoldens;
final bool buildTestAssets; final String testAssetDirectory;
final Uri projectRootDirectory; final Uri projectRootDirectory;
final FlutterProject flutterProject; final FlutterProject flutterProject;
final String icudtlPath; final String icudtlPath;
...@@ -419,7 +419,7 @@ class FlutterPlatform extends PlatformPlugin { ...@@ -419,7 +419,7 @@ class FlutterPlatform extends PlatformPlugin {
machine: machine, machine: machine,
debuggingOptions: debuggingOptions, debuggingOptions: debuggingOptions,
host: host, host: host,
buildTestAssets: buildTestAssets, testAssetDirectory: testAssetDirectory,
flutterProject: flutterProject, flutterProject: flutterProject,
icudtlPath: icudtlPath, icudtlPath: icudtlPath,
compileExpression: _compileExpressionService, compileExpression: _compileExpressionService,
......
...@@ -39,7 +39,7 @@ class FlutterTesterTestDevice extends TestDevice { ...@@ -39,7 +39,7 @@ class FlutterTesterTestDevice extends TestDevice {
@required this.enableObservatory, @required this.enableObservatory,
@required this.machine, @required this.machine,
@required this.host, @required this.host,
@required this.buildTestAssets, @required this.testAssetDirectory,
@required this.flutterProject, @required this.flutterProject,
@required this.icudtlPath, @required this.icudtlPath,
@required this.compileExpression, @required this.compileExpression,
...@@ -66,7 +66,7 @@ class FlutterTesterTestDevice extends TestDevice { ...@@ -66,7 +66,7 @@ class FlutterTesterTestDevice extends TestDevice {
final bool enableObservatory; final bool enableObservatory;
final bool machine; final bool machine;
final InternetAddress host; final InternetAddress host;
final bool buildTestAssets; final String testAssetDirectory;
final FlutterProject flutterProject; final FlutterProject flutterProject;
final String icudtlPath; final String icudtlPath;
final CompileExpression compileExpression; final CompileExpression compileExpression;
...@@ -93,7 +93,6 @@ class FlutterTesterTestDevice extends TestDevice { ...@@ -93,7 +93,6 @@ class FlutterTesterTestDevice extends TestDevice {
// Let the server choose an unused port. // Let the server choose an unused port.
_server = await bind(host, /*port*/ 0); _server = await bind(host, /*port*/ 0);
logger.printTrace('test $id: test harness socket server is running at port:${_server.port}'); logger.printTrace('test $id: test harness socket server is running at port:${_server.port}');
final List<String> command = <String>[ final List<String> command = <String>[
// Until an arm64 flutter tester binary is available, force to run in Rosetta // Until an arm64 flutter tester binary is available, force to run in Rosetta
// to avoid "unexpectedly got a signal in sigtramp" crash. // to avoid "unexpectedly got a signal in sigtramp" crash.
...@@ -128,7 +127,10 @@ class FlutterTesterTestDevice extends TestDevice { ...@@ -128,7 +127,10 @@ class FlutterTesterTestDevice extends TestDevice {
'--enable-dart-profiling', '--enable-dart-profiling',
'--non-interactive', '--non-interactive',
'--use-test-fonts', '--use-test-fonts',
'--disable-asset-fonts',
'--packages=${debuggingOptions.buildInfo.packagesPath}', '--packages=${debuggingOptions.buildInfo.packagesPath}',
if (testAssetDirectory != null)
'--flutter-assets-dir=$testAssetDirectory',
if (debuggingOptions.nullAssertions) if (debuggingOptions.nullAssertions)
'--dart-flags=--null_assertions', '--dart-flags=--null_assertions',
...debuggingOptions.dartEntrypointArgs, ...debuggingOptions.dartEntrypointArgs,
...@@ -148,8 +150,8 @@ class FlutterTesterTestDevice extends TestDevice { ...@@ -148,8 +150,8 @@ class FlutterTesterTestDevice extends TestDevice {
'FONTCONFIG_FILE': fontConfigManager.fontConfigFile.path, 'FONTCONFIG_FILE': fontConfigManager.fontConfigFile.path,
'SERVER_PORT': _server.port.toString(), 'SERVER_PORT': _server.port.toString(),
'APP_NAME': flutterProject?.manifest?.appName ?? '', 'APP_NAME': flutterProject?.manifest?.appName ?? '',
if (buildTestAssets) if (testAssetDirectory != null)
'UNIT_TEST_ASSETS': fileSystem.path.join(flutterProject?.directory?.path ?? '', 'build', 'unit_test_assets'), 'UNIT_TEST_ASSETS': testAssetDirectory,
}; };
logger.printTrace('test $id: Starting flutter_tester process with command=$command, environment=$environment'); logger.printTrace('test $id: Starting flutter_tester process with command=$command, environment=$environment');
......
...@@ -42,7 +42,7 @@ abstract class FlutterTestRunner { ...@@ -42,7 +42,7 @@ abstract class FlutterTestRunner {
bool updateGoldens = false, bool updateGoldens = false,
TestWatcher watcher, TestWatcher watcher,
@required int concurrency, @required int concurrency,
bool buildTestAssets = false, String testAssetDirectory,
FlutterProject flutterProject, FlutterProject flutterProject,
String icudtlPath, String icudtlPath,
Directory coverageDirectory, Directory coverageDirectory,
...@@ -78,7 +78,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner { ...@@ -78,7 +78,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
bool updateGoldens = false, bool updateGoldens = false,
TestWatcher watcher, TestWatcher watcher,
@required int concurrency, @required int concurrency,
bool buildTestAssets = false, String testAssetDirectory,
FlutterProject flutterProject, FlutterProject flutterProject,
String icudtlPath, String icudtlPath,
Directory coverageDirectory, Directory coverageDirectory,
...@@ -202,7 +202,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner { ...@@ -202,7 +202,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
precompiledDillPath: precompiledDillPath, precompiledDillPath: precompiledDillPath,
precompiledDillFiles: precompiledDillFiles, precompiledDillFiles: precompiledDillFiles,
updateGoldens: updateGoldens, updateGoldens: updateGoldens,
buildTestAssets: buildTestAssets, testAssetDirectory: testAssetDirectory,
projectRootDirectory: globals.fs.currentDirectory.uri, projectRootDirectory: globals.fs.currentDirectory.uri,
flutterProject: flutterProject, flutterProject: flutterProject,
icudtlPath: icudtlPath, icudtlPath: icudtlPath,
......
...@@ -754,7 +754,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner { ...@@ -754,7 +754,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
bool updateGoldens = false, bool updateGoldens = false,
TestWatcher watcher, TestWatcher watcher,
int concurrency, int concurrency,
bool buildTestAssets = false, String testAssetDirectory,
FlutterProject flutterProject, FlutterProject flutterProject,
String icudtlPath, String icudtlPath,
Directory coverageDirectory, Directory coverageDirectory,
......
...@@ -95,7 +95,7 @@ void main() { ...@@ -95,7 +95,7 @@ void main() {
precompiledDillPath: 'def', precompiledDillPath: 'def',
precompiledDillFiles: expectedPrecompiledDillFiles, precompiledDillFiles: expectedPrecompiledDillFiles,
updateGoldens: true, updateGoldens: true,
buildTestAssets: true, testAssetDirectory: '/build/test',
serverType: InternetAddressType.IPv6, serverType: InternetAddressType.IPv6,
icudtlPath: 'ghi', icudtlPath: 'ghi',
platformPluginRegistration: (FlutterPlatform platform) { platformPluginRegistration: (FlutterPlatform platform) {
...@@ -114,7 +114,7 @@ void main() { ...@@ -114,7 +114,7 @@ void main() {
expect(flutterPlatform.precompiledDillPath, equals('def')); expect(flutterPlatform.precompiledDillPath, equals('def'));
expect(flutterPlatform.precompiledDillFiles, expectedPrecompiledDillFiles); expect(flutterPlatform.precompiledDillFiles, expectedPrecompiledDillFiles);
expect(flutterPlatform.updateGoldens, equals(true)); expect(flutterPlatform.updateGoldens, equals(true));
expect(flutterPlatform.buildTestAssets, equals(true)); expect(flutterPlatform.testAssetDirectory, '/build/test');
expect(flutterPlatform.icudtlPath, equals('ghi')); expect(flutterPlatform.icudtlPath, equals('ghi'));
}); });
}); });
......
...@@ -87,6 +87,7 @@ void main() { ...@@ -87,6 +87,7 @@ void main() {
'--enable-dart-profiling', '--enable-dart-profiling',
'--non-interactive', '--non-interactive',
'--use-test-fonts', '--use-test-fonts',
'--disable-asset-fonts',
'--packages=.dart_tool/package_config.json', '--packages=.dart_tool/package_config.json',
'example.dill', 'example.dill',
], environment: <String, String>{ ], environment: <String, String>{
...@@ -131,6 +132,7 @@ void main() { ...@@ -131,6 +132,7 @@ void main() {
'--enable-dart-profiling', '--enable-dart-profiling',
'--non-interactive', '--non-interactive',
'--use-test-fonts', '--use-test-fonts',
'--disable-asset-fonts',
'--packages=.dart_tool/package_config.json', '--packages=.dart_tool/package_config.json',
'example.dill', 'example.dill',
], environment: <String, String>{ ], environment: <String, String>{
...@@ -203,6 +205,7 @@ void main() { ...@@ -203,6 +205,7 @@ void main() {
'--enable-dart-profiling', '--enable-dart-profiling',
'--non-interactive', '--non-interactive',
'--use-test-fonts', '--use-test-fonts',
'--disable-asset-fonts',
'--packages=.dart_tool/package_config.json', '--packages=.dart_tool/package_config.json',
'--foo', '--foo',
'--bar', '--bar',
...@@ -244,6 +247,7 @@ void main() { ...@@ -244,6 +247,7 @@ void main() {
'--enable-dart-profiling', '--enable-dart-profiling',
'--non-interactive', '--non-interactive',
'--use-test-fonts', '--use-test-fonts',
'--disable-asset-fonts',
'--packages=.dart_tool/package_config.json', '--packages=.dart_tool/package_config.json',
'example.dill', 'example.dill',
], ],
...@@ -293,7 +297,7 @@ class TestFlutterTesterDevice extends FlutterTesterTestDevice { ...@@ -293,7 +297,7 @@ class TestFlutterTesterDevice extends FlutterTesterTestDevice {
enableObservatory: enableObservatory, enableObservatory: enableObservatory,
machine: false, machine: false,
host: InternetAddress.loopbackIPv6, host: InternetAddress.loopbackIPv6,
buildTestAssets: false, testAssetDirectory: null,
flutterProject: null, flutterProject: null,
icudtlPath: null, icudtlPath: null,
compileExpression: null, compileExpression: null,
......
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