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

Unified Diff: test/runner/browser/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/backend/metadata_test.dart ('k') | test/runner/runner_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/runner/browser/runner_test.dart
diff --git a/test/runner/browser/runner_test.dart b/test/runner/browser/runner_test.dart
index f2d3c6381201d95aead5a72ddcc54db26cbe8add..146c05fd5c7ab90e6d7c54456f4c67944038c112 100644
--- a/test/runner/browser/runner_test.dart
+++ b/test/runner/browser/runner_test.dart
@@ -513,6 +513,100 @@ void main() {
expect(result.stdout, contains("Test timed out after 0 seconds."));
expect(result.stdout, contains("-1: Some tests failed."));
});
+
+ 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: {"chrome": new Skip()});
+}
+''');
+
+ var result = _runUnittest(["-p", "chrome", "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: {"vm": new Skip()});
+}
+''');
+
+ var result = _runUnittest(["-p", "chrome", "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: {
+ "chrome": new Timeout(new Duration(seconds: 0))
+ });
+}
+''');
+
+ var result = _runUnittest(["-p", "chrome", "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: {
+ "vm": new Timeout(new Duration(seconds: 0))
+ });
+}
+''');
+
+ var result = _runUnittest(["-p", "chrome", "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: {
+ "chrome": new Skip("first"),
+ "chrome || windows": new Skip("second"),
+ "chrome || linux": new Skip("third"),
+ "chrome || mac-os": new Skip("fourth"),
+ "chrome || android": new Skip("fifth")
+ });
+}
+''');
+
+ var result = _runUnittest(["-p", "chrome", "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")
+ ])));
+ });
+ });
}
ProcessResult _runUnittest(List<String> args) =>
« no previous file with comments | « test/backend/metadata_test.dart ('k') | test/runner/runner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698