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

Unified Diff: test/runner/runner_test.dart

Issue 1097183003: Add an "onPlatform" parameter to test() and group(). (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 | « test/runner/browser/runner_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/runner/runner_test.dart
diff --git a/test/runner/runner_test.dart b/test/runner/runner_test.dart
index d717b671d62247cc2ec7add3102b85ca989c50f9..0214ab9e4aa2386ece0487b8ae5c40293a6e8d51 100644
--- a/test/runner/runner_test.dart
+++ b/test/runner/runner_test.dart
@@ -377,6 +377,100 @@ void main() {
expect(result.stdout, contains("+0 ~1: All tests skipped."));
});
+ group("in onPlatform", () {
+ test("respects matching Skips", () {
+ new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
+import 'dart:async';
+
+import 'package:test/test.dart';
+
+void main() {
+ test("fail", () => throw 'oh no', onPlatform: {"vm": new Skip()});
+}
+''');
+
+ var result = _runUnittest(["test.dart"]);
+ expect(result.stdout, contains("+0 ~1: All tests skipped."));
+ });
+
+ test("ignores non-matching Skips", () {
+ new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
+import 'dart:async';
+
+import 'package:test/test.dart';
+
+void main() {
+ test("success", () {}, onPlatform: {"chrome": new Skip()});
+}
+''');
+
+ var result = _runUnittest(["test.dart"]);
+ expect(result.stdout, contains("+1: All tests passed!"));
+ });
+
+ test("respects matching Timeouts", () {
+ new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
+import 'dart:async';
+
+import 'package:test/test.dart';
+
+void main() {
+ test("fail", () => throw 'oh no', onPlatform: {
+ "vm": new Timeout(new Duration(seconds: 0))
+ });
+}
+''');
+
+ var result = _runUnittest(["test.dart"]);
+ expect(result.stdout, contains("Test timed out after 0 seconds."));
+ expect(result.stdout, contains("-1: Some tests failed."));
+ });
+
+ test("ignores non-matching Timeouts", () {
+ new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
+import 'dart:async';
+
+import 'package:test/test.dart';
+
+void main() {
+ test("success", () {}, onPlatform: {
+ "chrome": new Timeout(new Duration(seconds: 0))
+ });
+}
+''');
+
+ var result = _runUnittest(["test.dart"]);
+ expect(result.stdout, contains("+1: All tests passed!"));
+ });
+
+ test("applies matching platforms in order", () {
+ new File(p.join(_sandbox, "test.dart")).writeAsStringSync('''
+import 'dart:async';
+
+import 'package:test/test.dart';
+
+void main() {
+ test("success", () {}, onPlatform: {
+ "vm": new Skip("first"),
+ "vm || windows": new Skip("second"),
+ "vm || linux": new Skip("third"),
+ "vm || mac-os": new Skip("fourth"),
+ "vm || android": new Skip("fifth")
+ });
+}
+''');
+
+ var result = _runUnittest(["test.dart"]);
+ expect(result.stdout, contains("Skip: fifth"));
+ expect(result.stdout, isNot(anyOf([
+ contains("Skip: first"),
+ contains("Skip: second"),
+ contains("Skip: third"),
+ contains("Skip: fourth")
+ ])));
+ });
+ });
+
group("flags:", () {
test("with the --color flag, uses colors", () {
new File(p.join(_sandbox, "test.dart")).writeAsStringSync(_failure);
« no previous file with comments | « test/runner/browser/runner_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698