Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Unified Diff: tools/testing/dart/test_runner.dart

Issue 11293278: Changed: TestCase.output -> TestCase.commandOutputs[] (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/testing/dart/test_progress.dart ('k') | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/test_runner.dart
diff --git a/tools/testing/dart/test_runner.dart b/tools/testing/dart/test_runner.dart
index 482b7fdd6389b6c58d0c1f3883282fc7496af6b9..3725233744bb72dc0c2315a45b12f5096ad35e4b 100644
--- a/tools/testing/dart/test_runner.dart
+++ b/tools/testing/dart/test_runner.dart
@@ -72,10 +72,10 @@ class TestCase {
* multiple sources that are run in isolation.
*/
List<Command> commands;
+ Map<Command, CommandOutput> commandOutputs = new Map<Command,CommandOutput>();
Map configuration;
String displayName;
- TestOutput output;
bool isNegative;
Set<String> expectedOutcomes;
TestCaseEvent completedHandler;
@@ -144,6 +144,13 @@ class TestCase {
}
}
+ CommandOutput get lastCommandOutput {
+ if (commandOutputs.length == 0) {
+ throw new Exception("CommandOutputs is empty, maybe no command was run?");
ricow1 2012/11/15 08:08:41 I would like to add a litte more context to the th
kustermann 2012/11/15 09:04:43 Done.
+ }
+ return commandOutputs[commands[commandOutputs.length - 1]];
+ }
+
int get timeout {
if (expectedOutcomes.contains(SLOW)) {
return configuration['timeout'] * SLOW_TIMEOUT_MULTIPLIER;
@@ -244,16 +251,23 @@ class BrowserTestCase extends TestCase {
* the time the process took to run. It also contains a pointer to the
* [TestCase] this is the output of.
*/
-abstract class TestOutput {
- factory TestOutput.fromCase(TestCase testCase,
- int exitCode,
- bool incomplete,
- bool timedOut,
- List<String> stdout,
- List<String> stderr,
- Duration time) {
- return new TestOutputImpl.fromCase(
- testCase, exitCode, incomplete, timedOut, stdout, stderr, time);
+abstract class CommandOutput {
+ factory CommandOutput.fromCase(TestCase testCase,
+ Command command,
+ int exitCode,
+ bool incomplete,
+ bool timedOut,
+ List<String> stdout,
+ List<String> stderr,
+ Duration time) {
+ return new CommandOutputImpl.fromCase(testCase,
+ command,
+ exitCode,
+ incomplete,
+ timedOut,
+ stdout,
+ stderr,
+ time);
}
bool get incomplete;
@@ -281,7 +295,7 @@ abstract class TestOutput {
List<String> get diagnostics;
}
-class TestOutputImpl implements TestOutput {
+class CommandOutputImpl implements CommandOutput {
TestCase testCase;
int exitCode;
@@ -309,32 +323,51 @@ class TestOutputImpl implements TestOutput {
// Don't call this constructor, call TestOutput.fromCase() to
// get a new TestOutput instance.
ricow1 2012/11/15 08:08:41 update comment
kustermann 2012/11/15 09:04:43 Done.
- TestOutputImpl(TestCase this.testCase,
- int this.exitCode,
- bool this.incomplete,
- bool this.timedOut,
- List<String> this.stdout,
- List<String> this.stderr,
- Duration this.time) {
- testCase.output = this;
+ CommandOutputImpl(TestCase this.testCase,
+ Command command,
+ int this.exitCode,
+ bool this.incomplete,
+ bool this.timedOut,
+ List<String> this.stdout,
+ List<String> this.stderr,
+ Duration this.time) {
+ testCase.commandOutputs[command] = this;
diagnostics = [];
}
- factory TestOutputImpl.fromCase(TestCase testCase,
- int exitCode,
- bool incomplete,
- bool timedOut,
- List<String> stdout,
- List<String> stderr,
- Duration time) {
+ factory CommandOutputImpl.fromCase(TestCase testCase,
+ Command command,
+ int exitCode,
+ bool incomplete,
+ bool timedOut,
+ List<String> stdout,
+ List<String> stderr,
+ Duration time) {
if (testCase is BrowserTestCase) {
- return new BrowserTestOutputImpl(testCase, exitCode, incomplete,
- timedOut, stdout, stderr, time);
+ return new BrowserCommandOutputImpl(testCase,
+ command,
+ exitCode,
+ incomplete,
+ timedOut,
+ stdout,
+ stderr,
+ time);
} else if (testCase.configuration['compiler'] == 'dartc') {
- return new AnalysisTestOutputImpl(testCase, exitCode, timedOut,
- stdout, stderr, time);
+ return new AnalysisCommandOutputImpl(testCase,
+ command,
+ exitCode,
+ timedOut,
+ stdout,
+ stderr,
+ time);
}
- return new TestOutputImpl(testCase, exitCode, incomplete, timedOut,
- stdout, stderr, time);
+ return new CommandOutputImpl(testCase,
+ command,
+ exitCode,
+ incomplete,
+ timedOut,
+ stdout,
+ stderr,
+ time);
}
String get result =>
@@ -374,10 +407,24 @@ class TestOutputImpl implements TestOutput {
}
-class BrowserTestOutputImpl extends TestOutputImpl {
- BrowserTestOutputImpl(testCase, exitCode, incomplete,
- timedOut, stdout, stderr, time) :
- super(testCase, exitCode, incomplete, timedOut, stdout, stderr, time);
+class BrowserCommandOutputImpl extends CommandOutputImpl {
+ BrowserCommandOutputImpl(
+ testCase,
+ command,
+ exitCode,
+ incomplete,
+ timedOut,
+ stdout,
+ stderr,
+ time) :
+ super(testCase,
+ command,
+ exitCode,
+ incomplete,
+ timedOut,
+ stdout,
+ stderr,
+ time);
bool get didFail {
// Browser case:
@@ -420,7 +467,7 @@ class BrowserTestOutputImpl extends TestOutputImpl {
// The static analyzer does not actually execute code, so
// the criteria for success now depend on the text sent
// to stderr.
-class AnalysisTestOutputImpl extends TestOutputImpl {
+class AnalysisCommandOutputImpl extends CommandOutputImpl {
// An error line has 8 fields that look like:
// ERROR|COMPILER|MISSING_SOURCE|file:/tmp/t.dart|15|1|24|Missing source.
final int ERROR_LEVEL = 0;
@@ -429,8 +476,14 @@ class AnalysisTestOutputImpl extends TestOutputImpl {
bool alreadyComputed = false;
bool failResult;
- AnalysisTestOutputImpl(testCase, exitCode, timedOut, stdout, stderr, time) :
- super(testCase, exitCode, false, timedOut, stdout, stderr, time);
+ AnalysisCommandOutputImpl(testCase,
+ command,
+ exitCode,
+ timedOut,
+ stdout,
+ stderr,
+ time) :
+ super(testCase, command, exitCode, false, timedOut, stdout, stderr, time);
bool get didFail {
if (!alreadyComputed) {
@@ -611,25 +664,32 @@ class RunningProcess {
* succeded, otherwise it will have the exit code of the first failing
* command.
*/
- void testComplete(int exitCode, bool incomplete) {
- new TestOutput.fromCase(testCase, exitCode, incomplete, timedOut, stdout,
- stderr, new Date.now().difference(startTime));
+ void testComplete(Command lastCommand, int exitCode, bool incomplete) {
+ var lastCommandOutput = new CommandOutput.fromCase(
+ testCase,
ricow1 2012/11/15 08:08:41 strange indentation
kustermann 2012/11/15 09:04:43 Done.
+ lastCommand,
+ exitCode,
+ incomplete,
+ timedOut,
+ stdout,
+ stderr,
+ new Date.now().difference(startTime));
timeoutTimer.cancel();
- if (testCase.output.unexpectedOutput
+ if (lastCommandOutput.unexpectedOutput
&& testCase.configuration['verbose'] != null
&& testCase.configuration['verbose']) {
print(testCase.displayName);
- for (var line in testCase.output.stderr) print(line);
- for (var line in testCase.output.stdout) print(line);
+ for (var line in lastCommandOutput.stderr) print(line);
+ for (var line in lastCommandOutput.stdout) print(line);
}
if (allowRetries && testCase.usesWebDriver
- && testCase.output.unexpectedOutput
+ && lastCommandOutput.unexpectedOutput
&& (testCase as BrowserTestCase).numRetries > 0) {
// Selenium tests can be flaky. Try rerunning.
- testCase.output.requestRetry = true;
+ lastCommandOutput.requestRetry = true;
}
- if (testCase.output.requestRetry) {
- testCase.output.requestRetry = false;
+ if (lastCommandOutput.requestRetry) {
+ lastCommandOutput.requestRetry = false;
this.timedOut = false;
(testCase as BrowserTestCase).numRetries--;
print("Potential flake. Re-running ${testCase.displayName} "
@@ -648,7 +708,7 @@ class RunningProcess {
* treats all but the last command as compilation steps. The last command is
* the actual test and its output is analyzed in [testComplete].
*/
- void stepExitHandler(int exitCode) {
+ void commandComplete(Command command, int exitCode) {
process = null;
int totalSteps = testCase.commands.length;
String suffix =' (step $currentStep of $totalSteps)';
@@ -656,14 +716,14 @@ class RunningProcess {
// Non-webdriver test timed out before it could complete. Webdriver tests
// run their own timeouts by timing from the launch of the browser (which
// could be delayed).
- testComplete(0, true);
+ testComplete(command, 0, true);
} else if (currentStep == totalSteps) {
// Done with all test commands.
- testComplete(exitCode, false);
+ testComplete(command, exitCode, false);
} else if (exitCode != 0) {
// One of the steps failed.
stderr.add('test.dart: Compilation failed$suffix, exit code $exitCode\n');
- testComplete(exitCode, true);
+ testComplete(command, exitCode, true);
} else {
// One compilation step successfully completed, move on to the
// next step.
@@ -678,7 +738,7 @@ class RunningProcess {
timeoutTimer.cancel();
processQueue._getBatchRunner(testCase).startTest(testCase);
} else {
- runCommand(testCase.commands[currentStep++], stepExitHandler);
+ runCommand(testCase.commands[currentStep++], commandComplete);
}
}
}
@@ -702,14 +762,18 @@ class RunningProcess {
stderr = new List<String>();
currentStep = 0;
startTime = new Date.now();
- runCommand(testCase.commands[currentStep++], stepExitHandler);
+ runCommand(testCase.commands[currentStep++], commandComplete);
}
- void runCommand(Command command, void exitHandler(int exitCode)) {
+ void runCommand(Command command, void commandCompleteHandler(Command, int)) {
+ void processExitHandler(int returnCode) {
+ commandCompleteHandler(command, returnCode);
+ }
+
Future processFuture = Process.start(command.executable, command.arguments);
processFuture.then((Process p) {
process = p;
- process.onExit = exitHandler;
+ process.onExit = processExitHandler;
var stdoutStringStream = new StringInputStream(process.stdout);
var stderrStringStream = new StringInputStream(process.stderr);
stdoutStringStream.onLine =
@@ -728,7 +792,7 @@ class RunningProcess {
print("Process error:");
print(" Command: $command");
print(" Error: $e");
- testComplete(-1, false);
+ testComplete(command, -1, false);
return true;
});
}
@@ -759,6 +823,7 @@ class MutableValue<T> {
}
class BatchRunnerProcess {
+ Command _command;
String _executable;
List<String> _batchArguments;
@@ -779,6 +844,7 @@ class BatchRunnerProcess {
bool _isWebDriver;
BatchRunnerProcess(TestCase testCase) {
+ _command = testCase.commands.last;
_executable = testCase.commands.last.executable;
_batchArguments = testCase.batchRunnerArguments;
_isWebDriver = testCase.usesWebDriver;
@@ -789,6 +855,7 @@ class BatchRunnerProcess {
void startTest(TestCase testCase) {
Expect.isNull(_currentTest);
_currentTest = testCase;
+ _command = testCase.commands.last;
if (_process === null) {
// Start process if not yet started.
_executable = testCase.commands.last.executable;
@@ -869,10 +936,14 @@ class BatchRunnerProcess {
var exitCode = 0;
if (outcome == "CRASH") exitCode = -10;
if (outcome == "FAIL" || outcome == "TIMEOUT") exitCode = 1;
- new TestOutput.fromCase(_currentTest, exitCode, false,
- (outcome == "TIMEOUT"),
- _testStdout, _testStderr,
- new Date.now().difference(_startTime));
+ new CommandOutput.fromCase(_currentTest,
+ _command,
+ exitCode,
+ false,
+ (outcome == "TIMEOUT"),
+ _testStdout,
+ _testStderr,
+ new Date.now().difference(_startTime));
var test = _currentTest;
_currentTest = null;
test.completed();
« no previous file with comments | « tools/testing/dart/test_progress.dart ('k') | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698