Chromium Code Reviews| Index: dart/tools/testing/dart/test_runner.dart |
| diff --git a/dart/tools/testing/dart/test_runner.dart b/dart/tools/testing/dart/test_runner.dart |
| index 0bb1fa0c617f81aa722029dae3989912563186b1..f8874e3cdf17a2cfb573e1384cb821eefb7c36b1 100644 |
| --- a/dart/tools/testing/dart/test_runner.dart |
| +++ b/dart/tools/testing/dart/test_runner.dart |
| @@ -905,6 +905,96 @@ class HTMLBrowserCommandOutputImpl extends BrowserCommandOutputImpl { |
| } |
| } |
| +class BrowserControllerTestOutcome extends CommandOutputImpl |
| + with UnittestSuiteMessagesMixin { |
| + BrowserTestOutput _result; |
| + factory BrowserControllerTestOutcome( |
| + Command command, BrowserTestOutput result) { |
| + String indent(String string, int numSpaces) { |
| + var SPACE = ' '; |
| + var spaces = ''; |
| + for (var i = 0; i < numSpaces; i++) spaces += SPACE; |
| + |
| + var buffer = new StringBuffer(); |
| + var lines = string.replaceAll('\r', '').split('\n'); |
| + for (var i = 0; i < lines.length; i++) { |
| + buffer.write("$spaces${lines[i]}"); |
| + if (i != lines.length) { |
| + buffer.write('\n'); |
| + } |
| + } |
| + return buffer.toString(); |
| + } |
| + |
| + String stdout = ""; |
| + String stderr = ""; |
| + if (result.didTimeout) { |
| + if (result.delayUntilTestStarted != null) { |
| + stderr = "This test timed out. The delay until the test actually " |
| + "started was: ${result.delayUntilTestStarted}."; |
| + } else { |
| + stderr = "This test has not notified test.py that it started running. " |
| + "This could be a bug in test.py! " |
| + "Please contact ricow/kustermann"; |
| + } |
| + } else { |
| + // NOTE: If the test timed out, we do not have this information. |
| + stdout = |
| + "TestOutcome: ${result.outcome}\n\n" |
| + "DOM:\n" |
| + "${indent(result.dom, 2)}\n\n" |
| + "print() calls: \n" |
| + "${indent(result.printCalls.join('\n'), 2)}\n\n" |
| + "messages received:\n" |
| + "${indent(result.receivedMessages.join('\n'), 2)}\n\n" |
| + "debug messages:\n" |
| + "${indent(result.debugMessages.join('\n'), 2)}\n\n"; |
| + } |
| + stderr = |
| + '$stderr\n\n' |
| + 'BrowserOutput while running the test (* EXPERIMENTAL *):\n' |
| + 'BrowserOutput.stdout:\n' |
| + '${indent(result.browserOutput.stdout.toString(), 2)}\n' |
| + 'BrowserOutput.stderr:\n' |
| + '${indent(result.browserOutput.stderr.toString(), 2)}\n' |
| + '\n'; |
| + |
| + return new BrowserControllerTestOutcome._internal( |
| + command, result, encodeUtf8(stdout), encodeUtf8(stderr)); |
| + } |
| + |
| + BrowserControllerTestOutcome._internal( |
| + Command command, BrowserTestOutput result, |
| + List<int> stdout, List<int> stderr) |
| + : super(command, 0, result.didTimeout, stdout, stderr, result.duration, |
| + false) { |
| + _result = result; |
| + } |
| + |
| + Expectation result(TestCase testCase) { |
| + // Handle timeouts first |
| + if (_result.didTimeout) return Expectation.TIMEOUT; |
| + |
| + // If the test didn't start, we've a problem. Report it as a failure. |
| + if (_result.outcome == 'NOT_STARTED') return Expectation.FAIL; |
| + |
| + Expectation outcome; |
| + if (_result.outcome == 'FAIL') outcome = Expectation.RUNTIME_ERROR; |
| + else if (_result.outcome == 'PASS') outcome = Expectation.PASS; |
| + else throw "error"; |
|
ricow1
2013/10/23 11:42:32
throw a better error
|
| + |
| + // Multitests are handled specially |
| + if (testCase.info != null) { |
| + if (testCase.info.hasRuntimeError) { |
| + if (outcome == Expectation.RUNTIME_ERROR) return Expectation.PASS; |
| + return Expectation.MISSING_RUNTIME_ERROR; |
| + } |
| + } |
| + |
| + return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); |
| + } |
| +} |
| + |
| // The static analyzer does not actually execute code, so |
| // the criteria for success now depend on the text sent |
| @@ -1993,31 +2083,8 @@ class CommandExecutorImpl implements CommandExecutor { |
| var completer = new Completer<CommandOutput>(); |
| var callback = (BrowserTestOutput output) { |
| - bool timedOut = output.didTimeout; |
| - String stderr = ""; |
| - if (timedOut) { |
| - if (output.delayUntilTestStarted != null) { |
| - stderr = "This test timed out. The delay until the test actually " |
| - "started was: ${output.delayUntilTestStarted}."; |
| - } else { |
| - stderr = "This test has not notified test.py that it started running." |
| - " This could be a bug in test.py! " |
| - "Please contact ricow/kustermann"; |
| - } |
| - } |
| - stderr = |
| - '$stderr\n\n' |
| - 'BrowserOutput while running the test (* EXPERIMENTAL *):\n' |
| - 'BrowserOutput.stdout:\n${output.browserOutput.stdout.toString()}\n' |
| - 'BrowserOutput.stderr:\n${output.browserOutput.stderr.toString()}\n'; |
| - var commandOutput = createCommandOutput(browserCommand, |
| - 0, |
| - timedOut, |
| - encodeUtf8(output.dom), |
| - encodeUtf8(stderr), |
| - output.duration, |
| - false); |
| - completer.complete(commandOutput); |
| + completer.complete( |
| + new BrowserControllerTestOutcome(browserCommand, output)); |
| }; |
| BrowserTest browserTest = new BrowserTest(browserCommand.url, |
| callback, |