Expose sharding functionality (#1087)
Closes #1086
diff --git a/pkgs/test/CHANGELOG.md b/pkgs/test/CHANGELOG.md
index 765a1d3..f2acb13 100644
--- a/pkgs/test/CHANGELOG.md
+++ b/pkgs/test/CHANGELOG.md
@@ -1,3 +1,10 @@
+## 1.8.0
+
+* Expose the previously hidden sharding arguments
+ * `--total-shards` specifies how many shards the suite should
+ be split into
+ * `--shard-index` specifies which shard should be run
+
## 1.7.0
* Add a `--debug` flag for running the VM/Chrome in debug mode.
diff --git a/pkgs/test/README.md b/pkgs/test/README.md
index 11b85de..0063505 100644
--- a/pkgs/test/README.md
+++ b/pkgs/test/README.md
@@ -157,6 +157,16 @@
tests on both platforms with a single command: `pub run test -p "chrome,vm"
path/to/test.dart`.
+Tests can also be sharded with the `--total-shards` and `--shard-index` arguments,
+allowing you to split up your test suites and run them separately. For example,
+if you wanted to run 3 shards of your test suite, you could run them as follows:
+
+```bash
+pub run test --total-shards 3 --shard-index 0 path/to/test.dart
+pub run test --total-shards 3 --shard-index 1 path/to/test.dart
+pub run test --total-shards 3 --shard-index 2 path/to/test.dart
+```
+
### Restricting Tests to Certain Platforms
Some test files only make sense to run on particular platforms. They may use
diff --git a/pkgs/test/pubspec.yaml b/pkgs/test/pubspec.yaml
index 1f5391e..4637b4a 100644
--- a/pkgs/test/pubspec.yaml
+++ b/pkgs/test/pubspec.yaml
@@ -1,5 +1,5 @@
name: test
-version: 1.7.0
+version: 1.8.0
author: Dart Team <misc@dartlang.org>
description: A full featured library for writing and running Dart tests.
homepage: https://github.com/dart-lang/test/blob/master/pkgs/test
diff --git a/pkgs/test/test/runner/runner_test.dart b/pkgs/test/test/runner/runner_test.dart
index 8ce54bd..483d942 100644
--- a/pkgs/test/test/runner/runner_test.dart
+++ b/pkgs/test/test/runner/runner_test.dart
@@ -84,6 +84,8 @@
-j, --concurrency=<threads> The number of concurrent test suites run.
(defaults to "$_defaultConcurrency")
+ --total-shards The total number of invocations of the test runner being run.
+ --shard-index The index of this test runner invocation (of --total-shards).
--pub-serve=<port> The port of a pub serve instance serving "test/".
--timeout The default test timeout. For example: 15s, 2x, none
(defaults to "30s")
diff --git a/pkgs/test_core/lib/src/runner/configuration/args.dart b/pkgs/test_core/lib/src/runner/configuration/args.dart
index fe0eb91..6c244b2 100644
--- a/pkgs/test_core/lib/src/runner/configuration/args.dart
+++ b/pkgs/test_core/lib/src/runner/configuration/args.dart
@@ -74,6 +74,10 @@
help: 'The number of concurrent test suites run.',
defaultsTo: defaultConcurrency.toString(),
valueHelp: 'threads');
+ parser.addOption("total-shards",
+ help: 'The total number of invocations of the test runner being run.');
+ parser.addOption("shard-index",
+ help: 'The index of this test runner invocation (of --total-shards).');
parser.addOption("pub-serve",
help: 'The port of a pub serve instance serving "test/".',
valueHelp: 'port');
@@ -128,12 +132,6 @@
help: 'The path to the dart2js executable.', hide: true);
parser.addMultiOption("dart2js-args",
help: 'Extra arguments to pass to dart2js.', hide: true);
- parser.addOption("total-shards",
- help: 'The total number of invocations of the test runner being run.',
- hide: true);
- parser.addOption("shard-index",
- help: 'The index of this test runner invocation (of --total-shards).',
- hide: true);
// If we're running test/dir/my_test.dart, we'll look for
// test/dir/my_test.dart.html in the precompiled directory.