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

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

Issue 11348060: Revert of commit 14947 (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 0e2af70a2602d7fa20b506c855e501be7158067d..758d91080e5846b181084827c54134b5200e759e 100644
--- a/tools/testing/dart/test_runner.dart
+++ b/tools/testing/dart/test_runner.dart
@@ -56,27 +56,26 @@ class Command {
* contains static information about the test; actually running the test is
* performed by [ProcessQueue] using a [RunningProcess] object.
*
- * The output information is stored in a [CommandOutput] instance contained
- * in TestCase.commandOutputs. The last CommandOutput instance is responsible
- * for evaluating if the test has passed, failed, crashed, or timed out, and the
- * TestCase has information about what the expected result of the test should
- * be.
+ * The output information is stored in a [TestOutput] instance contained
+ * in the TestCase. The TestOutput instance is responsible for evaluating
+ * if the test has passed, failed, crashed, or timed out, and the TestCase
+ * has information about what the expected result of the test should be.
*
* The TestCase has a callback function, [completedHandler], that is run when
* the test is completed.
*/
class TestCase {
/**
- * A list of commands to execute. Most test cases have a single command.
- * Dart2js tests have two commands, one to compile the source and another
- * to execute it. Some isolate tests might even have three, if they require
- * compiling multiple sources that are run in isolation.
+ * A list of commands to execute. Most test cases have a single command. Frog
+ * tests have two commands, one to compilate the source and another to execute
+ * it. Some isolate tests might even have three, if they require compiling
+ * 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;
@@ -145,15 +144,6 @@ class TestCase {
}
}
- CommandOutput get lastCommandOutput {
- if (commandOutputs.length == 0) {
- throw new Exception("CommandOutputs is empty, maybe no command was run? ("
- "displayName: '$displayName', "
- "configurationString: '$configurationString')");
- }
- return commandOutputs[commands[commandOutputs.length - 1]];
- }
-
int get timeout {
if (expectedOutcomes.contains(SLOW)) {
return configuration['timeout'] * SLOW_TIMEOUT_MULTIPLIER;
@@ -249,28 +239,21 @@ class BrowserTestCase extends TestCase {
/**
- * CommandOutput records the output of a completed command: the process's exit
- * code, the standard output and standard error, whether the process timed out,
- * and the time the process took to run. It also contains a pointer to the
+ * TestOutput records the output of a completed test: the process's exit code,
+ * the standard output and standard error, whether the process timed out, and
+ * the time the process took to run. It also contains a pointer to the
* [TestCase] this is the output of.
*/
-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);
+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);
}
bool get incomplete;
@@ -298,7 +281,7 @@ abstract class CommandOutput {
List<String> get diagnostics;
}
-class CommandOutputImpl implements CommandOutput {
+class TestOutputImpl implements TestOutput {
TestCase testCase;
int exitCode;
@@ -324,53 +307,34 @@ class CommandOutputImpl implements CommandOutput {
*/
bool requestRetry = false;
- // Don't call this constructor, call CommandOutput.fromCase() to
+ // Don't call this constructor, call TestOutput.fromCase() to
// get a new TestOutput instance.
- 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;
+ 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;
diagnostics = [];
}
- factory CommandOutputImpl.fromCase(TestCase testCase,
- Command command,
- int exitCode,
- bool incomplete,
- bool timedOut,
- List<String> stdout,
- List<String> stderr,
- Duration time) {
+ factory TestOutputImpl.fromCase(TestCase testCase,
+ int exitCode,
+ bool incomplete,
+ bool timedOut,
+ List<String> stdout,
+ List<String> stderr,
+ Duration time) {
if (testCase is BrowserTestCase) {
- return new BrowserCommandOutputImpl(testCase,
- command,
- exitCode,
- incomplete,
- timedOut,
- stdout,
- stderr,
- time);
+ return new BrowserTestOutputImpl(testCase, exitCode, incomplete,
+ timedOut, stdout, stderr, time);
} else if (testCase.configuration['compiler'] == 'dartc') {
- return new AnalysisCommandOutputImpl(testCase,
- command,
- exitCode,
- timedOut,
- stdout,
- stderr,
- time);
+ return new AnalysisTestOutputImpl(testCase, exitCode, timedOut,
+ stdout, stderr, time);
}
- return new CommandOutputImpl(testCase,
- command,
- exitCode,
- incomplete,
- timedOut,
- stdout,
- stderr,
- time);
+ return new TestOutputImpl(testCase, exitCode, incomplete, timedOut,
+ stdout, stderr, time);
}
String get result =>
@@ -410,24 +374,10 @@ class CommandOutputImpl implements CommandOutput {
}
-class BrowserCommandOutputImpl extends CommandOutputImpl {
- BrowserCommandOutputImpl(
- testCase,
- command,
- exitCode,
- incomplete,
- timedOut,
- stdout,
- stderr,
- time) :
- super(testCase,
- command,
- exitCode,
- incomplete,
- timedOut,
- stdout,
- stderr,
- time);
+class BrowserTestOutputImpl extends TestOutputImpl {
+ BrowserTestOutputImpl(testCase, exitCode, incomplete,
+ timedOut, stdout, stderr, time) :
+ super(testCase, exitCode, incomplete, timedOut, stdout, stderr, time);
bool get didFail {
// Browser case:
@@ -470,7 +420,7 @@ class BrowserCommandOutputImpl extends CommandOutputImpl {
// The static analyzer does not actually execute code, so
// the criteria for success now depend on the text sent
// to stderr.
-class AnalysisCommandOutputImpl extends CommandOutputImpl {
+class AnalysisTestOutputImpl extends TestOutputImpl {
// 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;
@@ -479,14 +429,8 @@ class AnalysisCommandOutputImpl extends CommandOutputImpl {
bool alreadyComputed = false;
bool failResult;
- AnalysisCommandOutputImpl(testCase,
- command,
- exitCode,
- timedOut,
- stdout,
- stderr,
- time) :
- super(testCase, command, exitCode, false, timedOut, stdout, stderr, time);
+ AnalysisTestOutputImpl(testCase, exitCode, timedOut, stdout, stderr, time) :
+ super(testCase, exitCode, false, timedOut, stdout, stderr, time);
bool get didFail {
if (!alreadyComputed) {
@@ -639,7 +583,7 @@ class AnalysisCommandOutputImpl extends CommandOutputImpl {
* A RunningProcess actually runs a test, getting the command lines from
* its [TestCase], starting the test process (and first, a compilation
* process if the TestCase is a [BrowserTestCase]), creating a timeout
- * timer, and recording the results in a new [CommandOutput] object, which it
+ * timer, and recording the results in a new [TestOutput] object, which it
* attaches to the TestCase. The lifetime of the RunningProcess is limited
* to the time it takes to start the process, run the process, and record
* the result; there are no pointers to it, so it should be available to
@@ -667,32 +611,25 @@ class RunningProcess {
* succeded, otherwise it will have the exit code of the first failing
* command.
*/
- void testComplete(Command lastCommand, int exitCode, bool incomplete) {
- var lastCommandOutput =
- new CommandOutput.fromCase(testCase,
- lastCommand,
- exitCode,
- incomplete,
- timedOut,
- stdout,
- stderr,
- new Date.now().difference(startTime));
+ void testComplete(int exitCode, bool incomplete) {
+ new TestOutput.fromCase(testCase, exitCode, incomplete, timedOut, stdout,
+ stderr, new Date.now().difference(startTime));
timeoutTimer.cancel();
- if (lastCommandOutput.unexpectedOutput
+ if (testCase.output.unexpectedOutput
&& testCase.configuration['verbose'] != null
&& testCase.configuration['verbose']) {
print(testCase.displayName);
- for (var line in lastCommandOutput.stderr) print(line);
- for (var line in lastCommandOutput.stdout) print(line);
+ for (var line in testCase.output.stderr) print(line);
+ for (var line in testCase.output.stdout) print(line);
}
if (allowRetries && testCase.usesWebDriver
- && lastCommandOutput.unexpectedOutput
+ && testCase.output.unexpectedOutput
&& (testCase as BrowserTestCase).numRetries > 0) {
// Selenium tests can be flaky. Try rerunning.
- lastCommandOutput.requestRetry = true;
+ testCase.output.requestRetry = true;
}
- if (lastCommandOutput.requestRetry) {
- lastCommandOutput.requestRetry = false;
+ if (testCase.output.requestRetry) {
+ testCase.output.requestRetry = false;
this.timedOut = false;
(testCase as BrowserTestCase).numRetries--;
print("Potential flake. Re-running ${testCase.displayName} "
@@ -711,7 +648,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 commandComplete(Command command, int exitCode) {
+ void stepExitHandler(int exitCode) {
process = null;
int totalSteps = testCase.commands.length;
String suffix =' (step $currentStep of $totalSteps)';
@@ -719,14 +656,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(command, 0, true);
+ testComplete(0, true);
} else if (currentStep == totalSteps) {
// Done with all test commands.
- testComplete(command, exitCode, false);
+ testComplete(exitCode, false);
} else if (exitCode != 0) {
// One of the steps failed.
stderr.add('test.dart: Compilation failed$suffix, exit code $exitCode\n');
- testComplete(command, exitCode, true);
+ testComplete(exitCode, true);
} else {
// One compilation step successfully completed, move on to the
// next step.
@@ -741,7 +678,7 @@ class RunningProcess {
timeoutTimer.cancel();
processQueue._getBatchRunner(testCase).startTest(testCase);
} else {
- runCommand(testCase.commands[currentStep++], commandComplete);
+ runCommand(testCase.commands[currentStep++], stepExitHandler);
}
}
}
@@ -765,18 +702,14 @@ class RunningProcess {
stderr = new List<String>();
currentStep = 0;
startTime = new Date.now();
- runCommand(testCase.commands[currentStep++], commandComplete);
+ runCommand(testCase.commands[currentStep++], stepExitHandler);
}
- void runCommand(Command command, void commandCompleteHandler(Command, int)) {
- void processExitHandler(int returnCode) {
- commandCompleteHandler(command, returnCode);
- }
-
+ void runCommand(Command command, void exitHandler(int exitCode)) {
Future processFuture = Process.start(command.executable, command.arguments);
processFuture.then((Process p) {
process = p;
- process.onExit = processExitHandler;
+ process.onExit = exitHandler;
var stdoutStringStream = new StringInputStream(process.stdout);
var stderrStringStream = new StringInputStream(process.stderr);
stdoutStringStream.onLine =
@@ -795,7 +728,7 @@ class RunningProcess {
print("Process error:");
print(" Command: $command");
print(" Error: $e");
- testComplete(command, -1, false);
+ testComplete(-1, false);
return true;
});
}
@@ -826,7 +759,6 @@ class MutableValue<T> {
}
class BatchRunnerProcess {
- Command _command;
String _executable;
List<String> _batchArguments;
@@ -847,7 +779,6 @@ class BatchRunnerProcess {
bool _isWebDriver;
BatchRunnerProcess(TestCase testCase) {
- _command = testCase.commands.last;
_executable = testCase.commands.last.executable;
_batchArguments = testCase.batchRunnerArguments;
_isWebDriver = testCase.usesWebDriver;
@@ -858,7 +789,6 @@ 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;
@@ -939,14 +869,10 @@ class BatchRunnerProcess {
var exitCode = 0;
if (outcome == "CRASH") exitCode = -10;
if (outcome == "FAIL" || outcome == "TIMEOUT") exitCode = 1;
- new CommandOutput.fromCase(_currentTest,
- _command,
- exitCode,
- false,
- (outcome == "TIMEOUT"),
- _testStdout,
- _testStderr,
- new Date.now().difference(_startTime));
+ new TestOutput.fromCase(_currentTest, 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