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

Unified Diff: lib/src/executable.dart

Issue 1062813006: Add the ability to run test suites in parallel. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 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 | « lib/src/backend/live_test_controller.dart ('k') | lib/src/runner/browser/compiler_pool.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/executable.dart
diff --git a/lib/src/executable.dart b/lib/src/executable.dart
index ebe0e7558cc56d86238a8740f0140026707e494b..65ff6f821df613fe24b28d47b13d042646e38591 100644
--- a/lib/src/executable.dart
+++ b/lib/src/executable.dart
@@ -10,6 +10,7 @@ library test.executable;
import 'dart:async';
import 'dart:io';
import 'dart:isolate';
+import 'dart:math' as math;
import 'package:args/args.dart';
import 'package:stack_trace/stack_trace.dart';
@@ -26,6 +27,12 @@ import 'utils.dart';
/// The argument parser used to parse the executable arguments.
final _parser = new ArgParser(allowTrailingOptions: true);
+/// The default number of test suites to run at once.
+///
+/// This defaults to half the available processors, since presumably some of
+/// them will be used for the OS and other processes.
+final _defaultConcurrency = math.max(1, Platform.numberOfProcessors ~/ 2);
+
/// A merged stream of all signals that tell the test runner to shut down
/// gracefully.
///
@@ -80,6 +87,11 @@ void main(List<String> args) {
allowed: TestPlatform.all.map((platform) => platform.identifier).toList(),
defaultsTo: 'vm',
allowMultiple: true);
+ _parser.addOption("concurrency",
+ abbr: 'j',
+ help: 'The number of concurrent test suites run.\n'
+ '(defaults to $_defaultConcurrency)',
+ valueHelp: 'threads');
_parser.addOption("pub-serve",
help: 'The port of a pub serve instance serving "test/".',
hide: !supportsPubServe,
@@ -127,6 +139,18 @@ transformers:
packageRoot: options["package-root"],
color: color);
+ var concurrency = _defaultConcurrency;
+ if (options["concurrency"] != null) {
+ try {
+ concurrency = int.parse(options["concurrency"]);
+ } catch (error) {
+ _printUsage('Couldn\'t parse --concurrency "${options["concurrency"]}":'
+ ' ${error.message}');
+ exitCode = exit_codes.usage;
+ return;
+ }
+ }
+
var signalSubscription;
var closed = false;
signalSubscription = _signals.listen((_) {
@@ -186,7 +210,8 @@ transformers:
}
}
- var reporter = new CompactReporter(flatten(suites), color: color);
+ var reporter = new CompactReporter(flatten(suites),
+ concurrency: concurrency, color: color);
// Override the signal handler to close [reporter]. [loader] will still be
// closed in the [whenComplete] below.
@@ -197,7 +222,10 @@ transformers:
// Wait a bit to print this message, since printing it eagerly looks weird
// if the tests then finish immediately.
var timer = new Timer(new Duration(seconds: 1), () {
- print("Waiting for current test to finish.");
+ // Print a blank line first to ensure that this doesn't interfere with
+ // the compact reporter's unfinished line.
+ print("");
+ print("Waiting for current test(s) to finish.");
print("Press Control-C again to terminate immediately.");
});
« no previous file with comments | « lib/src/backend/live_test_controller.dart ('k') | lib/src/runner/browser/compiler_pool.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698