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

Side by Side Diff: tests/compiler/dart2js/exit_code_test.dart

Issue 1235563003: Add interfaces for a new compiler API. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 5 years, 5 months 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Test the exit code of dart2js in case of exceptions, errors, warnings, etc. 5 // Test the exit code of dart2js in case of exceptions, errors, warnings, etc.
6 6
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io' show Platform; 9 import 'dart:io' show Platform;
10 10
11 import 'package:async_helper/async_helper.dart'; 11 import 'package:async_helper/async_helper.dart';
12 import 'package:expect/expect.dart'; 12 import 'package:expect/expect.dart';
13 13
14 import 'package:compiler/compiler.dart' as api; 14 import 'package:compiler/compiler.dart' as old_api;
15 import 'package:compiler/compiler_new.dart' as api;
15 import 'package:compiler/src/compile_time_constants.dart'; 16 import 'package:compiler/src/compile_time_constants.dart';
16 import 'package:compiler/src/dart2js.dart' as entry; 17 import 'package:compiler/src/dart2js.dart' as entry;
17 import 'package:compiler/src/dart2jslib.dart'; 18 import 'package:compiler/src/dart2jslib.dart';
18 import 'package:compiler/src/apiimpl.dart' as apiimpl; 19 import 'package:compiler/src/apiimpl.dart' as apiimpl;
19 import 'package:compiler/src/elements/elements.dart'; 20 import 'package:compiler/src/elements/elements.dart';
20 import 'package:compiler/src/library_loader.dart'; 21 import 'package:compiler/src/library_loader.dart';
22 import 'package:compiler/src/null_compiler_output.dart';
23 import 'package:compiler/src/old_to_new_api.dart';
21 import 'package:compiler/src/resolution/resolution.dart'; 24 import 'package:compiler/src/resolution/resolution.dart';
22 import 'package:compiler/src/scanner/scannerlib.dart'; 25 import 'package:compiler/src/scanner/scannerlib.dart';
23 import 'package:compiler/src/util/util.dart'; 26 import 'package:compiler/src/util/util.dart';
24 27
25 class TestCompiler extends apiimpl.Compiler { 28 class TestCompiler extends apiimpl.Compiler {
26 final String testMarker; 29 final String testMarker;
27 final String testType; 30 final String testType;
28 final Function onTest; 31 final Function onTest;
29 32
30 TestCompiler(api.CompilerInputProvider inputProvider, 33 TestCompiler(api.CompilerInput inputProvider,
31 api.CompilerOutputProvider outputProvider, 34 api.CompilerOutput outputProvider,
32 api.DiagnosticHandler handler, 35 api.CompilerDiagnostics handler,
33 Uri libraryRoot, 36 Uri libraryRoot,
34 Uri packageRoot, 37 Uri packageRoot,
35 List<String> options, 38 List<String> options,
36 Map<String, dynamic> environment, 39 Map<String, dynamic> environment,
37 Uri packageConfig, 40 Uri packageConfig,
38 api.PackagesDiscoveryProvider findPackages, 41 api.PackagesDiscoveryProvider findPackages,
39 String this.testMarker, 42 String this.testMarker,
40 String this.testType, 43 String this.testType,
41 Function this.onTest) 44 Function this.onTest)
42 : super(inputProvider, outputProvider, handler, libraryRoot, 45 : super(inputProvider, outputProvider, handler, libraryRoot,
43 packageRoot, options, environment, packageConfig, findPackages) { 46 packageRoot, options, environment, packageConfig, findPackages) {
44 scanner = new TestScanner(this); 47 scanner = new TestScanner(this);
45 resolver = new TestResolver(this, backend.constantCompilerTask); 48 resolver = new TestResolver(this, backend.constantCompilerTask);
46 test('Compiler'); 49 test('Compiler');
47 } 50 }
48 51
49 Future<bool> run(Uri uri) { 52 Future<bool> run(Uri uri) {
50 test('Compiler.run'); 53 test('Compiler.run');
51 return super.run(uri); 54 return super.run(uri);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 Future testExitCode( 146 Future testExitCode(
144 String marker, String type, int expectedExitCode, List options) { 147 String marker, String type, int expectedExitCode, List options) {
145 bool testOccurred = false; 148 bool testOccurred = false;
146 149
147 void onTest(String testMarker, String testType) { 150 void onTest(String testMarker, String testType) {
148 if (testMarker == marker && testType == type) { 151 if (testMarker == marker && testType == type) {
149 testOccurred = true; 152 testOccurred = true;
150 } 153 }
151 } 154 }
152 return new Future(() { 155 return new Future(() {
153 Future<api.CompilationResult> compile( 156 Future<old_api.CompilationResult> compile(
154 Uri script, 157 Uri script,
155 Uri libraryRoot, 158 Uri libraryRoot,
156 Uri packageRoot, 159 Uri packageRoot,
157 api.CompilerInputProvider inputProvider, 160 old_api.CompilerInputProvider inputProvider,
158 api.DiagnosticHandler handler, 161 old_api.DiagnosticHandler handler,
159 [List<String> options = const [], 162 [List<String> options = const [],
160 api.CompilerOutputProvider outputProvider, 163 old_api.CompilerOutputProvider outputProvider,
161 Map<String, dynamic> environment = const {}, 164 Map<String, dynamic> environment = const {},
162 Uri packageConfig, 165 Uri packageConfig,
163 api.PackagesDiscoveryProvider findPackages]) { 166 api.PackagesDiscoveryProvider findPackages]) {
164 libraryRoot = Platform.script.resolve('../../../sdk/'); 167 libraryRoot = Platform.script.resolve('../../../sdk/');
165 outputProvider = NullSink.outputProvider; 168 outputProvider = NullSink.outputProvider;
166 // Use this to silence the test when debugging: 169 // Use this to silence the test when debugging:
167 // handler = (uri, begin, end, message, kind) {}; 170 // handler = (uri, begin, end, message, kind) {};
168 Compiler compiler = new TestCompiler(inputProvider, 171 Compiler compiler = new TestCompiler(
169 outputProvider, 172 new LegacyCompilerInput(inputProvider),
170 handler, 173 new LegacyCompilerOutput(outputProvider),
171 libraryRoot, 174 new LegacyCompilerDiagnostics(handler),
172 packageRoot, 175 libraryRoot,
173 options, 176 packageRoot,
174 environment, 177 options,
175 packageConfig, 178 environment,
176 findPackages, 179 packageConfig,
177 marker, 180 findPackages,
178 type, 181 marker,
179 onTest); 182 type,
183 onTest);
180 return compiler.run(script).then((bool success) { 184 return compiler.run(script).then((bool success) {
181 return new api.CompilationResult(compiler, isSuccess: success); 185 return new old_api.CompilationResult(compiler, isSuccess: success);
182 }); 186 });
183 } 187 }
184 188
185 int foundExitCode; 189 int foundExitCode;
186 190
187 checkResult() { 191 checkResult() {
188 Expect.isTrue(testOccurred, 'testExitCode($marker, $type) did not occur'); 192 Expect.isTrue(testOccurred, 'testExitCode($marker, $type) did not occur');
189 if (foundExitCode == null) foundExitCode = 0; 193 if (foundExitCode == null) foundExitCode = 0;
190 print('testExitCode($marker, $type) ' 194 print('testExitCode($marker, $type) '
191 'exitCode=$foundExitCode expected=$expectedExitCode'); 195 'exitCode=$foundExitCode expected=$expectedExitCode');
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 273
270 expected = _expectedExitCode( 274 expected = _expectedExitCode(
271 beforeRun: tests[marker], fatalWarnings: true); 275 beforeRun: tests[marker], fatalWarnings: true);
272 totalExpectedErrors += expected.length; 276 totalExpectedErrors += expected.length;
273 await testExitCodes(marker, expected, ['--fatal-warnings']); 277 await testExitCodes(marker, expected, ['--fatal-warnings']);
274 } 278 }
275 279
276 Expect.equals(totalExpectedErrors, checkedResults); 280 Expect.equals(totalExpectedErrors, checkedResults);
277 }); 281 });
278 } 282 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/diagnose_ambiguous_test.dart ('k') | tests/compiler/dart2js/incremental/compile_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698