| 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 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io' show Platform; | 8 import 'dart:io' show Platform; |
| 9 | 9 |
| 10 import 'package:async_helper/async_helper.dart'; | 10 import 'package:async_helper/async_helper.dart'; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 return super.processLoadedLibraries(loadedLibraries); | 80 return super.processLoadedLibraries(loadedLibraries); |
| 81 } | 81 } |
| 82 | 82 |
| 83 test(String marker) { | 83 test(String marker) { |
| 84 if (marker == testMarker) { | 84 if (marker == testMarker) { |
| 85 switch (testType) { | 85 switch (testType) { |
| 86 case 'assert': | 86 case 'assert': |
| 87 onTest(testMarker, testType); | 87 onTest(testMarker, testType); |
| 88 assert(false); | 88 assert(false); |
| 89 break; | 89 break; |
| 90 case 'invariant': | 90 case 'failedAt': |
| 91 onTest(testMarker, testType); | 91 onTest(testMarker, testType); |
| 92 invariant(NO_LOCATION_SPANNABLE, false, message: marker); | 92 failedAt(NO_LOCATION_SPANNABLE, marker); |
| 93 break; | 93 break; |
| 94 case 'warning': | 94 case 'warning': |
| 95 onTest(testMarker, testType); | 95 onTest(testMarker, testType); |
| 96 reporter.reportWarningMessage( | 96 reporter.reportWarningMessage( |
| 97 NO_LOCATION_SPANNABLE, MessageKind.GENERIC, {'text': marker}); | 97 NO_LOCATION_SPANNABLE, MessageKind.GENERIC, {'text': marker}); |
| 98 break; | 98 break; |
| 99 case 'error': | 99 case 'error': |
| 100 onTest(testMarker, testType); | 100 onTest(testMarker, testType); |
| 101 reporter.reportErrorMessage( | 101 reporter.reportErrorMessage( |
| 102 NO_LOCATION_SPANNABLE, MessageKind.GENERIC, {'text': marker}); | 102 NO_LOCATION_SPANNABLE, MessageKind.GENERIC, {'text': marker}); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 assert((isCheckedMode = true)); | 263 assert((isCheckedMode = true)); |
| 264 | 264 |
| 265 entry.enableWriteString = false; | 265 entry.enableWriteString = false; |
| 266 | 266 |
| 267 Map _expectedExitCode({bool beforeRun: false, bool fatalWarnings: false}) { | 267 Map _expectedExitCode({bool beforeRun: false, bool fatalWarnings: false}) { |
| 268 if (beforeRun) { | 268 if (beforeRun) { |
| 269 return { | 269 return { |
| 270 '': 0, | 270 '': 0, |
| 271 'NoSuchMethodError': 253, | 271 'NoSuchMethodError': 253, |
| 272 'assert': isCheckedMode ? 253 : 0, | 272 'assert': isCheckedMode ? 253 : 0, |
| 273 'invariant': 253 | 273 'failedAt': 253 |
| 274 }; | 274 }; |
| 275 } | 275 } |
| 276 | 276 |
| 277 // duringRun: | 277 // duringRun: |
| 278 return { | 278 return { |
| 279 '': 0, | 279 '': 0, |
| 280 'NoSuchMethodError': 253, | 280 'NoSuchMethodError': 253, |
| 281 'assert': isCheckedMode ? 253 : 0, | 281 'assert': isCheckedMode ? 253 : 0, |
| 282 'invariant': 253, | 282 'failedAt': 253, |
| 283 'warning': fatalWarnings ? 1 : 0, | 283 'warning': fatalWarnings ? 1 : 0, |
| 284 'error': 1, | 284 'error': 1, |
| 285 'internalError': 253, | 285 'internalError': 253, |
| 286 }; | 286 }; |
| 287 } | 287 } |
| 288 | 288 |
| 289 const beforeRun = false; | 289 const beforeRun = false; |
| 290 const duringRun = true; | 290 const duringRun = true; |
| 291 final tests = { | 291 final tests = { |
| 292 'Compiler': beforeRun, | 292 'Compiler': beforeRun, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 308 | 308 |
| 309 expected = | 309 expected = |
| 310 _expectedExitCode(beforeRun: tests[marker], fatalWarnings: true); | 310 _expectedExitCode(beforeRun: tests[marker], fatalWarnings: true); |
| 311 totalExpectedErrors += expected.length; | 311 totalExpectedErrors += expected.length; |
| 312 await testExitCodes(marker, expected, ['--fatal-warnings']); | 312 await testExitCodes(marker, expected, ['--fatal-warnings']); |
| 313 } | 313 } |
| 314 | 314 |
| 315 Expect.equals(totalExpectedErrors, checkedResults); | 315 Expect.equals(totalExpectedErrors, checkedResults); |
| 316 }); | 316 }); |
| 317 } | 317 } |
| OLD | NEW |