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