OLD | NEW |
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 |
(...skipping 19 matching lines...) Expand all Loading... |
30 import 'package:compiler/src/options.dart' show CompilerOptions; | 30 import 'package:compiler/src/options.dart' show CompilerOptions; |
31 import 'package:compiler/src/resolution/resolution.dart'; | 31 import 'package:compiler/src/resolution/resolution.dart'; |
32 import 'package:compiler/src/scanner/scanner_task.dart'; | 32 import 'package:compiler/src/scanner/scanner_task.dart'; |
33 import 'package:compiler/src/universe/world_impact.dart'; | 33 import 'package:compiler/src/universe/world_impact.dart'; |
34 import 'diagnostic_reporter_helper.dart'; | 34 import 'diagnostic_reporter_helper.dart'; |
35 | 35 |
36 class TestCompiler extends apiimpl.CompilerImpl { | 36 class TestCompiler extends apiimpl.CompilerImpl { |
37 final String testMarker; | 37 final String testMarker; |
38 final String testType; | 38 final String testType; |
39 final Function onTest; | 39 final Function onTest; |
40 DiagnosticReporter reporter; | 40 TestDiagnosticReporter reporter; |
41 | 41 |
42 TestCompiler(api.CompilerInput inputProvider, | 42 TestCompiler(api.CompilerInput inputProvider, |
43 api.CompilerOutput outputProvider, | 43 api.CompilerOutput outputProvider, |
44 api.CompilerDiagnostics handler, | 44 api.CompilerDiagnostics handler, |
45 Uri libraryRoot, | 45 Uri libraryRoot, |
46 Uri packageRoot, | 46 Uri packageRoot, |
47 List<String> options, | 47 List<String> options, |
48 Map<String, dynamic> environment, | 48 Map<String, dynamic> environment, |
49 Uri packageConfig, | 49 Uri packageConfig, |
50 api.PackagesDiscoveryProvider findPackages, | 50 api.PackagesDiscoveryProvider findPackages, |
51 String this.testMarker, | 51 String this.testMarker, |
52 String this.testType, | 52 String this.testType, |
53 Function this.onTest) | 53 Function this.onTest) |
54 : super(inputProvider, outputProvider, handler, | 54 : reporter = new TestDiagnosticReporter(), |
| 55 super(inputProvider, outputProvider, handler, |
55 new CompilerOptions.parse( | 56 new CompilerOptions.parse( |
56 libraryRoot: libraryRoot, | 57 libraryRoot: libraryRoot, |
57 packageRoot: packageRoot, | 58 packageRoot: packageRoot, |
58 options: options, | 59 options: options, |
59 environment: environment, | 60 environment: environment, |
60 packageConfig: packageConfig, | 61 packageConfig: packageConfig, |
61 packagesDiscoveryProvider: findPackages)) { | 62 packagesDiscoveryProvider: findPackages)) { |
62 reporter = new TestDiagnosticReporter(this, super.reporter); | 63 reporter.compiler = this; |
| 64 reporter.reporter = super.reporter; |
63 test('Compiler'); | 65 test('Compiler'); |
64 } | 66 } |
65 | 67 |
66 @override | 68 @override |
67 ScannerTask createScannerTask() => new TestScanner(this); | 69 ScannerTask createScannerTask() => new TestScanner(this); |
68 | 70 |
69 @override | 71 @override |
70 ResolverTask createResolverTask() { | 72 ResolverTask createResolverTask() { |
71 return new TestResolver(this, backend.constantCompilerTask); | 73 return new TestResolver(this, backend.constantCompilerTask); |
72 } | 74 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 break; | 131 break; |
130 case '': | 132 case '': |
131 onTest(testMarker, testType); | 133 onTest(testMarker, testType); |
132 break; | 134 break; |
133 } | 135 } |
134 } | 136 } |
135 } | 137 } |
136 } | 138 } |
137 | 139 |
138 class TestDiagnosticReporter extends DiagnosticReporterWrapper { | 140 class TestDiagnosticReporter extends DiagnosticReporterWrapper { |
139 final TestCompiler compiler; | 141 TestCompiler compiler; |
140 final DiagnosticReporter reporter; | 142 DiagnosticReporter reporter; |
141 | |
142 TestDiagnosticReporter(this.compiler, this.reporter); | |
143 | 143 |
144 @override | 144 @override |
145 withCurrentElement(Element element, f()) { | 145 withCurrentElement(Element element, f()) { |
146 return super.withCurrentElement(element, () { | 146 return super.withCurrentElement(element, () { |
147 compiler.test('Compiler.withCurrentElement'); | 147 compiler.test('Compiler.withCurrentElement'); |
148 return f(); | 148 return f(); |
149 }); | 149 }); |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 306 |
307 expected = _expectedExitCode( | 307 expected = _expectedExitCode( |
308 beforeRun: tests[marker], fatalWarnings: true); | 308 beforeRun: tests[marker], fatalWarnings: true); |
309 totalExpectedErrors += expected.length; | 309 totalExpectedErrors += expected.length; |
310 await testExitCodes(marker, expected, ['--fatal-warnings']); | 310 await testExitCodes(marker, expected, ['--fatal-warnings']); |
311 } | 311 } |
312 | 312 |
313 Expect.equals(totalExpectedErrors, checkedResults); | 313 Expect.equals(totalExpectedErrors, checkedResults); |
314 }); | 314 }); |
315 } | 315 } |
OLD | NEW |