| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * Classes and methods for executing tests. | 6 * Classes and methods for executing tests. |
| 7 * | 7 * |
| 8 * This module includes: | 8 * This module includes: |
| 9 * - Managing parallel execution of tests, including timeout checks. | 9 * - Managing parallel execution of tests, including timeout checks. |
| 10 * - Evaluating the output of each test as pass/fail/crash/timeout. | 10 * - Evaluating the output of each test as pass/fail/crash/timeout. |
| 11 */ | 11 */ |
| 12 library test_runner; | 12 library test_runner; |
| 13 | 13 |
| 14 import "dart:async"; | 14 import "dart:async"; |
| 15 import "dart:collection" show Queue; | 15 import "dart:collection" show Queue; |
| 16 import "dart:convert" show LineSplitter, UTF8; | 16 import "dart:convert" show LineSplitter, UTF8; |
| 17 // We need to use the 'io' prefix here, otherwise io.exitCode will shadow | 17 // We need to use the 'io' prefix here, otherwise io.exitCode will shadow |
| 18 // CommandOutput.exitCode in subclasses of CommandOutput. | 18 // CommandOutput.exitCode in subclasses of CommandOutput. |
| 19 import "dart:io" as io; | 19 import "dart:io" as io; |
| 20 import "dart:math" as math; | 20 import "dart:math" as math; |
| 21 import 'dependency_graph.dart' as dgraph; | 21 import 'dependency_graph.dart' as dgraph; |
| 22 import "browser_controller.dart"; | 22 import "browser_controller.dart"; |
| 23 import "status_file_parser.dart"; | 23 import "status_file_parser.dart"; |
| 24 import "test_progress.dart"; | 24 import "test_progress.dart"; |
| 25 import "test_suite.dart"; | 25 import "test_suite.dart"; |
| 26 import "utils.dart"; | 26 import "utils.dart"; |
| 27 import 'record_and_replay.dart'; | 27 import 'record_and_replay.dart'; |
| 28 | 28 |
| 29 const int CRASHING_BROWSER_EXITCODE = -10; |
| 29 const int SLOW_TIMEOUT_MULTIPLIER = 4; | 30 const int SLOW_TIMEOUT_MULTIPLIER = 4; |
| 30 | 31 |
| 31 const MESSAGE_CANNOT_OPEN_DISPLAY = 'Gtk-WARNING **: cannot open display'; | 32 const MESSAGE_CANNOT_OPEN_DISPLAY = 'Gtk-WARNING **: cannot open display'; |
| 32 const MESSAGE_FAILED_TO_RUN_COMMAND = 'Failed to run command. return code=1'; | 33 const MESSAGE_FAILED_TO_RUN_COMMAND = 'Failed to run command. return code=1'; |
| 33 | 34 |
| 34 typedef void TestCaseEvent(TestCase testCase); | 35 typedef void TestCaseEvent(TestCase testCase); |
| 35 typedef void ExitCodeEvent(int exitCode); | 36 typedef void ExitCodeEvent(int exitCode); |
| 36 typedef void EnqueueMoreWork(ProcessQueue queue); | 37 typedef void EnqueueMoreWork(ProcessQueue queue); |
| 37 | 38 |
| 38 // Some IO tests use these variables and get confused if the host environment | 39 // Some IO tests use these variables and get confused if the host environment |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 return hasFailed(testCase) ? Expectation.FAIL : Expectation.PASS; | 654 return hasFailed(testCase) ? Expectation.FAIL : Expectation.PASS; |
| 654 } | 655 } |
| 655 | 656 |
| 656 bool get hasCrashed { | 657 bool get hasCrashed { |
| 657 // The Java dartc runner and dart2js exits with code 253 in case | 658 // The Java dartc runner and dart2js exits with code 253 in case |
| 658 // of unhandled exceptions. | 659 // of unhandled exceptions. |
| 659 if (exitCode == 253) return true; | 660 if (exitCode == 253) return true; |
| 660 if (io.Platform.operatingSystem == 'windows') { | 661 if (io.Platform.operatingSystem == 'windows') { |
| 661 // The VM uses std::abort to terminate on asserts. | 662 // The VM uses std::abort to terminate on asserts. |
| 662 // std::abort terminates with exit code 3 on Windows. | 663 // std::abort terminates with exit code 3 on Windows. |
| 663 if (exitCode == 3) { | 664 if (exitCode == 3 || exitCode == CRASHING_BROWSER_EXITCODE) { |
| 664 return !timedOut; | 665 return !timedOut; |
| 665 } | 666 } |
| 666 // If a program receives an uncaught system exception, the program | 667 // If a program receives an uncaught system exception, the program |
| 667 // terminates with the exception code as exit code. | 668 // terminates with the exception code as exit code. |
| 668 // The 0x3FFFFF00 mask here tries to determine if an exception indicates | 669 // The 0x3FFFFF00 mask here tries to determine if an exception indicates |
| 669 // a crash of the program. | 670 // a crash of the program. |
| 670 // System exception codes can be found in 'winnt.h', for example | 671 // System exception codes can be found in 'winnt.h', for example |
| 671 // "#define STATUS_ACCESS_VIOLATION ((DWORD) 0xC0000005)" | 672 // "#define STATUS_ACCESS_VIOLATION ((DWORD) 0xC0000005)" |
| 672 return (!timedOut && (exitCode < 0) && ((0x3FFFFF00 & exitCode) == 0)); | 673 return (!timedOut && (exitCode < 0) && ((0x3FFFFF00 & exitCode) == 0)); |
| 673 } | 674 } |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1359 String _createArgumentsLine(List<String> arguments, int timeout) { | 1360 String _createArgumentsLine(List<String> arguments, int timeout) { |
| 1360 return arguments.join(' ') + '\n'; | 1361 return arguments.join(' ') + '\n'; |
| 1361 } | 1362 } |
| 1362 | 1363 |
| 1363 void _reportResult() { | 1364 void _reportResult() { |
| 1364 if (!_currentlyRunning) return; | 1365 if (!_currentlyRunning) return; |
| 1365 // _status == '>>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}' | 1366 // _status == '>>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}' |
| 1366 | 1367 |
| 1367 var outcome = _status.split(" ")[2]; | 1368 var outcome = _status.split(" ")[2]; |
| 1368 var exitCode = 0; | 1369 var exitCode = 0; |
| 1370 if (outcome == "CRASH") exitCode = CRASHING_BROWSER_EXITCODE; |
| 1369 if (outcome == "FAIL" || outcome == "TIMEOUT") exitCode = 1; | 1371 if (outcome == "FAIL" || outcome == "TIMEOUT") exitCode = 1; |
| 1370 var output = createCommandOutput(_command, | 1372 var output = createCommandOutput(_command, |
| 1371 exitCode, | 1373 exitCode, |
| 1372 (outcome == "TIMEOUT"), | 1374 (outcome == "TIMEOUT"), |
| 1373 _testStdout, | 1375 _testStdout, |
| 1374 _testStderr, | 1376 _testStderr, |
| 1375 new DateTime.now().difference(_startTime), | 1377 new DateTime.now().difference(_startTime), |
| 1376 false); | 1378 false); |
| 1377 assert(_completer != null); | 1379 assert(_completer != null); |
| 1378 _completer.complete(output); | 1380 _completer.complete(output); |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2214 } | 2216 } |
| 2215 } | 2217 } |
| 2216 | 2218 |
| 2217 void eventAllTestsDone() { | 2219 void eventAllTestsDone() { |
| 2218 for (var listener in _eventListener) { | 2220 for (var listener in _eventListener) { |
| 2219 listener.allDone(); | 2221 listener.allDone(); |
| 2220 } | 2222 } |
| 2221 _allDone(); | 2223 _allDone(); |
| 2222 } | 2224 } |
| 2223 } | 2225 } |
| OLD | NEW |