Reviewers: kevmoo,
Description:
Properly set the exit code for failing tests run directly.
R=
kev...@google.com
Please review this at
https://codereview.chromium.org/1086083006/
Base URL: g...@github.com:dart-lang/test@master
Affected files (+12, -2 lines):
M CHANGELOG.md
M lib/test.dart
M test/runner/runner_test.dart
Index: CHANGELOG.md
diff --git a/CHANGELOG.md b/CHANGELOG.md
index
2959a63c3e108694b03e8461a41fbaadbeffff54..a399d4c6a22fd377abedfb06c3902fb409110d2e
100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,9 @@
* Stop `pub serve` from emitting a duplicate-asset error for tests with
custom
HTML files.
+* When running a test suite via `dart path/to/test.dart`, throw an
exception if
+ the suite fails so that the exit code is set properly.
+
### 0.12.0-beta.10
* Fix running browser tests in subdirectories.
Index: lib/test.dart
diff --git a/lib/test.dart b/lib/test.dart
index
06280430535a467fd0626163374e735aeb9cb9d4..1d420d311eb9a4d5f33e84122a2d4fd1ae9ec672
100644
--- a/lib/test.dart
+++ b/lib/test.dart
@@ -55,8 +55,13 @@ Declarer get _declarer {
path: p.prettyUri(Uri.base),
platform: "VM")
.forPlatform(TestPlatform.vm, os: currentOSGuess);
- // TODO(nweiz): Set the exit code on the VM when issue 6943 is fixed.
- new NoIoCompactReporter([suite], color: true).run();
+
+ new NoIoCompactReporter([suite], color: true).run().then((success) {
+ // TODO(nweiz): Set the exit code on the VM when issue 6943 is fixed.
+ if (success) return;
+ print('');
+ new Future.error("Dummy exception to set exit code.");
+ });
});
return _globalDeclarer;
}
Index: test/runner/runner_test.dart
diff --git a/test/runner/runner_test.dart b/test/runner/runner_test.dart
index
5e038127650cbbd3f78813e7e8c3063de60b3c0f..963feaf3fa223b1bbf3c21c14e6358baf7cb32d6
100644
--- a/test/runner/runner_test.dart
+++ b/test/runner/runner_test.dart
@@ -285,6 +285,7 @@ $_usage"""));
"test.dart"
]);
expect(result.stdout, contains("All tests passed!"));
+ expect(result.exitCode, equals(0));
});
// Regression test; this broke in 0.12.0-beta.9.
@@ -332,6 +333,7 @@ $_usage"""));
"test.dart"
]);
expect(result.stdout, contains("Some tests failed."));
+ expect(result.exitCode, isNot(equals(0)));
});
});