Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: pkg/dev_compiler/test/codegen_test.dart

Issue 2578463004: update DDC to use analyzer extractDefinedVariables (Closed)
Patch Set: merge Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/dev_compiler/lib/src/compiler/command.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Tests code generation. 5 /// Tests code generation.
6 /// 6 ///
7 /// Runs Dart Dev Compiler on all input in the `codegen` directory and checks 7 /// Runs Dart Dev Compiler on all input in the `codegen` directory and checks
8 /// that the output is what we expected. 8 /// that the output is what we expected.
9 library dev_compiler.test.codegen_test; 9 library dev_compiler.test.codegen_test;
10 10
11 // TODO(rnystrom): This doesn't actually run any tests any more. It just 11 // TODO(rnystrom): This doesn't actually run any tests any more. It just
12 // compiles stuff. This should be changed to not use unittest and just be a 12 // compiles stuff. This should be changed to not use unittest and just be a
13 // regular program that outputs files. 13 // regular program that outputs files.
14 14
15 import 'dart:io' show Directory, File, Platform; 15 import 'dart:io' show Directory, File, Platform;
16 import 'package:analyzer/analyzer.dart' 16 import 'package:analyzer/analyzer.dart'
17 show 17 show
18 ExportDirective, 18 ExportDirective,
19 ImportDirective, 19 ImportDirective,
20 StringLiteral, 20 StringLiteral,
21 UriBasedDirective, 21 UriBasedDirective,
22 parseDirectives; 22 parseDirectives;
23 import 'package:analyzer/src/command_line/arguments.dart'
24 show extractDefinedVariables;
23 import 'package:analyzer/src/dart/ast/ast.dart'; 25 import 'package:analyzer/src/dart/ast/ast.dart';
24 import 'package:analyzer/src/generated/source.dart' show Source; 26 import 'package:analyzer/src/generated/source.dart' show Source;
25 import 'package:args/args.dart' show ArgParser, ArgResults; 27 import 'package:args/args.dart' show ArgParser, ArgResults;
26 import 'package:dev_compiler/src/analyzer/context.dart' 28 import 'package:dev_compiler/src/analyzer/context.dart';
27 show AnalyzerOptions, parseDeclaredVariables;
28 import 'package:dev_compiler/src/compiler/compiler.dart' 29 import 'package:dev_compiler/src/compiler/compiler.dart'
29 show BuildUnit, CompilerOptions, JSModuleFile, ModuleCompiler; 30 show BuildUnit, CompilerOptions, JSModuleFile, ModuleCompiler;
30 import 'package:dev_compiler/src/compiler/module_builder.dart' 31 import 'package:dev_compiler/src/compiler/module_builder.dart'
31 show ModuleFormat, addModuleFormatOptions, parseModuleFormatOption; 32 show ModuleFormat, addModuleFormatOptions, parseModuleFormatOption;
32 import 'package:path/path.dart' as path; 33 import 'package:path/path.dart' as path;
33 import 'package:test/test.dart' show expect, isFalse, isTrue, test; 34 import 'package:test/test.dart' show expect, isFalse, isTrue, test;
34 35
35 import '../tool/build_sdk.dart' as build_sdk; 36 import '../tool/build_sdk.dart' as build_sdk;
36 import 'testing.dart' show repoDirectory, testDirectory; 37 import 'testing.dart' show repoDirectory, testDirectory;
37 import 'multitest.dart' show extractTestsFromMultitest, isMultiTest; 38 import 'multitest.dart' show extractTestsFromMultitest, isMultiTest;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 var match = testFileOptionsMatcher.firstMatch(contents); 133 var match = testFileOptionsMatcher.firstMatch(contents);
133 134
134 var args = defaultOptions.toList(); 135 var args = defaultOptions.toList();
135 if (match != null) { 136 if (match != null) {
136 var matchedArgs = match.group(2).split(' '); 137 var matchedArgs = match.group(2).split(' ');
137 args.addAll(matchedArgs.where((s) => !ignoreOptions.contains(s))); 138 args.addAll(matchedArgs.where((s) => !ignoreOptions.contains(s)));
138 } 139 }
139 140
140 var declaredVars = <String, String>{}; 141 var declaredVars = <String, String>{};
141 var argResults = 142 var argResults =
142 compileArgParser.parse(parseDeclaredVariables(args, declaredVars)); 143 compileArgParser.parse(extractDefinedVariables(args, declaredVars));
143 var options = new CompilerOptions.fromArguments(argResults); 144 var options = new CompilerOptions.fromArguments(argResults);
144 var moduleFormat = parseModuleFormatOption(argResults).first; 145 var moduleFormat = parseModuleFormatOption(argResults).first;
145 146
146 // Collect any other files we've imported. 147 // Collect any other files we've imported.
147 var files = new Set<String>(); 148 var files = new Set<String>();
148 _collectTransitiveImports(contents, files, from: testFile); 149 _collectTransitiveImports(contents, files, from: testFile);
149 var unit = new BuildUnit( 150 var unit = new BuildUnit(
150 name, path.dirname(testFile), files.toList(), _moduleForLibrary); 151 name, path.dirname(testFile), files.toList(), _moduleForLibrary);
151 152
152 var compiler = sharedCompiler; 153 var compiler = sharedCompiler;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 StringLiteral uriLiteral = directive.uri; 357 StringLiteral uriLiteral = directive.uri;
357 String uriContent = uriLiteral.stringValue; 358 String uriContent = uriLiteral.stringValue;
358 if (uriContent != null) { 359 if (uriContent != null) {
359 uriContent = uriContent.trim(); 360 uriContent = uriContent.trim();
360 directive.uriContent = uriContent; 361 directive.uriContent = uriContent;
361 } 362 }
362 return (directive as UriBasedDirectiveImpl).validate() == null 363 return (directive as UriBasedDirectiveImpl).validate() == null
363 ? uriContent 364 ? uriContent
364 : null; 365 : null;
365 } 366 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/lib/src/compiler/command.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698