| 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, fatal errors, errors, | 5 // Test the exit code of dart2js in case of exceptions, errors, warnings, etc. |
| 6 // warnings, etc. | |
| 7 | 6 |
| 8 | 7 |
| 9 import 'dart:async'; | 8 import 'dart:async'; |
| 10 import 'dart:io' show Platform; | 9 import 'dart:io' show Platform; |
| 11 | 10 |
| 12 import 'package:async_helper/async_helper.dart'; | 11 import 'package:async_helper/async_helper.dart'; |
| 13 import 'package:expect/expect.dart'; | 12 import 'package:expect/expect.dart'; |
| 14 | 13 |
| 15 import 'package:compiler/compiler.dart' as api; | 14 import 'package:compiler/compiler.dart' as api; |
| 16 import 'package:compiler/src/dart2js.dart' as entry; | 15 import 'package:compiler/src/dart2js.dart' as entry; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 case 'warning': | 89 case 'warning': |
| 91 onTest(testMarker, testType); | 90 onTest(testMarker, testType); |
| 92 reportWarning(NO_LOCATION_SPANNABLE, | 91 reportWarning(NO_LOCATION_SPANNABLE, |
| 93 MessageKind.GENERIC, {'text': marker}); | 92 MessageKind.GENERIC, {'text': marker}); |
| 94 break; | 93 break; |
| 95 case 'error': | 94 case 'error': |
| 96 onTest(testMarker, testType); | 95 onTest(testMarker, testType); |
| 97 reportError(NO_LOCATION_SPANNABLE, | 96 reportError(NO_LOCATION_SPANNABLE, |
| 98 MessageKind.GENERIC, {'text': marker}); | 97 MessageKind.GENERIC, {'text': marker}); |
| 99 break; | 98 break; |
| 100 case 'fatalError': | |
| 101 onTest(testMarker, testType); | |
| 102 reportError(NO_LOCATION_SPANNABLE, | |
| 103 MessageKind.GENERIC, {'text': marker}); | |
| 104 throw new CompilerCancelledException(null); | |
| 105 break; | |
| 106 case 'internalError': | 99 case 'internalError': |
| 107 onTest(testMarker, testType); | 100 onTest(testMarker, testType); |
| 108 internalError(NO_LOCATION_SPANNABLE, marker); | 101 internalError(NO_LOCATION_SPANNABLE, marker); |
| 109 break; | 102 break; |
| 110 case 'NoSuchMethodError': | 103 case 'NoSuchMethodError': |
| 111 onTest(testMarker, testType); | 104 onTest(testMarker, testType); |
| 112 null.foo; | 105 null.foo; |
| 113 break; | 106 break; |
| 114 case '': | 107 case '': |
| 115 onTest(testMarker, testType); | 108 onTest(testMarker, testType); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 'invariant': 253 | 221 'invariant': 253 |
| 229 }; | 222 }; |
| 230 | 223 |
| 231 final duringRun = { | 224 final duringRun = { |
| 232 '': 0, | 225 '': 0, |
| 233 'NoSuchMethodError': 253, | 226 'NoSuchMethodError': 253, |
| 234 'assert': isCheckedMode ? 253 : 0, | 227 'assert': isCheckedMode ? 253 : 0, |
| 235 'invariant': 253, | 228 'invariant': 253, |
| 236 'warning': 0, | 229 'warning': 0, |
| 237 'error': 1, | 230 'error': 1, |
| 238 'fatalError': 1, | |
| 239 'internalError': 253, | 231 'internalError': 253, |
| 240 }; | 232 }; |
| 241 | 233 |
| 242 final tests = { | 234 final tests = { |
| 243 'Compiler': beforeRun, | 235 'Compiler': beforeRun, |
| 244 'Compiler.run': beforeRun, | 236 'Compiler.run': beforeRun, |
| 245 'Compiler.onLibraryScanned': beforeRun, | 237 'Compiler.onLibraryScanned': beforeRun, |
| 246 'Compiler.onLibrariesLoaded': beforeRun, | 238 'Compiler.onLibrariesLoaded': beforeRun, |
| 247 'ScannerTask.scanElements': duringRun, | 239 'ScannerTask.scanElements': duringRun, |
| 248 'Compiler.withCurrentElement': duringRun, | 240 'Compiler.withCurrentElement': duringRun, |
| 249 'Compiler.analyzeElement': duringRun, | 241 'Compiler.analyzeElement': duringRun, |
| 250 'Compiler.codegen': duringRun, | 242 'Compiler.codegen': duringRun, |
| 251 'ResolverTask.computeClassMembers': duringRun, | 243 'ResolverTask.computeClassMembers': duringRun, |
| 252 }; | 244 }; |
| 253 | 245 |
| 254 asyncStart(); | 246 asyncStart(); |
| 255 Future.forEach(tests.keys, (marker) { | 247 Future.forEach(tests.keys, (marker) { |
| 256 return testExitCodes(marker, tests[marker]); | 248 return testExitCodes(marker, tests[marker]); |
| 257 }).then((_) { | 249 }).then((_) { |
| 258 int countResults(Map runType) { | 250 int countResults(Map runType) { |
| 259 return runType.length * | 251 return runType.length * |
| 260 tests.values.where((r) => r == runType).length; | 252 tests.values.where((r) => r == runType).length; |
| 261 } | 253 } |
| 262 | 254 |
| 263 Expect.equals(countResults(beforeRun) + countResults(duringRun), | 255 Expect.equals(countResults(beforeRun) + countResults(duringRun), |
| 264 checkedResults); | 256 checkedResults); |
| 265 asyncEnd(); | 257 asyncEnd(); |
| 266 }); | 258 }); |
| 267 } | 259 } |
| OLD | NEW |