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

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

Issue 1859973002: Autoformat tools/testing/dart (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Format whole directory Created 4 years, 8 months 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 ac387a5b485d125734e1438b592ae31abf4b5469..0d641366b737a25db8168df207f5e5105243306f 100644
--- a/tools/testing/dart/test_runner.dart
+++ b/tools/testing/dart/test_runner.dart
@@ -39,10 +39,14 @@ typedef void EnqueueMoreWork(ProcessQueue queue);
// Some IO tests use these variables and get confused if the host environment
// variables are inherited so they are excluded.
-const List<String> EXCLUDED_ENVIRONMENT_VARIABLES =
- const ['http_proxy', 'https_proxy', 'no_proxy',
- 'HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY'];
-
+const List<String> EXCLUDED_ENVIRONMENT_VARIABLES = const [
+ 'http_proxy',
+ 'https_proxy',
+ 'no_proxy',
+ 'HTTP_PROXY',
+ 'HTTPS_PROXY',
+ 'NO_PROXY'
+];
/** A command executed as a step in a test case. */
class Command {
@@ -70,7 +74,8 @@ class Command {
return _cachedHashCode;
}
- operator ==(other) => identical(this, other) ||
+ operator ==(other) =>
+ identical(this, other) ||
(runtimeType == other.runtimeType && _equal(other));
void _buildHashCode(HashCodeBuilder builder) {
@@ -78,8 +83,7 @@ class Command {
}
bool _equal(Command other) =>
- hashCode == other.hashCode &&
- displayName == other.displayName;
+ hashCode == other.hashCode && displayName == other.displayName;
String toString() => reproductionCommand;
@@ -99,10 +103,8 @@ class ProcessCommand extends Command {
/** Working directory for the command */
final String workingDirectory;
- ProcessCommand._(String displayName, this.executable,
- this.arguments,
- [this.environmentOverrides = null,
- this.workingDirectory = null])
+ ProcessCommand._(String displayName, this.executable, this.arguments,
+ [this.environmentOverrides = null, this.workingDirectory = null])
: super._(displayName) {
if (io.Platform.operatingSystem == 'windows') {
// Windows can't handle the first command if it is a .bat file or the like
@@ -130,11 +132,12 @@ class ProcessCommand extends Command {
String get reproductionCommand {
var env = new StringBuffer();
environmentOverrides.forEach((key, value) =>
- (io.Platform.operatingSystem == 'windows') ?
- env.write('set $key=${escapeCommandLineArgument(value)} & ') :
- env.write('$key=${escapeCommandLineArgument(value)} '));
+ (io.Platform.operatingSystem == 'windows')
+ ? env.write('set $key=${escapeCommandLineArgument(value)} & ')
+ : env.write('$key=${escapeCommandLineArgument(value)} '));
var command = ([executable]..addAll(arguments))
- .map(escapeCommandLineArgument).join(' ');
+ .map(escapeCommandLineArgument)
+ .join(' ');
if (workingDirectory != null) {
command = "$command (working directory: $workingDirectory)";
}
@@ -149,13 +152,14 @@ class CompilationCommand extends ProcessCommand {
final bool _neverSkipCompilation;
final List<Uri> _bootstrapDependencies;
- CompilationCommand._(String displayName,
- this._outputFile,
- this._neverSkipCompilation,
- this._bootstrapDependencies,
- String executable,
- List<String> arguments,
- Map<String, String> environmentOverrides)
+ CompilationCommand._(
+ String displayName,
+ this._outputFile,
+ this._neverSkipCompilation,
+ this._bootstrapDependencies,
+ String executable,
+ List<String> arguments,
+ Map<String, String> environmentOverrides)
: super._(displayName, executable, arguments, environmentOverrides);
Future<bool> get outputIsUpToDate {
@@ -181,8 +185,8 @@ class CompilationCommand extends ProcessCommand {
return readDepsFile("$_outputFile.deps").then((dependencies) {
if (dependencies != null) {
dependencies.addAll(_bootstrapDependencies);
- var jsOutputLastModified = TestUtils.lastModifiedCache.getLastModified(
- new Uri(scheme: 'file', path: _outputFile));
+ var jsOutputLastModified = TestUtils.lastModifiedCache
+ .getLastModified(new Uri(scheme: 'file', path: _outputFile));
if (jsOutputLastModified != null) {
for (var dependency in dependencies) {
var dependencyLastModified =
@@ -220,37 +224,36 @@ class AddFlagsKey {
AddFlagsKey(this.flags, this.env);
// Just use object identity for environment map
bool operator ==(other) =>
- other is AddFlagsKey && flags == other.flags && env == other.env;
+ other is AddFlagsKey && flags == other.flags && env == other.env;
int get hashCode => flags.hashCode ^ env.hashCode;
}
class ContentShellCommand extends ProcessCommand {
- ContentShellCommand._(String executable,
- String htmlFile,
- List<String> options,
- List<String> dartFlags,
- Map<String, String> environmentOverrides)
- : super._("content_shell",
- executable,
- _getArguments(options, htmlFile),
- _getEnvironment(environmentOverrides, dartFlags));
+ ContentShellCommand._(
+ String executable,
+ String htmlFile,
+ List<String> options,
+ List<String> dartFlags,
+ Map<String, String> environmentOverrides)
+ : super._("content_shell", executable, _getArguments(options, htmlFile),
+ _getEnvironment(environmentOverrides, dartFlags));
// Cache the modified environments in a map from the old environment and
// the string of Dart flags to the new environment. Avoid creating new
// environment object for each command object.
- static Map<AddFlagsKey, Map> environments =
- new Map<AddFlagsKey, Map>();
+ static Map<AddFlagsKey, Map> environments = new Map<AddFlagsKey, Map>();
static Map _getEnvironment(Map env, List<String> dartFlags) {
var needDartFlags = dartFlags != null && dartFlags.length > 0;
if (needDartFlags) {
if (env == null) {
- env = const { };
+ env = const {};
}
var flags = dartFlags.join(' ');
- return environments.putIfAbsent(new AddFlagsKey(flags, env),
+ return environments.putIfAbsent(
+ new AddFlagsKey(flags, env),
() => new Map.from(env)
- ..addAll({'DART_FLAGS': flags, 'DART_FORWARDING_PRINT': '1'}));
+ ..addAll({'DART_FLAGS': flags, 'DART_FORWARDING_PRINT': '1'}));
}
return env;
}
@@ -270,11 +273,10 @@ class BrowserTestCommand extends Command {
final Map configuration;
final bool retry;
- BrowserTestCommand._(String _browser,
- this.url,
- this.configuration,
- this.retry)
- : super._(_browser), browser = _browser;
+ BrowserTestCommand._(
+ String _browser, this.url, this.configuration, this.retry)
+ : super._(_browser),
+ browser = _browser;
void _buildHashCode(HashCodeBuilder builder) {
super._buildHashCode(builder);
@@ -292,10 +294,12 @@ class BrowserTestCommand extends Command {
retry == other.retry;
String get reproductionCommand {
- var parts = [io.Platform.resolvedExecutable,
- 'tools/testing/dart/launch_browser.dart',
- browser,
- url];
+ var parts = [
+ io.Platform.resolvedExecutable,
+ 'tools/testing/dart/launch_browser.dart',
+ browser,
+ url
+ ];
return parts.map(escapeCommandLineArgument).join(' ');
}
@@ -304,11 +308,8 @@ class BrowserTestCommand extends Command {
class BrowserHtmlTestCommand extends BrowserTestCommand {
List<String> expectedMessages;
- BrowserHtmlTestCommand._(String browser,
- String url,
- Map configuration,
- this.expectedMessages,
- bool retry)
+ BrowserHtmlTestCommand._(String browser, String url, Map configuration,
+ this.expectedMessages, bool retry)
: super._(browser, url, configuration, retry);
void _buildHashCode(HashCodeBuilder builder) {
@@ -324,11 +325,8 @@ class BrowserHtmlTestCommand extends BrowserTestCommand {
class AnalysisCommand extends ProcessCommand {
final String flavor;
- AnalysisCommand._(this.flavor,
- String displayName,
- String executable,
- List<String> arguments,
- Map<String, String> environmentOverrides)
+ AnalysisCommand._(this.flavor, String displayName, String executable,
+ List<String> arguments, Map<String, String> environmentOverrides)
: super._(displayName, executable, arguments, environmentOverrides);
void _buildHashCode(HashCodeBuilder builder) {
@@ -337,40 +335,34 @@ class AnalysisCommand extends ProcessCommand {
}
bool _equal(AnalysisCommand other) =>
- super._equal(other) &&
- flavor == other.flavor;
+ super._equal(other) && flavor == other.flavor;
}
class VmCommand extends ProcessCommand {
- VmCommand._(String executable,
- List<String> arguments,
- Map<String,String> environmentOverrides)
+ VmCommand._(String executable, List<String> arguments,
+ Map<String, String> environmentOverrides)
: super._("vm", executable, arguments, environmentOverrides);
}
class JSCommandlineCommand extends ProcessCommand {
- JSCommandlineCommand._(String displayName,
- String executable,
- List<String> arguments,
- [Map<String, String> environmentOverrides = null])
- : super._(displayName,
- executable,
- arguments,
- environmentOverrides);
+ JSCommandlineCommand._(
+ String displayName, String executable, List<String> arguments,
+ [Map<String, String> environmentOverrides = null])
+ : super._(displayName, executable, arguments, environmentOverrides);
}
class PubCommand extends ProcessCommand {
final String command;
- PubCommand._(String pubCommand,
- String pubExecutable,
- String pubspecYamlDirectory,
- String pubCacheDirectory)
- : super._('pub_$pubCommand',
- new io.File(pubExecutable).absolute.path,
- [pubCommand],
- {'PUB_CACHE' : pubCacheDirectory},
- pubspecYamlDirectory), command = pubCommand;
+ PubCommand._(String pubCommand, String pubExecutable,
+ String pubspecYamlDirectory, String pubCacheDirectory)
+ : super._(
+ 'pub_$pubCommand',
+ new io.File(pubExecutable).absolute.path,
+ [pubCommand],
+ {'PUB_CACHE': pubCacheDirectory},
+ pubspecYamlDirectory),
+ command = pubCommand;
void _buildHashCode(HashCodeBuilder builder) {
super._buildHashCode(builder);
@@ -378,8 +370,7 @@ class PubCommand extends ProcessCommand {
}
bool _equal(PubCommand other) =>
- super._equal(other) &&
- command == other.command;
+ super._equal(other) && command == other.command;
}
/* [ScriptCommand]s are executed by dart code. */
@@ -394,7 +385,7 @@ class CleanDirectoryCopyCommand extends ScriptCommand {
final String _destinationDirectory;
CleanDirectoryCopyCommand._(this._sourceDirectory, this._destinationDirectory)
- : super._('dir_copy');
+ : super._('dir_copy');
String get reproductionCommand =>
"Copying '$_sourceDirectory' to '$_destinationDirectory'.";
@@ -440,10 +431,9 @@ class ModifyPubspecYamlCommand extends ScriptCommand {
String _destinationFile;
Map<String, Map> _dependencyOverrides;
- ModifyPubspecYamlCommand._(this._pubspecYamlFile,
- this._destinationFile,
- this._dependencyOverrides)
- : super._("modify_pubspec") {
+ ModifyPubspecYamlCommand._(
+ this._pubspecYamlFile, this._destinationFile, this._dependencyOverrides)
+ : super._("modify_pubspec") {
assert(_pubspecYamlFile.endsWith("pubspec.yaml"));
assert(_destinationFile.endsWith("pubspec.yaml"));
}
@@ -455,9 +445,9 @@ class ModifyPubspecYamlCommand extends ScriptCommand {
Future<ScriptCommandOutputImpl> run() {
var watch = new Stopwatch()..start();
- var pubspecLockFile =
- _destinationFile.substring(0, _destinationFile.length - ".yaml".length)
- + ".lock";
+ var pubspecLockFile = _destinationFile.substring(
+ 0, _destinationFile.length - ".yaml".length) +
+ ".lock";
var file = new io.File(_pubspecYamlFile);
var destinationFile = new io.File(_destinationFile);
@@ -465,15 +455,14 @@ class ModifyPubspecYamlCommand extends ScriptCommand {
return file.readAsString().then((String yamlString) {
var dependencyOverrideSection = new StringBuffer();
if (_dependencyOverrides.isNotEmpty) {
- dependencyOverrideSection.write(
- "\n"
+ dependencyOverrideSection.write("\n"
"# This section was autogenerated by test.py!\n"
"dependency_overrides:\n");
_dependencyOverrides.forEach((String packageName, Map override) {
dependencyOverrideSection.write(" $packageName:\n");
override.forEach((overrideKey, overrideValue) {
- dependencyOverrideSection.write(
- " $overrideKey: $overrideValue\n");
+ dependencyOverrideSection
+ .write(" $overrideKey: $overrideValue\n");
});
});
}
@@ -529,9 +518,9 @@ class MakeSymlinkCommand extends ScriptCommand {
}
var link = new io.Link(_link);
- return link.exists()
- .then((bool exists) { if (exists) return link.delete(); })
- .then((_) => link.create(_target));
+ return link.exists().then((bool exists) {
+ if (exists) return link.delete();
+ }).then((_) => link.create(_target));
}).then((_) {
return new ScriptCommandOutputImpl(
this, Expectation.PASS, "", watch.elapsed);
@@ -548,9 +537,7 @@ class MakeSymlinkCommand extends ScriptCommand {
}
bool _equal(MakeSymlinkCommand other) =>
- super._equal(other) &&
- _link == other._link &&
- _target == other._target;
+ super._equal(other) && _link == other._link && _target == other._target;
}
class CommandBuilder {
@@ -566,45 +553,46 @@ class CommandBuilder {
_cleared = true;
}
- ContentShellCommand getContentShellCommand(String executable,
- String htmlFile,
- List<String> options,
- List<String> dartFlags,
- Map<String, String> environment) {
+ ContentShellCommand getContentShellCommand(
+ String executable,
+ String htmlFile,
+ List<String> options,
+ List<String> dartFlags,
+ Map<String, String> environment) {
ContentShellCommand command = new ContentShellCommand._(
executable, htmlFile, options, dartFlags, environment);
return _getUniqueCommand(command);
}
- BrowserTestCommand getBrowserTestCommand(String browser,
- String url,
- Map configuration,
- bool retry) {
+ BrowserTestCommand getBrowserTestCommand(
+ String browser, String url, Map configuration, bool retry) {
var command = new BrowserTestCommand._(browser, url, configuration, retry);
return _getUniqueCommand(command);
}
- BrowserHtmlTestCommand getBrowserHtmlTestCommand(String browser,
- String url,
- Map configuration,
- List<String> expectedMessages,
- bool retry) {
+ BrowserHtmlTestCommand getBrowserHtmlTestCommand(String browser, String url,
+ Map configuration, List<String> expectedMessages, bool retry) {
var command = new BrowserHtmlTestCommand._(
browser, url, configuration, expectedMessages, retry);
return _getUniqueCommand(command);
}
- CompilationCommand getCompilationCommand(String displayName,
- outputFile,
- neverSkipCompilation,
- List<Uri> bootstrapDependencies,
- String executable,
- List<String> arguments,
- Map<String, String> environment) {
- var command =
- new CompilationCommand._(
- displayName, outputFile, neverSkipCompilation,
- bootstrapDependencies, executable, arguments, environment);
+ CompilationCommand getCompilationCommand(
+ String displayName,
+ outputFile,
+ neverSkipCompilation,
+ List<Uri> bootstrapDependencies,
+ String executable,
+ List<String> arguments,
+ Map<String, String> environment) {
+ var command = new CompilationCommand._(
+ displayName,
+ outputFile,
+ neverSkipCompilation,
+ bootstrapDependencies,
+ executable,
+ arguments,
+ environment);
return _getUniqueCommand(command);
}
@@ -616,41 +604,36 @@ class CommandBuilder {
return _getUniqueCommand(command);
}
- VmCommand getVmCommand(String executable,
- List<String> arguments,
- Map<String, String> environmentOverrides) {
+ VmCommand getVmCommand(String executable, List<String> arguments,
+ Map<String, String> environmentOverrides) {
var command = new VmCommand._(executable, arguments, environmentOverrides);
return _getUniqueCommand(command);
}
Command getJSCommandlineCommand(String displayName, executable, arguments,
- [environment = null]) {
- var command = new JSCommandlineCommand._(displayName, executable, arguments,
- environment);
+ [environment = null]) {
+ var command = new JSCommandlineCommand._(
+ displayName, executable, arguments, environment);
return _getUniqueCommand(command);
}
Command getProcessCommand(String displayName, executable, arguments,
- [environment = null, workingDirectory = null]) {
- var command = new ProcessCommand._(displayName, executable, arguments,
- environment, workingDirectory);
+ [environment = null, workingDirectory = null]) {
+ var command = new ProcessCommand._(
+ displayName, executable, arguments, environment, workingDirectory);
return _getUniqueCommand(command);
}
Command getCopyCommand(String sourceDirectory, String destinationDirectory) {
- var command = new CleanDirectoryCopyCommand._(sourceDirectory,
- destinationDirectory);
+ var command =
+ new CleanDirectoryCopyCommand._(sourceDirectory, destinationDirectory);
return _getUniqueCommand(command);
}
- Command getPubCommand(String pubCommand,
- String pubExecutable,
- String pubspecYamlDirectory,
- String pubCacheDirectory) {
- var command = new PubCommand._(pubCommand,
- pubExecutable,
- pubspecYamlDirectory,
- pubCacheDirectory);
+ Command getPubCommand(String pubCommand, String pubExecutable,
+ String pubspecYamlDirectory, String pubCacheDirectory) {
+ var command = new PubCommand._(
+ pubCommand, pubExecutable, pubspecYamlDirectory, pubCacheDirectory);
return _getUniqueCommand(command);
}
@@ -659,7 +642,7 @@ class CommandBuilder {
}
Command getModifyPubspecCommand(String pubspecYamlFile, Map depsOverrides,
- {String destinationFile: null}) {
+ {String destinationFile: null}) {
if (destinationFile == null) destinationFile = pubspecYamlFile;
return _getUniqueCommand(new ModifyPubspecYamlCommand._(
pubspecYamlFile, destinationFile, depsOverrides));
@@ -716,7 +699,8 @@ class TestCase extends UniqueObject {
* compiling multiple sources that are run in isolation.
*/
List<Command> commands;
- Map<Command, CommandOutput> commandOutputs = new Map<Command,CommandOutput>();
+ Map<Command, CommandOutput> commandOutputs =
+ new Map<Command, CommandOutput>();
Map configuration;
String displayName;
@@ -724,19 +708,16 @@ class TestCase extends UniqueObject {
int hash = 0;
Set<Expectation> expectedOutcomes;
- TestCase(this.displayName,
- this.commands,
- this.configuration,
- this.expectedOutcomes,
- {isNegative: false,
- TestInformation info: null}) {
+ TestCase(this.displayName, this.commands, this.configuration,
+ this.expectedOutcomes,
+ {isNegative: false, TestInformation info: null}) {
if (isNegative || displayName.contains("negative_test")) {
_expectations |= IS_NEGATIVE;
}
if (info != null) {
_setExpectations(info);
- hash = info.originTestPath.relativeTo(TestUtils.dartDir)
- .toString().hashCode;
+ hash =
+ info.originTestPath.relativeTo(TestUtils.dartDir).toString().hashCode;
}
}
@@ -777,8 +758,8 @@ class TestCase extends UniqueObject {
CommandOutput get lastCommandOutput {
if (commandOutputs.length == 0) {
throw new Exception("CommandOutputs is empty, maybe no command was run? ("
- "displayName: '$displayName', "
- "configurationString: '$configurationString')");
+ "displayName: '$displayName', "
+ "configurationString: '$configurationString')");
}
return commandOutputs[commands[commandOutputs.length - 1]];
}
@@ -786,8 +767,8 @@ class TestCase extends UniqueObject {
Command get lastCommandExecuted {
if (commandOutputs.length == 0) {
throw new Exception("CommandOutputs is empty, maybe no command was run? ("
- "displayName: '$displayName', "
- "configurationString: '$configurationString')");
+ "displayName: '$displayName', "
+ "configurationString: '$configurationString')");
}
return commands[commandOutputs.length - 1];
}
@@ -815,34 +796,34 @@ class TestCase extends UniqueObject {
}
bool get isFlaky {
- if (expectedOutcomes.contains(Expectation.SKIP) ||
- expectedOutcomes.contains(Expectation.SKIP_BY_DESIGN)) {
- return false;
- }
+ if (expectedOutcomes.contains(Expectation.SKIP) ||
+ expectedOutcomes.contains(Expectation.SKIP_BY_DESIGN)) {
+ return false;
+ }
- return expectedOutcomes
- .where((expectation) => !expectation.isMetaExpectation).length > 1;
+ return expectedOutcomes
+ .where((expectation) => !expectation.isMetaExpectation)
+ .length >
+ 1;
}
bool get isFinished {
return commandOutputs.length > 0 &&
(!lastCommandOutput.successful ||
- commands.length == commandOutputs.length);
+ commands.length == commandOutputs.length);
}
}
-
/**
* BrowserTestCase has an extra compilation command that is run in a separate
* process, before the regular test is run as in the base class [TestCase].
* If the compilation command fails, then the rest of the test is not run.
*/
class BrowserTestCase extends TestCase {
-
- BrowserTestCase(displayName, commands, configuration,
- expectedOutcomes, info, isNegative, this._testingUrl)
- : super(displayName, commands, configuration,
- expectedOutcomes, isNegative: isNegative, info: info);
+ BrowserTestCase(displayName, commands, configuration, expectedOutcomes, info,
+ isNegative, this._testingUrl)
+ : super(displayName, commands, configuration, expectedOutcomes,
+ isNegative: isNegative, info: info);
String _testingUrl;
@@ -858,14 +839,13 @@ class UnittestSuiteMessagesMixin {
return testOutput.contains("unittest-suite-success");
}
- Expectation _negateOutcomeIfIncompleteAsyncTest(Expectation outcome,
- String testOutput) {
+ Expectation _negateOutcomeIfIncompleteAsyncTest(
+ Expectation outcome, String testOutput) {
// If this is an asynchronous test and the asynchronous operation didn't
// complete successfully, it's outcome is Expectation.FAIL.
// TODO: maybe we should introduce a AsyncIncomplete marker or so
if (outcome == Expectation.PASS) {
- if (_isAsyncTest(testOutput) &&
- !_isAsyncTestSuccessful(testOutput)) {
+ if (_isAsyncTest(testOutput) && !_isAsyncTestSuccessful(testOutput)) {
return Expectation.FAIL;
}
}
@@ -930,14 +910,15 @@ class CommandOutputImpl extends UniqueObject implements CommandOutput {
bool alreadyPrintedWarning = false;
// TODO(kustermann): Remove testCase from this class.
- CommandOutputImpl(Command this.command,
- int this.exitCode,
- bool this.timedOut,
- List<int> this.stdout,
- List<int> this.stderr,
- Duration this.time,
- bool this.compilationSkipped,
- int this.pid) {
+ CommandOutputImpl(
+ Command this.command,
+ int this.exitCode,
+ bool this.timedOut,
+ List<int> this.stdout,
+ List<int> this.stderr,
+ Duration this.time,
+ bool this.compilationSkipped,
+ int this.pid) {
diagnostics = [];
}
@@ -991,8 +972,8 @@ class CommandOutputImpl extends UniqueObject implements CommandOutput {
return testCase.isNegative ? !didFail(testCase) : didFail(testCase);
}
- Expectation _negateOutcomeIfNegativeTest(Expectation outcome,
- bool isNegative) {
+ Expectation _negateOutcomeIfNegativeTest(
+ Expectation outcome, bool isNegative) {
if (!isNegative) return outcome;
if (outcome.canBeOutcomeOf(Expectation.FAIL)) {
@@ -1012,21 +993,9 @@ class BrowserCommandOutputImpl extends CommandOutputImpl {
bool _failedBecauseOfMissingXDisplay;
BrowserCommandOutputImpl(
- command,
- exitCode,
- timedOut,
- stdout,
- stderr,
- time,
- compilationSkipped) :
- super(command,
- exitCode,
- timedOut,
- stdout,
- stderr,
- time,
- compilationSkipped,
- 0) {
+ command, exitCode, timedOut, stdout, stderr, time, compilationSkipped)
+ : super(command, exitCode, timedOut, stdout, stderr, time,
+ compilationSkipped, 0) {
_failedBecauseOfMissingXDisplay = _didFailBecauseOfMissingXDisplay();
if (_failedBecauseOfMissingXDisplay) {
DebugLogger.warning("Warning: Test failure because of missing XDisplay");
@@ -1128,7 +1097,7 @@ class BrowserCommandOutputImpl extends CommandOutputImpl {
}
if (!containsFail && !containsPass) {
DebugLogger.warning("Test had neither 'FAIL' nor 'PASS' in stdout. "
- "($command)");
+ "($command)");
return true;
}
if (containsFail) {
@@ -1137,43 +1106,31 @@ class BrowserCommandOutputImpl extends CommandOutputImpl {
assert(containsPass);
if (exitCode != 0) {
var message = "All tests passed, but exitCode != 0. "
- "Actual exitcode: $exitCode. "
- "($command)";
+ "Actual exitcode: $exitCode. "
+ "($command)";
DebugLogger.warning(message);
diagnostics.add(message);
}
return (!hasCrashed &&
- exitCode != 0 &&
- (!isWindows || exitCode != WHITELISTED_CONTENTSHELL_EXITCODE));
+ exitCode != 0 &&
+ (!isWindows || exitCode != WHITELISTED_CONTENTSHELL_EXITCODE));
}
DebugLogger.warning("Couldn't find 'Content-Type: text/plain' in output. "
- "($command).");
+ "($command).");
return true;
}
}
class HTMLBrowserCommandOutputImpl extends BrowserCommandOutputImpl {
- HTMLBrowserCommandOutputImpl(
- command,
- exitCode,
- timedOut,
- stdout,
- stderr,
- time,
- compilationSkipped) :
- super(command,
- exitCode,
- timedOut,
- stdout,
- stderr,
- time,
- compilationSkipped);
+ HTMLBrowserCommandOutputImpl(
+ command, exitCode, timedOut, stdout, stderr, time, compilationSkipped)
+ : super(command, exitCode, timedOut, stdout, stderr, time,
+ compilationSkipped);
bool didFail(TestCase testCase) {
return _getOutcome() != Expectation.PASS;
}
-
bool get _browserTestFailure {
// We should not need to convert back and forward.
var output = decodeUtf8(super.stdout);
@@ -1183,10 +1140,16 @@ class HTMLBrowserCommandOutputImpl extends BrowserCommandOutputImpl {
}
class BrowserTestJsonResult {
- static const ALLOWED_TYPES =
- const ['sync_exception', 'window_onerror', 'script_onerror',
- 'window_compilationerror', 'print', 'message_received', 'dom',
- 'debug'];
+ static const ALLOWED_TYPES = const [
+ 'sync_exception',
+ 'window_onerror',
+ 'script_onerror',
+ 'window_compilationerror',
+ 'print',
+ 'message_received',
+ 'dom',
+ 'debug'
+ ];
final Expectation outcome;
final String htmlDom;
@@ -1198,7 +1161,7 @@ class BrowserTestJsonResult {
void validate(String assertion, bool value) {
if (!value) {
throw "InvalidFormat sent from browser driving page: $assertion:\n\n"
- "$content";
+ "$content";
}
}
@@ -1218,12 +1181,11 @@ class BrowserTestJsonResult {
var value = entry['value'];
var timestamp = entry['timestamp'];
- validate("'type' of an entry must be a String",
- type is String);
+ validate("'type' of an entry must be a String", type is String);
validate("'type' has to be in $ALLOWED_TYPES.",
- ALLOWED_TYPES.contains(type));
- validate("'timestamp' of an entry must be a number",
- timestamp is num);
+ ALLOWED_TYPES.contains(type));
+ validate(
+ "'timestamp' of an entry must be a number", timestamp is num);
messagesByType[type].add(value);
}
@@ -1238,7 +1200,7 @@ class BrowserTestJsonResult {
return new BrowserTestJsonResult(
_getOutcome(messagesByType), dom, events);
}
- } catch(error) {
+ } catch (error) {
// If something goes wrong, we know the content was not in the correct
// JSON format. So we can't parse it.
// The caller is responsible for falling back to the old way of
@@ -1275,11 +1237,11 @@ class BrowserTestJsonResult {
// the unittest implementation posts these messages using
// "window.postMessage()" instead of the normal "print()" them.
- var isAsyncTest = searchForMsg(['print', 'message_received'],
- 'unittest-suite-wait-for-done');
+ var isAsyncTest = searchForMsg(
+ ['print', 'message_received'], 'unittest-suite-wait-for-done');
var isAsyncSuccess =
searchForMsg(['print', 'message_received'], 'unittest-suite-success') ||
- searchForMsg(['print', 'message_received'], 'unittest-suite-done');
+ searchForMsg(['print', 'message_received'], 'unittest-suite-done');
if (isAsyncTest) {
if (isAsyncSuccess) {
@@ -1301,22 +1263,23 @@ class BrowserTestJsonResult {
}
class BrowserControllerTestOutcome extends CommandOutputImpl
- with UnittestSuiteMessagesMixin {
+ with UnittestSuiteMessagesMixin {
BrowserTestOutput _result;
Expectation _rawOutcome;
- factory BrowserControllerTestOutcome(Command command,
- BrowserTestOutput result) {
+ factory BrowserControllerTestOutcome(
+ Command command, BrowserTestOutput result) {
void validate(String assertion, bool value) {
if (!value) {
throw "InvalidFormat sent from browser driving page: $assertion:\n\n"
- "${result.lastKnownMessage}";
+ "${result.lastKnownMessage}";
}
}
String indent(String string, int numSpaces) {
var spaces = new List.filled(numSpaces, ' ').join('');
- return string.replaceAll('\r\n', '\n')
+ return string
+ .replaceAll('\r\n', '\n')
.split('\n')
.map((line) => "$spaces$line")
.join('\n');
@@ -1344,13 +1307,13 @@ class BrowserControllerTestOutcome extends CommandOutputImpl
if (result.didTimeout) {
if (result.delayUntilTestStarted != null) {
stderr = "This test timed out. The delay until the test actually "
- "started was: ${result.delayUntilTestStarted}.";
+ "started was: ${result.delayUntilTestStarted}.";
} else {
// TODO(ricow/kustermann) as soon as we record the state periodically,
// we will have more information and can remove this warning.
stderr = "This test has not notified test.py that it started running. "
- "This could be a bug in test.py! "
- "Please contact ricow/whesse";
+ "This could be a bug in test.py! "
+ "Please contact ricow/whesse";
}
}
@@ -1360,8 +1323,7 @@ class BrowserControllerTestOutcome extends CommandOutputImpl
stdout = "message:\n${indent(result.lastKnownMessage, 2)}\n\n";
}
- stderr =
- '$stderr\n\n'
+ stderr = '$stderr\n\n'
'BrowserOutput while running the test (* EXPERIMENTAL *):\n'
'BrowserOutput.stdout:\n'
'${indent(result.browserOutput.stdout.toString(), 2)}\n'
@@ -1369,20 +1331,23 @@ class BrowserControllerTestOutcome extends CommandOutputImpl
'${indent(result.browserOutput.stderr.toString(), 2)}\n'
'\n';
return new BrowserControllerTestOutcome._internal(
- command, result, outcome, encodeUtf8(stdout), encodeUtf8(stderr));
+ command, result, outcome, encodeUtf8(stdout), encodeUtf8(stderr));
}
BrowserControllerTestOutcome._internal(
- Command command, BrowserTestOutput result, this._rawOutcome,
- List<int> stdout, List<int> stderr)
+ Command command,
+ BrowserTestOutput result,
+ this._rawOutcome,
+ List<int> stdout,
+ List<int> stderr)
: super(command, 0, result.didTimeout, stdout, stderr, result.duration,
- false, 0) {
+ false, 0) {
_result = result;
}
Expectation result(TestCase testCase) {
// Handle timeouts first
- if (_result.didTimeout) return Expectation.TIMEOUT;
+ if (_result.didTimeout) return Expectation.TIMEOUT;
// Multitests are handled specially
if (testCase.hasRuntimeError) {
@@ -1394,7 +1359,6 @@ class BrowserControllerTestOutcome extends CommandOutputImpl
}
}
-
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.
@@ -1403,21 +1367,10 @@ class AnalysisCommandOutputImpl extends CommandOutputImpl {
final int FILENAME = 3;
final int FORMATTED_ERROR = 7;
- AnalysisCommandOutputImpl(command,
- exitCode,
- timedOut,
- stdout,
- stderr,
- time,
- compilationSkipped) :
- super(command,
- exitCode,
- timedOut,
- stdout,
- stderr,
- time,
- compilationSkipped,
- 0);
+ AnalysisCommandOutputImpl(
+ command, exitCode, timedOut, stdout, stderr, time, compilationSkipped)
+ : super(command, exitCode, timedOut, stdout, stderr, time,
+ compilationSkipped, 0);
Expectation result(TestCase testCase) {
// TODO(kustermann): If we run the analyzer not in batch mode, make sure
@@ -1455,9 +1408,8 @@ class AnalysisCommandOutputImpl extends CommandOutputImpl {
return Expectation.STATIC_WARNING;
}
- assert (errors.length == 0 && warnings.length == 0);
- assert (!testCase.hasCompileError &&
- !testCase.hasStaticWarning);
+ assert(errors.length == 0 && warnings.length == 0);
+ assert(!testCase.hasCompileError && !testCase.hasStaticWarning);
return Expectation.PASS;
}
@@ -1468,7 +1420,7 @@ class AnalysisCommandOutputImpl extends CommandOutputImpl {
StringBuffer field = new StringBuffer();
List<String> result = [];
bool escaped = false;
- for (var i = 0 ; i < line.length; i++) {
+ for (var i = 0; i < line.length; i++) {
var c = line[i];
if (!escaped && c == '\\') {
escaped = true;
@@ -1503,13 +1455,12 @@ class AnalysisCommandOutputImpl extends CommandOutputImpl {
}
class VmCommandOutputImpl extends CommandOutputImpl
- with UnittestSuiteMessagesMixin {
+ with UnittestSuiteMessagesMixin {
static const DART_VM_EXITCODE_COMPILE_TIME_ERROR = 254;
static const DART_VM_EXITCODE_UNCAUGHT_EXCEPTION = 255;
VmCommandOutputImpl(Command command, int exitCode, bool timedOut,
- List<int> stdout, List<int> stderr, Duration time,
- int pid)
+ List<int> stdout, List<int> stderr, Duration time, int pid)
: super(command, exitCode, timedOut, stdout, stderr, time, false, pid);
Expectation result(TestCase testCase) {
@@ -1553,11 +1504,16 @@ class VmCommandOutputImpl extends CommandOutputImpl
class CompilationCommandOutputImpl extends CommandOutputImpl {
static const DART2JS_EXITCODE_CRASH = 253;
- CompilationCommandOutputImpl(Command command, int exitCode, bool timedOut,
- List<int> stdout, List<int> stderr, Duration time,
+ CompilationCommandOutputImpl(
+ Command command,
+ int exitCode,
+ bool timedOut,
+ List<int> stdout,
+ List<int> stderr,
+ Duration time,
bool compilationSkipped)
: super(command, exitCode, timedOut, stdout, stderr, time,
- compilationSkipped, 0);
+ compilationSkipped, 0);
Expectation result(TestCase testCase) {
// Handle general crash/timeout detection.
@@ -1596,7 +1552,7 @@ class CompilationCommandOutputImpl extends CommandOutputImpl {
}
class JsCommandlineOutputImpl extends CommandOutputImpl
- with UnittestSuiteMessagesMixin {
+ with UnittestSuiteMessagesMixin {
JsCommandlineOutputImpl(Command command, int exitCode, bool timedOut,
List<int> stdout, List<int> stderr, Duration time)
: super(command, exitCode, timedOut, stdout, stderr, time, false, 0);
@@ -1620,7 +1576,7 @@ class JsCommandlineOutputImpl extends CommandOutputImpl
class PubCommandOutputImpl extends CommandOutputImpl {
PubCommandOutputImpl(PubCommand command, int exitCode, bool timedOut,
List<int> stdout, List<int> stderr, Duration time)
- : super(command, exitCode, timedOut, stdout, stderr, time, false, 0);
+ : super(command, exitCode, timedOut, stdout, stderr, time, false, 0);
Expectation result(TestCase testCase) {
// Handle crashes and timeouts first
@@ -1641,8 +1597,8 @@ class ScriptCommandOutputImpl extends CommandOutputImpl {
final Expectation _result;
ScriptCommandOutputImpl(ScriptCommand command, this._result,
- String scriptExecutionInformation, Duration time)
- : super(command, 0, false, [], [], time, false, 0) {
+ String scriptExecutionInformation, Duration time)
+ : super(command, 0, false, [], [], time, false, 0) {
var lines = scriptExecutionInformation.split("\n");
diagnostics.addAll(lines);
}
@@ -1652,29 +1608,20 @@ class ScriptCommandOutputImpl extends CommandOutputImpl {
bool get canRunDependendCommands => _result == Expectation.PASS;
bool get successful => _result == Expectation.PASS;
-
}
-CommandOutput createCommandOutput(Command command,
- int exitCode,
- bool timedOut,
- List<int> stdout,
- List<int> stderr,
- Duration time,
- bool compilationSkipped,
- [int pid = 0]) {
+CommandOutput createCommandOutput(Command command, int exitCode, bool timedOut,
+ List<int> stdout, List<int> stderr, Duration time, bool compilationSkipped,
+ [int pid = 0]) {
if (command is ContentShellCommand) {
return new BrowserCommandOutputImpl(
- command, exitCode, timedOut, stdout, stderr,
- time, compilationSkipped);
+ command, exitCode, timedOut, stdout, stderr, time, compilationSkipped);
} else if (command is BrowserTestCommand) {
return new HTMLBrowserCommandOutputImpl(
- command, exitCode, timedOut, stdout, stderr,
- time, compilationSkipped);
+ command, exitCode, timedOut, stdout, stderr, time, compilationSkipped);
} else if (command is AnalysisCommand) {
return new AnalysisCommandOutputImpl(
- command, exitCode, timedOut, stdout, stderr,
- time, compilationSkipped);
+ command, exitCode, timedOut, stdout, stderr, time, compilationSkipped);
} else if (command is VmCommand) {
return new VmCommandOutputImpl(
command, exitCode, timedOut, stdout, stderr, time, pid);
@@ -1694,12 +1641,10 @@ CommandOutput createCommandOutput(Command command,
command, exitCode, timedOut, stdout, stderr, time);
}
- return new CommandOutputImpl(
- command, exitCode, timedOut, stdout, stderr,
+ return new CommandOutputImpl(command, exitCode, timedOut, stdout, stderr,
time, compilationSkipped, pid);
}
-
/**
* An OutputLog records the output from a test, but truncates it if
* it is longer than MAX_HEAD characters, and just keeps the head and
@@ -1734,10 +1679,9 @@ class OutputLog {
}
}
- List<int> _truncatedTail() =>
- tail.length > TAIL_LENGTH ?
- tail.sublist(tail.length - TAIL_LENGTH) :
- tail;
+ List<int> _truncatedTail() => tail.length > TAIL_LENGTH
+ ? tail.sublist(tail.length - TAIL_LENGTH)
+ : tail;
List<int> toList() {
if (complete == null) {
@@ -1751,7 +1695,8 @@ Data removed due to excessive length
*****************************************************************************
-""".codeUnits);
+"""
+ .codeUnits);
complete.addAll(_truncatedTail());
} else if (tail != null) {
complete.addAll(tail);
@@ -1801,11 +1746,10 @@ class RunningProcess {
_commandComplete(0);
} else {
var processEnvironment = _createProcessEnvironment();
- Future processFuture =
- io.Process.start(command.executable,
- command.arguments,
- environment: processEnvironment,
- workingDirectory: command.workingDirectory);
+ Future processFuture = io.Process.start(
+ command.executable, command.arguments,
+ environment: processEnvironment,
+ workingDirectory: command.workingDirectory);
processFuture.then((io.Process process) {
StreamSubscription stdoutSubscription =
_drainStream(process.stdout, stdout);
@@ -1871,14 +1815,14 @@ class RunningProcess {
});
}
- Future.wait([stdoutCompleter.future,
- stderrCompleter.future]).then((_) {
+ Future.wait([stdoutCompleter.future, stderrCompleter.future]).then(
+ (_) {
_commandComplete(exitCode);
});
});
- timeoutTimer = new Timer(new Duration(seconds: timeout),
- timeoutHandler);
+ timeoutTimer =
+ new Timer(new Duration(seconds: timeout), timeoutHandler);
}).catchError((e) {
// TODO(floitsch): should we try to report the stacktrace?
print("Process error:");
@@ -1912,8 +1856,8 @@ class RunningProcess {
return commandOutput;
}
- StreamSubscription _drainStream(Stream<List<int>> source,
- OutputLog destination) {
+ StreamSubscription _drainStream(
+ Stream<List<int>> source, OutputLog destination) {
return source.listen(destination.add);
}
@@ -1957,7 +1901,7 @@ class BatchRunnerProcess {
BatchRunnerProcess();
Future<CommandOutput> runCommand(String runnerType, ProcessCommand command,
- int timeout, List<String> arguments) {
+ int timeout, List<String> arguments) {
assert(_completer == null);
assert(!_currentlyRunning);
@@ -2011,15 +1955,14 @@ class BatchRunnerProcess {
_status = null;
_stdoutCompleter = new Completer();
_stderrCompleter = new Completer();
- _timer = new Timer(new Duration(seconds: timeout),
- _timeoutHandler);
+ _timer = new Timer(new Duration(seconds: timeout), _timeoutHandler);
var line = _createArgumentsLine(_arguments, timeout);
_process.stdin.write(line);
_stdoutSubscription.resume();
_stderrSubscription.resume();
- Future.wait([_stdoutCompleter.future,
- _stderrCompleter.future]).then((_) => _reportResult());
+ Future.wait([_stdoutCompleter.future, _stderrCompleter.future]).then(
+ (_) => _reportResult());
}
String _createArgumentsLine(List<String> arguments, int timeout) {
@@ -2034,13 +1977,14 @@ class BatchRunnerProcess {
var exitCode = 0;
if (outcome == "CRASH") exitCode = CRASHING_BROWSER_EXITCODE;
if (outcome == "FAIL" || outcome == "TIMEOUT") exitCode = 1;
- var output = createCommandOutput(_command,
- exitCode,
- (outcome == "TIMEOUT"),
- _testStdout.toList(),
- _testStderr.toList(),
- new DateTime.now().difference(_startTime),
- false);
+ var output = createCommandOutput(
+ _command,
+ exitCode,
+ (outcome == "TIMEOUT"),
+ _testStdout.toList(),
+ _testStderr.toList(),
+ new DateTime.now().difference(_startTime),
+ false);
assert(_completer != null);
_completer.complete(output);
_completer = null;
@@ -2055,7 +1999,8 @@ class BatchRunnerProcess {
_stdoutSubscription.cancel();
_stderrSubscription.cancel();
_startProcess(_reportResult);
- } else { // No active test case running.
+ } else {
+ // No active test case running.
_process = null;
}
}
@@ -2077,16 +2022,13 @@ class BatchRunnerProcess {
environment[key] = _processEnvironmentOverrides[key];
}
}
- Future processFuture = io.Process.start(executable,
- arguments,
- environment: environment);
+ Future processFuture =
+ io.Process.start(executable, arguments, environment: environment);
processFuture.then((io.Process p) {
_process = p;
var _stdoutStream =
- _process.stdout
- .transform(UTF8.decoder)
- .transform(new LineSplitter());
+ _process.stdout.transform(UTF8.decoder).transform(new LineSplitter());
_stdoutSubscription = _stdoutStream.listen((String line) {
if (line.startsWith('>>> TEST')) {
_status = line;
@@ -2107,9 +2049,7 @@ class BatchRunnerProcess {
_stdoutSubscription.pause();
var _stderrStream =
- _process.stderr
- .transform(UTF8.decoder)
- .transform(new LineSplitter());
+ _process.stderr.transform(UTF8.decoder).transform(new LineSplitter());
_stderrSubscription = _stderrStream.listen((String line) {
if (line.startsWith('>>> EOF STDERR')) {
_stderrSubscription.pause();
@@ -2156,7 +2096,6 @@ class BatchRunnerProcess {
}
}
-
/**
* [TestCaseEnqueuer] takes a list of TestSuites, generates TestCases and
* builds a dependency graph of all commands in every TestSuite.
@@ -2223,7 +2162,6 @@ class TestCaseEnqueuer {
}
}
-
/*
* [CommandEnqueuer] will
* - change node.state to NodeState.Enqueuing as soon as all dependencies have
@@ -2232,11 +2170,15 @@ class TestCaseEnqueuer {
* have a state of NodeState.Failed/NodeState.UnableToRun.
*/
class CommandEnqueuer {
- static final INIT_STATES = [dgraph.NodeState.Initialized,
- dgraph.NodeState.Waiting];
- static final FINISHED_STATES = [dgraph.NodeState.Successful,
- dgraph.NodeState.Failed,
- dgraph.NodeState.UnableToRun];
+ static final INIT_STATES = [
+ dgraph.NodeState.Initialized,
+ dgraph.NodeState.Waiting
+ ];
+ static final FINISHED_STATES = [
+ dgraph.NodeState.Successful,
+ dgraph.NodeState.Failed,
+ dgraph.NodeState.UnableToRun
+ ];
final dgraph.Graph _graph;
CommandEnqueuer(this._graph) {
@@ -2248,9 +2190,9 @@ class CommandEnqueuer {
});
eventCondition((e) => e is dgraph.StateChangedEvent).listen((event) {
- if ([dgraph.NodeState.Waiting,
- dgraph.NodeState.Processing].contains(event.from)) {
- if (FINISHED_STATES.contains(event.to)){
+ if ([dgraph.NodeState.Waiting, dgraph.NodeState.Processing]
+ .contains(event.from)) {
+ if (FINISHED_STATES.contains(event.to)) {
for (var dependendNode in event.node.neededFor) {
_changeNodeStateIfNecessary(dependendNode);
}
@@ -2263,16 +2205,17 @@ class CommandEnqueuer {
// changed it's state.
void _changeNodeStateIfNecessary(dgraph.Node node) {
if (INIT_STATES.contains(node.state)) {
- bool anyDependenciesUnsuccessful = node.dependencies.any(
- (dep) => [dgraph.NodeState.Failed,
- dgraph.NodeState.UnableToRun].contains(dep.state));
+ bool anyDependenciesUnsuccessful = node.dependencies.any((dep) => [
+ dgraph.NodeState.Failed,
+ dgraph.NodeState.UnableToRun
+ ].contains(dep.state));
var newState = dgraph.NodeState.Waiting;
if (anyDependenciesUnsuccessful) {
newState = dgraph.NodeState.UnableToRun;
} else {
- bool allDependenciesSuccessful = node.dependencies.every(
- (dep) => dep.state == dgraph.NodeState.Successful);
+ bool allDependenciesSuccessful = node.dependencies
+ .every((dep) => dep.state == dgraph.NodeState.Successful);
if (allDependenciesSuccessful) {
newState = dgraph.NodeState.Enqueuing;
@@ -2304,8 +2247,8 @@ class CommandQueue {
final TestCaseEnqueuer enqueuer;
final Queue<Command> _runQueue = new Queue<Command>();
- final _commandOutputStream = new StreamController<CommandOutput>(sync: true);
- final _completer = new Completer();
+ final _commandOutputStream = new StreamController<CommandOutput>(sync: true);
+ final _completer = new Completer();
int _numProcesses = 0;
int _maxProcesses;
@@ -2314,23 +2257,23 @@ class CommandQueue {
bool _finishing = false;
bool _verbose = false;
- CommandQueue(this.graph, this.enqueuer, this.executor,
- this._maxProcesses, this._maxBrowserProcesses, this._verbose) {
+ CommandQueue(this.graph, this.enqueuer, this.executor, this._maxProcesses,
+ this._maxBrowserProcesses, this._verbose) {
var eventCondition = graph.events.where;
eventCondition((event) => event is dgraph.StateChangedEvent)
.listen((event) {
- if (event.to == dgraph.NodeState.Enqueuing) {
- assert(event.from == dgraph.NodeState.Initialized ||
- event.from == dgraph.NodeState.Waiting);
- graph.changeState(event.node, dgraph.NodeState.Processing);
- var command = event.node.userData;
- if (event.node.dependencies.length > 0) {
- _runQueue.addFirst(command);
- } else {
- _runQueue.add(command);
- }
- Timer.run(() => _tryRunNextCommand());
- }
+ if (event.to == dgraph.NodeState.Enqueuing) {
+ assert(event.from == dgraph.NodeState.Initialized ||
+ event.from == dgraph.NodeState.Waiting);
+ graph.changeState(event.node, dgraph.NodeState.Processing);
+ var command = event.node.userData;
+ if (event.node.dependencies.length > 0) {
+ _runQueue.addFirst(command);
+ } else {
+ _runQueue.add(command);
+ }
+ Timer.run(() => _tryRunNextCommand());
+ }
});
// We're finished if the graph is sealed and all nodes are in a finished
// state (Successful, Failed or UnableToRun).
@@ -2374,8 +2317,8 @@ class CommandQueue {
// If a command is part of many TestCases we set the timeout to be
// the maximum over all [TestCase.timeout]s. At some point, we might
// eliminate [TestCase.timeout] completely and move it to [Command].
- int timeout = testCases.map((TestCase test) => test.timeout)
- .fold(0, math.max);
+ int timeout =
+ testCases.map((TestCase test) => test.timeout).fold(0, math.max);
if (_verbose) {
print('Running "${command.displayName}" command: $command');
@@ -2422,7 +2365,7 @@ class CommandQueue {
print("CommandQueue state:");
print(" Processes: used: $_numProcesses max: $_maxProcesses");
print(" BrowserProcesses: used: $_numBrowserProcesses "
- "max: $_maxBrowserProcesses");
+ "max: $_maxBrowserProcesses");
print(" Finishing: $_finishing");
print(" Queue (length = ${_runQueue.length}):");
for (var command in _runQueue) {
@@ -2431,7 +2374,6 @@ class CommandQueue {
}
}
-
/*
* [CommandExecutor] is responsible for executing commands. It will make sure
* that the the following two constraints are satisfied
@@ -2494,7 +2436,7 @@ class CommandExecutorImpl implements CommandExecutor {
return _runCommand(command, timeout).then((CommandOutput output) {
if (retriesLeft > 0 && shouldRetryCommand(output)) {
DebugLogger.warning("Rerunning Command: ($retriesLeft "
- "attempt(s) remains) [cmd: $command]");
+ "attempt(s) remains) [cmd: $command]");
return runCommand(retriesLeft - 1);
} else {
return new Future.value(output);
@@ -2545,8 +2487,8 @@ class CommandExecutorImpl implements CommandExecutor {
var completer = new Completer<CommandOutput>();
var callback = (BrowserTestOutput output) {
- completer.complete(
- new BrowserControllerTestOutcome(browserCommand, output));
+ completer
+ .complete(new BrowserControllerTestOutcome(browserCommand, output));
};
BrowserTest browserTest;
@@ -2564,12 +2506,12 @@ class CommandExecutorImpl implements CommandExecutor {
return completer.future;
}
- Future<BrowserTestRunner> _getBrowserTestRunner(String browser,
- Map configuration) async {
+ Future<BrowserTestRunner> _getBrowserTestRunner(
+ String browser, Map configuration) async {
var localIp = globalConfiguration['local_ip'];
if (_browserTestRunners[configuration] == null) {
var testRunner = new BrowserTestRunner(
- configuration, localIp, browser, maxBrowserProcesses);
+ configuration, localIp, browser, maxBrowserProcesses);
if (globalConfiguration['verbose']) {
testRunner.logger = DebugLogger.info;
}
@@ -2583,8 +2525,7 @@ class CommandExecutorImpl implements CommandExecutor {
class RecordingCommandExecutor implements CommandExecutor {
TestCaseRecorder _recorder;
- RecordingCommandExecutor(Path path)
- : _recorder = new TestCaseRecorder(path);
+ RecordingCommandExecutor(Path path) : _recorder = new TestCaseRecorder(path);
Future<CommandOutput> runCommand(node, ProcessCommand command, int timeout) {
assert(node.dependencies.length == 0);
@@ -2606,8 +2547,7 @@ class RecordingCommandExecutor implements CommandExecutor {
if (environment == null) return true;
return environment.length == 0 ||
(environment.length == 1 &&
- environment.containsKey("DART_CONFIGURATION"));
-
+ environment.containsKey("DART_CONFIGURATION"));
}
}
@@ -2643,7 +2583,7 @@ bool shouldRetryCommand(CommandOutput output) {
// "xvfb-run" issue 7564, try re-running the test.
bool containsFailureMsg(String line) {
return line.contains(MESSAGE_CANNOT_OPEN_DISPLAY) ||
- line.contains(MESSAGE_FAILED_TO_RUN_COMMAND);
+ line.contains(MESSAGE_FAILED_TO_RUN_COMMAND);
}
if (stdout.any(containsFailureMsg) || stderr.any(containsFailureMsg)) {
return true;
@@ -2671,8 +2611,10 @@ bool shouldRetryCommand(CommandOutput output) {
* closed.
*/
class TestCaseCompleter {
- static final COMPLETED_STATES = [dgraph.NodeState.Failed,
- dgraph.NodeState.Successful];
+ static final COMPLETED_STATES = [
+ dgraph.NodeState.Failed,
+ dgraph.NodeState.Successful
+ ];
final dgraph.Graph graph;
final TestCaseEnqueuer enqueuer;
final CommandQueue commandQueue;
@@ -2700,26 +2642,26 @@ class TestCaseCompleter {
// changes.
eventCondition((event) => event is dgraph.StateChangedEvent)
.listen((dgraph.StateChangedEvent event) {
- if (event.from == dgraph.NodeState.Processing &&
- !finishedRemainingTestCases ) {
- var command = event.node.userData;
+ if (event.from == dgraph.NodeState.Processing &&
+ !finishedRemainingTestCases) {
+ var command = event.node.userData;
- assert(COMPLETED_STATES.contains(event.to));
- assert(_outputs[command] != null);
+ assert(COMPLETED_STATES.contains(event.to));
+ assert(_outputs[command] != null);
- _completeTestCasesIfPossible(enqueuer.command2testCases[command]);
- _checkDone();
- }
+ _completeTestCasesIfPossible(enqueuer.command2testCases[command]);
+ _checkDone();
+ }
});
// Listen also for GraphSealedEvent's. If there is not a single node in the
// graph, we still want to finish after the graph was sealed.
eventCondition((event) => event is dgraph.GraphSealedEvent)
.listen((dgraph.GraphSealedEvent event) {
- if (!_closed && enqueuer.remainingTestCases.isEmpty) {
- _controller.close();
- _closed = true;
- }
+ if (!_closed && enqueuer.remainingTestCases.isEmpty) {
+ _controller.close();
+ _closed = true;
+ }
});
}
@@ -2763,7 +2705,6 @@ class TestCaseCompleter {
}
}
-
class ProcessQueue {
Map _globalConfiguration;
@@ -2771,32 +2712,28 @@ class ProcessQueue {
final dgraph.Graph _graph = new dgraph.Graph();
List<EventListener> _eventListener;
- ProcessQueue(this._globalConfiguration,
- maxProcesses,
- maxBrowserProcesses,
- DateTime startTime,
- testSuites,
- this._eventListener,
- this._allDone,
- [bool verbose = false,
- String recordingOutputFile,
- String recordedInputFile]) {
+ ProcessQueue(this._globalConfiguration, maxProcesses, maxBrowserProcesses,
+ DateTime startTime, testSuites, this._eventListener, this._allDone,
+ [bool verbose = false,
+ String recordingOutputFile,
+ String recordedInputFile]) {
void setupForListing(TestCaseEnqueuer testCaseEnqueuer) {
- _graph.events.where((event) => event is dgraph.GraphSealedEvent)
- .listen((dgraph.GraphSealedEvent event) {
- var testCases = new List.from(testCaseEnqueuer.remainingTestCases);
- testCases.sort((a, b) => a.displayName.compareTo(b.displayName));
-
- print("\nGenerating all matching test cases ....\n");
-
- for (TestCase testCase in testCases) {
- eventFinishedTestCase(testCase);
- print("${testCase.displayName} "
- "Expectations: ${testCase.expectedOutcomes.join(', ')} "
- "Configuration: '${testCase.configurationString}'");
- }
- eventAllTestsKnown();
- });
+ _graph.events
+ .where((event) => event is dgraph.GraphSealedEvent)
+ .listen((dgraph.GraphSealedEvent event) {
+ var testCases = new List.from(testCaseEnqueuer.remainingTestCases);
+ testCases.sort((a, b) => a.displayName.compareTo(b.displayName));
+
+ print("\nGenerating all matching test cases ....\n");
+
+ for (TestCase testCase in testCases) {
+ eventFinishedTestCase(testCase);
+ print("${testCase.displayName} "
+ "Expectations: ${testCase.expectedOutcomes.join(', ')} "
+ "Configuration: '${testCase.configurationString}'");
+ }
+ eventAllTestsKnown();
+ });
}
var testCaseEnqueuer;
@@ -2818,17 +2755,18 @@ class ProcessQueue {
cancelDebugTimer();
_debugTimer = new Timer(debugTimerDuration, () {
print("The debug timer of test.dart expired. Please report this issue"
- " to ricow/whesse and provide the following information:");
+ " to ricow/whesse and provide the following information:");
print("");
print("Graph is sealed: ${_graph.isSealed}");
print("");
_graph.DumpCounts();
print("");
var unfinishedNodeStates = [
- dgraph.NodeState.Initialized,
- dgraph.NodeState.Waiting,
- dgraph.NodeState.Enqueuing,
- dgraph.NodeState.Processing];
+ dgraph.NodeState.Initialized,
+ dgraph.NodeState.Waiting,
+ dgraph.NodeState.Enqueuing,
+ dgraph.NodeState.Processing
+ ];
for (var nodeState in unfinishedNodeStates) {
if (_graph.stateCount(nodeState) > 0) {
@@ -2842,7 +2780,7 @@ class ProcessQueue {
print(" Command: $command");
for (var testCase in testCases) {
print(" Enqueued by: ${testCase.configurationString} "
- "-- ${testCase.displayName}");
+ "-- ${testCase.displayName}");
}
print("");
}
@@ -2863,9 +2801,10 @@ class ProcessQueue {
// When the graph building is finished, notify event listeners.
_graph.events
- .where((event) => event is dgraph.GraphSealedEvent).listen((event) {
- eventAllTestsKnown();
- });
+ .where((event) => event is dgraph.GraphSealedEvent)
+ .listen((event) {
+ eventAllTestsKnown();
+ });
// Queue commands as they become "runnable"
var commandEnqueuer = new CommandEnqueuer(_graph);
@@ -2883,30 +2822,27 @@ class ProcessQueue {
// Run "runnable commands" using [executor] subject to
// maxProcesses/maxBrowserProcesses constraint
- commandQueue = new CommandQueue(
- _graph, testCaseEnqueuer, executor, maxProcesses, maxBrowserProcesses,
- verbose);
+ commandQueue = new CommandQueue(_graph, testCaseEnqueuer, executor,
+ maxProcesses, maxBrowserProcesses, verbose);
// Finish test cases when all commands were run (or some failed)
var testCaseCompleter =
new TestCaseCompleter(_graph, testCaseEnqueuer, commandQueue);
- testCaseCompleter.finishedTestCases.listen(
- (TestCase finishedTestCase) {
- resetDebugTimer();
+ testCaseCompleter.finishedTestCases.listen((TestCase finishedTestCase) {
+ resetDebugTimer();
- // If we're recording, we don't report any TestCases to listeners.
- if (!recording) {
- eventFinishedTestCase(finishedTestCase);
- }
- },
- onDone: () {
- // Wait until the commandQueue/execturo is done (it may need to stop
- // batch runners, browser controllers, ....)
- commandQueue.done.then((_) {
- cancelDebugTimer();
- eventAllTestsDone();
- });
- });
+ // If we're recording, we don't report any TestCases to listeners.
+ if (!recording) {
+ eventFinishedTestCase(finishedTestCase);
+ }
+ }, onDone: () {
+ // Wait until the commandQueue/execturo is done (it may need to stop
+ // batch runners, browser controllers, ....)
+ commandQueue.done.then((_) {
+ cancelDebugTimer();
+ eventAllTestsDone();
+ });
+ });
resetDebugTimer();
}
« 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