Unverified Commit 52018568 authored by Jackson Gardner's avatar Jackson Gardner Committed by GitHub

Use file:/// style uris when passing platform to the compiler. (#116553)

* Use file:/// style uris when passing platform to the compiler.

* License header.

* Use BufferLogger.

* Don't unadvertently convert strings to regexes for matching purposes.

* Fix formatting.

* More formatting.
parent 174d3be8
......@@ -123,7 +123,7 @@ class WebTestCompiler {
initializeFromDill: cachedKernelPath,
targetModel: TargetModel.dartdevc,
extraFrontEndOptions: extraFrontEndOptions,
platformDill: platformDillPath,
platformDill: _fileSystem.file(platformDillPath).absolute.uri.toString(),
dartDefines: buildInfo.dartDefines,
librariesSpec: _artifacts.getHostArtifact(HostArtifact.flutterWebLibrariesJson).uri.toString(),
packagesPath: buildInfo.packagesPath,
......
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/config.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/test/web_test_compiler.dart';
import 'package:test/expect.dart';
import '../../src/context.dart';
void main() {
testUsingContext('web test compiler issues valid compile command', () 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>[
FakeCommand(command: <Pattern>[
'Artifact.engineDartBinary.TargetPlatform.web_javascript',
'--disable-dart-dev',
'Artifact.frontendServerSnapshotForEngineDartSdk.TargetPlatform.web_javascript',
'--sdk-root',
'HostArtifact.flutterWebSdk/',
'--incremental',
'--target=dartdevc',
'--experimental-emit-debug-metadata',
'--output-dill',
'build/out',
'--packages',
'.dart_tool/package_config.json',
'-Ddart.vm.profile=false',
'-Ddart.vm.product=false',
'--enable-asserts',
'--filesystem-root',
'project/test',
'--filesystem-root',
'build',
'--filesystem-scheme',
'org-dartlang-app',
'--initialize-from-dill',
RegExp(r'^build\/(?:[a-z0-9]{32})\.cache\.dill$'),
'--platform',
'file:///HostArtifact.webPlatformKernelFolder/ddc_outline_sound.dill',
'--verbosity=error',
'--sound-null-safety'
], 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,
);
await compiler.initialize(
projectDirectory: fileSystem.directory('project'),
testOutputDir: 'build',
testFiles: <String>['project/test/fake_test.dart'],
buildInfo: buildInfo,
);
expect(processManager.hasRemainingExpectations, isFalse);
});
}
......@@ -39,7 +39,7 @@ class FakeCommand {
/// The exact commands that must be matched for this [FakeCommand] to be
/// considered correct.
final List<String> command;
final List<Pattern> command;
/// The exact working directory that must be matched for this [FakeCommand] to
/// be considered correct.
......@@ -110,7 +110,15 @@ class FakeCommand {
Map<String, String>? environment,
Encoding? encoding,
) {
expect(command, equals(this.command));
expect(command.length, this.command.length);
for(int i = 0; i < command.length; i++) {
final Pattern expected = this.command[i];
if (expected is String) {
expect(command[i], expected);
} else {
expect(command[i], matches(this.command[i]));
}
}
if (this.workingDirectory != null) {
expect(this.workingDirectory, workingDirectory);
}
......
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