Fix stray --packages argument from workspace refactor; add a test. (#170449)

Closes https://github.com/flutter/flutter/issues/170433.
This commit is contained in:
Matan Lurey 2025-06-12 14:28:07 -07:00 committed by GitHub
parent 8d2c80829f
commit 8953ea2cf9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 70 additions and 1 deletions

View File

@ -219,7 +219,7 @@ class WebTestCompiler {
),
'compile',
'wasm',
'--packages=../../.dart_tool/package_config.json',
'--packages=${buildInfo.packageConfigPath}',
'--extra-compiler-option=--platform=$platformFilePath',
'--extra-compiler-option=--multi-root-scheme=org-dartlang-app',
'--extra-compiler-option=--multi-root=${projectDirectory.childDirectory('test').path}',

View File

@ -94,4 +94,73 @@ void main() {
expect(processManager.hasRemainingExpectations, isFalse);
});
testUsingContext('web test compiler issues valid compile command (wasm)', () async {
final BufferLogger logger = BufferLogger.test();
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
fileSystem.file('project/test/fake_test.dart').createSync(recursive: true);
fileSystem.file('build/out').createSync(recursive: true);
fileSystem.file('build/build/out.sources').createSync(recursive: true);
fileSystem.file('build/build/out.json')
..createSync()
..writeAsStringSync('{}');
fileSystem.file('build/build/out.map').createSync();
fileSystem.file('build/build/out.metadata').createSync();
final FakePlatform platform = FakePlatform(environment: <String, String>{});
final Config config = Config(
Config.kFlutterSettings,
fileSystem: fileSystem,
logger: logger,
platform: platform,
);
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
const FakeCommand(
command: <Pattern>[
'Artifact.engineDartBinary.TargetPlatform.web_javascript',
'compile',
'wasm',
'--packages=.dart_tool/package_config.json',
'--extra-compiler-option=--platform=HostArtifact.webPlatformKernelFolder/dart2wasm_platform.dill',
'--extra-compiler-option=--multi-root-scheme=org-dartlang-app',
'--extra-compiler-option=--multi-root=project/test',
'--extra-compiler-option=--multi-root=build',
'--extra-compiler-option=--enable-asserts',
'--extra-compiler-option=--no-inlining',
'-DFLUTTER_WEB_USE_SKIA=true',
'-DFLUTTER_WEB_USE_SKWASM=false',
'-O0',
'-o',
'build/main.dart.wasm',
'build/main.dart',
],
stdout: 'result abc\nline0\nline1\nabc\nabc build/out 0',
),
]);
final WebTestCompiler compiler = WebTestCompiler(
logger: logger,
fileSystem: fileSystem,
platform: FakePlatform(environment: <String, String>{}),
artifacts: Artifacts.test(),
processManager: processManager,
config: config,
);
const BuildInfo buildInfo = BuildInfo(
BuildMode.debug,
'',
treeShakeIcons: false,
packageConfigPath: '.dart_tool/package_config.json',
);
await compiler.initialize(
projectDirectory: fileSystem.directory('project'),
testOutputDir: 'build',
testFiles: <String>['project/test/fake_test.dart'],
buildInfo: buildInfo,
webRenderer: WebRendererMode.canvaskit,
useWasm: true,
);
expect(processManager.hasRemainingExpectations, isFalse);
});
}