| 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. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 import 'command.dart'; | 22 import 'command.dart'; |
| 23 import 'command_output.dart'; | 23 import 'command_output.dart'; |
| 24 import 'configuration.dart'; | 24 import 'configuration.dart'; |
| 25 import 'dependency_graph.dart' as dgraph; | 25 import 'dependency_graph.dart' as dgraph; |
| 26 import 'expectation.dart'; | 26 import 'expectation.dart'; |
| 27 import 'runtime_configuration.dart'; | 27 import 'runtime_configuration.dart'; |
| 28 import 'test_progress.dart'; | 28 import 'test_progress.dart'; |
| 29 import 'test_suite.dart'; | 29 import 'test_suite.dart'; |
| 30 import 'utils.dart'; | 30 import 'utils.dart'; |
| 31 | 31 |
| 32 const int CRASHING_BROWSER_EXITCODE = -10; | 32 const int browserCrashExitCode = -10; |
| 33 const int SLOW_TIMEOUT_MULTIPLIER = 4; | 33 const int slowTimeoutMultiplier = 4; |
| 34 const int NON_UTF_FAKE_EXITCODE = 0xFFFD; | 34 const int nonUtfFakeExitCode = 0xFFFD; |
| 35 | 35 |
| 36 const MESSAGE_CANNOT_OPEN_DISPLAY = 'Gtk-WARNING **: cannot open display'; | 36 const cannotOpenDisplayMessage = 'Gtk-WARNING **: cannot open display'; |
| 37 const MESSAGE_FAILED_TO_RUN_COMMAND = 'Failed to run command. return code=1'; | 37 const failedToRunCommandMessage = 'Failed to run command. return code=1'; |
| 38 | 38 |
| 39 typedef void TestCaseEvent(TestCase testCase); | 39 typedef void TestCaseEvent(TestCase testCase); |
| 40 typedef void ExitCodeEvent(int exitCode); | 40 typedef void ExitCodeEvent(int exitCode); |
| 41 typedef void EnqueueMoreWork(ProcessQueue queue); | 41 typedef void EnqueueMoreWork(ProcessQueue queue); |
| 42 typedef void Action(); | 42 typedef void Action(); |
| 43 typedef Future<AdbCommandResult> StepFunction(); | 43 typedef Future<AdbCommandResult> StepFunction(); |
| 44 | 44 |
| 45 // Some IO tests use these variables and get confused if the host environment | 45 /// Some IO tests use these variables and get confused if the host environment |
| 46 // variables are inherited so they are excluded. | 46 /// variables are inherited so they are excluded. |
| 47 const EXCLUDED_ENVIRONMENT_VARIABLES = const [ | 47 const _excludedEnvironmentVariables = const [ |
| 48 'http_proxy', | 48 'http_proxy', |
| 49 'https_proxy', | 49 'https_proxy', |
| 50 'no_proxy', | 50 'no_proxy', |
| 51 'HTTP_PROXY', | 51 'HTTP_PROXY', |
| 52 'HTTPS_PROXY', | 52 'HTTPS_PROXY', |
| 53 'NO_PROXY' | 53 'NO_PROXY' |
| 54 ]; | 54 ]; |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * TestCase contains all the information needed to run a test and evaluate | 57 * TestCase contains all the information needed to run a test and evaluate |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 throw new Exception("CommandOutputs is empty, maybe no command was run? (" | 159 throw new Exception("CommandOutputs is empty, maybe no command was run? (" |
| 160 "displayName: '$displayName', " | 160 "displayName: '$displayName', " |
| 161 "configurationString: '$configurationString')"); | 161 "configurationString: '$configurationString')"); |
| 162 } | 162 } |
| 163 return commands[commandOutputs.length - 1]; | 163 return commands[commandOutputs.length - 1]; |
| 164 } | 164 } |
| 165 | 165 |
| 166 int get timeout { | 166 int get timeout { |
| 167 var result = configuration.timeout; | 167 var result = configuration.timeout; |
| 168 if (expectedOutcomes.contains(Expectation.slow)) { | 168 if (expectedOutcomes.contains(Expectation.slow)) { |
| 169 result *= SLOW_TIMEOUT_MULTIPLIER; | 169 result *= slowTimeoutMultiplier; |
| 170 } | 170 } |
| 171 return result; | 171 return result; |
| 172 } | 172 } |
| 173 | 173 |
| 174 String get configurationString { | 174 String get configurationString { |
| 175 var compiler = configuration.compiler.name; | 175 var compiler = configuration.compiler.name; |
| 176 var runtime = configuration.runtime.name; | 176 var runtime = configuration.runtime.name; |
| 177 var mode = configuration.mode.name; | 177 var mode = configuration.mode.name; |
| 178 var arch = configuration.architecture.name; | 178 var arch = configuration.architecture.name; |
| 179 var checked = configuration.isChecked ? '-checked' : ''; | 179 var checked = configuration.isChecked ? '-checked' : ''; |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 completer.complete(commandOutput); | 536 completer.complete(commandOutput); |
| 537 } | 537 } |
| 538 | 538 |
| 539 CommandOutput _createCommandOutput(ProcessCommand command, int exitCode) { | 539 CommandOutput _createCommandOutput(ProcessCommand command, int exitCode) { |
| 540 List<int> stdoutData = stdout.toList(); | 540 List<int> stdoutData = stdout.toList(); |
| 541 List<int> stderrData = stderr.toList(); | 541 List<int> stderrData = stderr.toList(); |
| 542 if (stdout.hasNonUtf8 || stderr.hasNonUtf8) { | 542 if (stdout.hasNonUtf8 || stderr.hasNonUtf8) { |
| 543 // If the output contained non-utf8 formatted data, then make the exit | 543 // If the output contained non-utf8 formatted data, then make the exit |
| 544 // code non-zero if it isn't already. | 544 // code non-zero if it isn't already. |
| 545 if (exitCode == 0) { | 545 if (exitCode == 0) { |
| 546 exitCode = NON_UTF_FAKE_EXITCODE; | 546 exitCode = nonUtfFakeExitCode; |
| 547 } | 547 } |
| 548 } | 548 } |
| 549 var commandOutput = createCommandOutput( | 549 var commandOutput = createCommandOutput( |
| 550 command, | 550 command, |
| 551 exitCode, | 551 exitCode, |
| 552 timedOut, | 552 timedOut, |
| 553 stdoutData, | 553 stdoutData, |
| 554 stderrData, | 554 stderrData, |
| 555 new DateTime.now().difference(startTime), | 555 new DateTime.now().difference(startTime), |
| 556 compilationSkipped, | 556 compilationSkipped, |
| 557 pid); | 557 pid); |
| 558 commandOutput.diagnostics.addAll(diagnostics); | 558 commandOutput.diagnostics.addAll(diagnostics); |
| 559 return commandOutput; | 559 return commandOutput; |
| 560 } | 560 } |
| 561 | 561 |
| 562 StreamSubscription _drainStream( | 562 StreamSubscription _drainStream( |
| 563 Stream<List<int>> source, OutputLog destination) { | 563 Stream<List<int>> source, OutputLog destination) { |
| 564 return source.listen(destination.add); | 564 return source.listen(destination.add); |
| 565 } | 565 } |
| 566 | 566 |
| 567 Map<String, String> _createProcessEnvironment() { | 567 Map<String, String> _createProcessEnvironment() { |
| 568 var environment = new Map<String, String>.from(io.Platform.environment); | 568 var environment = new Map<String, String>.from(io.Platform.environment); |
| 569 | 569 |
| 570 if (command.environmentOverrides != null) { | 570 if (command.environmentOverrides != null) { |
| 571 for (var key in command.environmentOverrides.keys) { | 571 for (var key in command.environmentOverrides.keys) { |
| 572 environment[key] = command.environmentOverrides[key]; | 572 environment[key] = command.environmentOverrides[key]; |
| 573 } | 573 } |
| 574 } | 574 } |
| 575 for (var excludedEnvironmentVariable in EXCLUDED_ENVIRONMENT_VARIABLES) { | 575 for (var excludedEnvironmentVariable in _excludedEnvironmentVariables) { |
| 576 environment.remove(excludedEnvironmentVariable); | 576 environment.remove(excludedEnvironmentVariable); |
| 577 } | 577 } |
| 578 | 578 |
| 579 // TODO(terry): Needed for roll 50? | 579 // TODO(terry): Needed for roll 50? |
| 580 environment["GLIBCPP_FORCE_NEW"] = "1"; | 580 environment["GLIBCPP_FORCE_NEW"] = "1"; |
| 581 environment["GLIBCXX_FORCE_NEW"] = "1"; | 581 environment["GLIBCXX_FORCE_NEW"] = "1"; |
| 582 | 582 |
| 583 return environment; | 583 return environment; |
| 584 } | 584 } |
| 585 } | 585 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 String _createArgumentsLine(List<String> arguments, int timeout) { | 673 String _createArgumentsLine(List<String> arguments, int timeout) { |
| 674 return arguments.join(' ') + '\n'; | 674 return arguments.join(' ') + '\n'; |
| 675 } | 675 } |
| 676 | 676 |
| 677 void _reportResult() { | 677 void _reportResult() { |
| 678 if (!_currentlyRunning) return; | 678 if (!_currentlyRunning) return; |
| 679 // _status == '>>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}' | 679 // _status == '>>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}' |
| 680 | 680 |
| 681 var outcome = _status.split(" ")[2]; | 681 var outcome = _status.split(" ")[2]; |
| 682 var exitCode = 0; | 682 var exitCode = 0; |
| 683 if (outcome == "CRASH") exitCode = CRASHING_BROWSER_EXITCODE; | 683 if (outcome == "CRASH") exitCode = browserCrashExitCode; |
| 684 if (outcome == "FAIL" || outcome == "TIMEOUT") exitCode = 1; | 684 if (outcome == "FAIL" || outcome == "TIMEOUT") exitCode = 1; |
| 685 var output = createCommandOutput( | 685 var output = createCommandOutput( |
| 686 _command, | 686 _command, |
| 687 exitCode, | 687 exitCode, |
| 688 (outcome == "TIMEOUT"), | 688 (outcome == "TIMEOUT"), |
| 689 _testStdout.toList(), | 689 _testStdout.toList(), |
| 690 _testStderr.toList(), | 690 _testStderr.toList(), |
| 691 new DateTime.now().difference(_startTime), | 691 new DateTime.now().difference(_startTime), |
| 692 false); | 692 false); |
| 693 assert(_completer != null); | 693 assert(_completer != null); |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1291 if (!runner._currentlyRunning) return runner; | 1291 if (!runner._currentlyRunning) return runner; |
| 1292 } | 1292 } |
| 1293 throw new Exception('Unable to find inactive batch runner.'); | 1293 throw new Exception('Unable to find inactive batch runner.'); |
| 1294 } | 1294 } |
| 1295 | 1295 |
| 1296 Future<CommandOutput> _startBrowserControllerTest( | 1296 Future<CommandOutput> _startBrowserControllerTest( |
| 1297 BrowserTestCommand browserCommand, int timeout) { | 1297 BrowserTestCommand browserCommand, int timeout) { |
| 1298 var completer = new Completer<CommandOutput>(); | 1298 var completer = new Completer<CommandOutput>(); |
| 1299 | 1299 |
| 1300 var callback = (BrowserTestOutput output) { | 1300 var callback = (BrowserTestOutput output) { |
| 1301 completer.complete(new BrowserCommandOutputImpl(browserCommand, output)); | 1301 completer.complete(new BrowserCommandOutput(browserCommand, output)); |
| 1302 }; | 1302 }; |
| 1303 | 1303 |
| 1304 BrowserTest browserTest; | 1304 BrowserTest browserTest; |
| 1305 if (browserCommand is BrowserHtmlTestCommand) { | 1305 if (browserCommand is BrowserHtmlTestCommand) { |
| 1306 browserTest = new HtmlTest(browserCommand.url, callback, timeout, | 1306 browserTest = new HtmlTest(browserCommand.url, callback, timeout, |
| 1307 browserCommand.expectedMessages); | 1307 browserCommand.expectedMessages); |
| 1308 } else { | 1308 } else { |
| 1309 browserTest = new BrowserTest(browserCommand.url, callback, timeout); | 1309 browserTest = new BrowserTest(browserCommand.url, callback, timeout); |
| 1310 } | 1310 } |
| 1311 _getBrowserTestRunner(browserCommand.configuration).then((testRunner) { | 1311 _getBrowserTestRunner(browserCommand.configuration).then((testRunner) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 // See http://dartbug.com/29655 . | 1372 // See http://dartbug.com/29655 . |
| 1373 if (command is ContentShellCommand) { | 1373 if (command is ContentShellCommand) { |
| 1374 return true; | 1374 return true; |
| 1375 } | 1375 } |
| 1376 | 1376 |
| 1377 if (io.Platform.operatingSystem == 'linux') { | 1377 if (io.Platform.operatingSystem == 'linux') { |
| 1378 decodeOutput(); | 1378 decodeOutput(); |
| 1379 // No matter which command we ran: If we get failures due to the | 1379 // No matter which command we ran: If we get failures due to the |
| 1380 // "xvfb-run" issue 7564, try re-running the test. | 1380 // "xvfb-run" issue 7564, try re-running the test. |
| 1381 bool containsFailureMsg(String line) { | 1381 bool containsFailureMsg(String line) { |
| 1382 return line.contains(MESSAGE_CANNOT_OPEN_DISPLAY) || | 1382 return line.contains(cannotOpenDisplayMessage) || |
| 1383 line.contains(MESSAGE_FAILED_TO_RUN_COMMAND); | 1383 line.contains(failedToRunCommandMessage); |
| 1384 } | 1384 } |
| 1385 | 1385 |
| 1386 if (stdout.any(containsFailureMsg) || stderr.any(containsFailureMsg)) { | 1386 if (stdout.any(containsFailureMsg) || stderr.any(containsFailureMsg)) { |
| 1387 return true; | 1387 return true; |
| 1388 } | 1388 } |
| 1389 } | 1389 } |
| 1390 } | 1390 } |
| 1391 return false; | 1391 return false; |
| 1392 } | 1392 } |
| 1393 | 1393 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 } | 1663 } |
| 1664 } | 1664 } |
| 1665 | 1665 |
| 1666 void eventAllTestsDone() { | 1666 void eventAllTestsDone() { |
| 1667 for (var listener in _eventListener) { | 1667 for (var listener in _eventListener) { |
| 1668 listener.allDone(); | 1668 listener.allDone(); |
| 1669 } | 1669 } |
| 1670 _allDone(); | 1670 _allDone(); |
| 1671 } | 1671 } |
| 1672 } | 1672 } |
| OLD | NEW |