046928d502
If main script is specified as a 'package:' URI, kernel compiler should not try to convert it to 'package:' URI using --packages file. Bug: FL-186 Change-Id: I65e8825470ca08b5dd1ae5bd30cf4f5699d6d03c Reviewed-on: https://dart-review.googlesource.com/c/93365 Reviewed-by: Zach Anderson <zra@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
127 lines
3.1 KiB
Dart
127 lines
3.1 KiB
Dart
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'dart:io';
|
|
|
|
import 'package:front_end/src/api_unstable/vm.dart'
|
|
show computePlatformBinariesLocation;
|
|
import 'package:test/test.dart';
|
|
import 'package:vm/kernel_front_end.dart';
|
|
|
|
final String sdkDir = Platform.script.resolve('../../..').toFilePath();
|
|
|
|
String platformPath() => computePlatformBinariesLocation()
|
|
.resolve('vm_platform_strong.dill')
|
|
.toFilePath();
|
|
|
|
const String mainScript = 'pkg/vm/bin/gen_kernel.dart';
|
|
const String mainScriptPackageUri = 'package:vm/kernel_front_end.dart';
|
|
const String packagesFile = '.packages';
|
|
|
|
void testCompile(List<String> args) async {
|
|
final compilerExitCode =
|
|
await runCompiler(createCompilerArgParser().parse(args), '');
|
|
expect(compilerExitCode, successExitCode);
|
|
}
|
|
|
|
main() {
|
|
Directory tempDir;
|
|
setUp(() {
|
|
var systemTempDir = Directory.systemTemp;
|
|
tempDir = systemTempDir.createTempSync('kernel_front_end_test');
|
|
});
|
|
|
|
tearDown(() {
|
|
tempDir.delete(recursive: true);
|
|
});
|
|
|
|
String outputDill() => new File('${tempDir.path}/foo.dill').path;
|
|
|
|
test('compile-simple', () async {
|
|
await testCompile([
|
|
'--platform',
|
|
platformPath(),
|
|
'--packages',
|
|
'$sdkDir/$packagesFile',
|
|
'--output',
|
|
outputDill(),
|
|
'$sdkDir/$mainScript',
|
|
]);
|
|
});
|
|
|
|
test('compile-multi-root', () async {
|
|
await testCompile([
|
|
'--platform',
|
|
platformPath(),
|
|
'--filesystem-scheme',
|
|
'test-filesystem-scheme',
|
|
'--filesystem-root',
|
|
sdkDir,
|
|
'--packages',
|
|
'test-filesystem-scheme:///$packagesFile',
|
|
'--output',
|
|
outputDill(),
|
|
'test-filesystem-scheme:///$mainScript',
|
|
]);
|
|
});
|
|
|
|
test('compile-multi-root-with-package-uri-main', () async {
|
|
await testCompile([
|
|
'--platform',
|
|
platformPath(),
|
|
'--filesystem-scheme',
|
|
'test-filesystem-scheme',
|
|
'--filesystem-root',
|
|
sdkDir,
|
|
'--packages',
|
|
'test-filesystem-scheme:///$packagesFile',
|
|
'--output',
|
|
outputDill(),
|
|
'$mainScriptPackageUri',
|
|
]);
|
|
});
|
|
|
|
test('compile-package-split', () async {
|
|
await testCompile([
|
|
'--platform',
|
|
platformPath(),
|
|
'--packages',
|
|
'$sdkDir/$packagesFile',
|
|
'--output',
|
|
outputDill(),
|
|
'--split-output-by-packages',
|
|
'$sdkDir/$mainScript',
|
|
]);
|
|
});
|
|
|
|
test('compile-bytecode', () async {
|
|
await testCompile([
|
|
'--platform',
|
|
platformPath(),
|
|
'--packages',
|
|
'$sdkDir/$packagesFile',
|
|
'--output',
|
|
outputDill(),
|
|
'--gen-bytecode',
|
|
'--drop-ast',
|
|
'$sdkDir/$mainScript',
|
|
]);
|
|
});
|
|
|
|
test('compile-bytecode-package-split', () async {
|
|
await testCompile([
|
|
'--platform',
|
|
platformPath(),
|
|
'--packages',
|
|
'$sdkDir/$packagesFile',
|
|
'--output',
|
|
outputDill(),
|
|
'--gen-bytecode',
|
|
'--drop-ast',
|
|
'--split-output-by-packages',
|
|
'$sdkDir/$mainScript',
|
|
]);
|
|
});
|
|
}
|