| Index: pkg/dev_compiler/test/codegen_test.dart
|
| diff --git a/pkg/dev_compiler/test/codegen_test.dart b/pkg/dev_compiler/test/codegen_test.dart
|
| index 5c215e027300e93fa90b29f3c54a1c4a74d91790..80a1a8aacbc1e3370770815807e57e081fe94ea8 100644
|
| --- a/pkg/dev_compiler/test/codegen_test.dart
|
| +++ b/pkg/dev_compiler/test/codegen_test.dart
|
| @@ -22,7 +22,8 @@ import 'package:analyzer/analyzer.dart'
|
| parseDirectives;
|
| import 'package:analyzer/src/generated/source.dart' show Source;
|
| import 'package:args/args.dart' show ArgParser, ArgResults;
|
| -import 'package:dev_compiler/src/analyzer/context.dart' show AnalyzerOptions;
|
| +import 'package:dev_compiler/src/analyzer/context.dart'
|
| + show AnalyzerOptions, parseDeclaredVariables;
|
| import 'package:dev_compiler/src/compiler/compiler.dart'
|
| show BuildUnit, CompilerOptions, JSModuleFile, ModuleCompiler;
|
| import 'package:dev_compiler/src/compiler/module_builder.dart'
|
| @@ -76,9 +77,8 @@ main(List<String> arguments) {
|
| .where((p) => p.endsWith('.sum'))
|
| .toList();
|
|
|
| - var analyzerOptions = new AnalyzerOptions(
|
| - dartSdkSummaryPath: sdkSummaryFile, summaryPaths: summaryPaths);
|
| - var compiler = new ModuleCompiler(analyzerOptions);
|
| + var sharedCompiler = new ModuleCompiler(new AnalyzerOptions(
|
| + dartSdkSummaryPath: sdkSummaryFile, summaryPaths: summaryPaths));
|
|
|
| var testDirs = [
|
| 'language',
|
| @@ -100,9 +100,20 @@ main(List<String> arguments) {
|
|
|
| // Our default compiler options. Individual tests can override these.
|
| var defaultOptions = ['--no-source-map', '--no-summarize'];
|
| - var compilerArgParser = new ArgParser();
|
| - CompilerOptions.addArguments(compilerArgParser);
|
| - addModuleFormatOptions(compilerArgParser);
|
| + var compileArgParser = new ArgParser();
|
| + CompilerOptions.addArguments(compileArgParser);
|
| + addModuleFormatOptions(compileArgParser);
|
| +
|
| + var testFileOptionsMatcher =
|
| + new RegExp(r'// (compile options: |SharedOptions=)(.*)', multiLine: true);
|
| +
|
| + // Ignore dart2js options that we don't support in DDC.
|
| + var ignoreOptions = [
|
| + '--enable-enum',
|
| + '--experimental-trust-js-interop-type-annotations',
|
| + '--trust-type-annotations',
|
| + '--supermixin'
|
| + ];
|
|
|
| // Compile each test file to JS and put the result in gen/codegen_output.
|
| for (var testFile in testFiles) {
|
| @@ -116,15 +127,17 @@ main(List<String> arguments) {
|
| test('dartdevc $name', () {
|
| // Check if we need to use special compile options.
|
| var contents = new File(testFile).readAsStringSync();
|
| - var match =
|
| - new RegExp(r'// compile options: (.*)').matchAsPrefix(contents);
|
| + var match = testFileOptionsMatcher.firstMatch(contents);
|
|
|
| var args = defaultOptions.toList();
|
| if (match != null) {
|
| - args.addAll(match.group(1).split(' '));
|
| + var matchedArgs = match.group(2).split(' ');
|
| + args.addAll(matchedArgs.where((s) => !ignoreOptions.contains(s)));
|
| }
|
|
|
| - var argResults = compilerArgParser.parse(args);
|
| + var declaredVars = <String, String>{};
|
| + var argResults =
|
| + compileArgParser.parse(parseDeclaredVariables(args, declaredVars));
|
| var options = new CompilerOptions.fromArguments(argResults);
|
| var moduleFormat = parseModuleFormatOption(argResults).first;
|
|
|
| @@ -133,6 +146,14 @@ main(List<String> arguments) {
|
| _collectTransitiveImports(contents, files, from: testFile);
|
| var unit = new BuildUnit(
|
| name, path.dirname(testFile), files.toList(), _moduleForLibrary);
|
| +
|
| + var compiler = sharedCompiler;
|
| + if (declaredVars.isNotEmpty) {
|
| + compiler = new ModuleCompiler(new AnalyzerOptions(
|
| + dartSdkSummaryPath: sdkSummaryFile,
|
| + summaryPaths: summaryPaths,
|
| + declaredVariables: declaredVars));
|
| + }
|
| var module = compiler.compile(unit, options);
|
|
|
| bool notStrong = notYetStrongTests.contains(name);
|
| @@ -155,7 +176,7 @@ main(List<String> arguments) {
|
|
|
| if (filePattern.hasMatch('sunflower')) {
|
| test('sunflower', () {
|
| - _buildSunflower(compiler, codegenOutputDir, codegenExpectDir);
|
| + _buildSunflower(sharedCompiler, codegenOutputDir, codegenExpectDir);
|
| });
|
| }
|
|
|
|
|