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

Unified Diff: test/runner/configuration/tags_test.dart

Issue 1691173002: Support tag configuration. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 10 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/configuration/configuration_test.dart ('k') | test/runner/tag_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/runner/configuration/tags_test.dart
diff --git a/test/runner/configuration/tags_test.dart b/test/runner/configuration/tags_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..fabe5a03971599f43b8d9ed682bbcf0a5620cf44
--- /dev/null
+++ b/test/runner/configuration/tags_test.dart
@@ -0,0 +1,126 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+@TestOn("vm")
+
+import 'dart:convert';
+
+import 'package:path/path.dart' as p;
+import 'package:scheduled_test/descriptor.dart' as d;
+import 'package:scheduled_test/scheduled_stream.dart';
+import 'package:scheduled_test/scheduled_test.dart';
+import 'package:test/src/util/exit_codes.dart' as exit_codes;
+
+import '../../io.dart';
+
+void main() {
+ useSandbox();
+
+ test("doesn't warn for tags that exist in the configuration", () {
+ d.file("dart_test.yaml", JSON.encode({
+ "tags": {"foo": null}
+ })).create();
+
+ d.file("test.dart", """
+ import 'package:test/test.dart';
+
+ void main() {
+ test("test", () {});
+ }
+ """).create();
+
+ var test = runTest(["test.dart"]);
+ test.stdout.expect(never(contains("Warning: Tags were used")));
+ test.shouldExit(0);
+ });
+
+ test("applies tag-specific configuration only to matching tests", () {
+ d.file("dart_test.yaml", JSON.encode({
+ "tags": {"foo": {"timeout": "0s"}}
+ })).create();
+
+ d.file("test.dart", """
+ import 'dart:async';
+
+ import 'package:test/test.dart';
+
+ void main() {
+ test("test 1", () => new Future.delayed(Duration.ZERO), tags: ['foo']);
+ test("test 2", () => new Future.delayed(Duration.ZERO));
+ }
+ """).create();
+
+ var test = runTest(["test.dart"]);
+ test.stdout.expect(containsInOrder([
+ "-1: test 1",
+ "+1 -1: Some tests failed."
+ ]));
+ test.shouldExit(1);
+ });
+
+ group("errors", () {
+ test("rejects an invalid tag type", () {
+ d.file("dart_test.yaml", '{"tags": {12: null}}').create();
+
+ var test = runTest([]);
+ test.stderr.expect(containsInOrder([
+ "tags key must be a string",
+ "^^"
+ ]));
+ test.shouldExit(exit_codes.data);
+ });
+
+ test("rejects an invalid tag name", () {
+ d.file("dart_test.yaml", JSON.encode({
+ "tags": {"foo bar": null}
+ })).create();
+
+ var test = runTest([]);
+ test.stderr.expect(containsInOrder([
+ "Invalid tag. Tags must be (optionally hyphenated) Dart identifiers.",
+ "^^^^^^^^^"
+ ]));
+ test.shouldExit(exit_codes.data);
+ });
+
+ test("rejects an inavlid tag map", () {
+ d.file("dart_test.yaml", JSON.encode({
+ "tags": 12
+ })).create();
+
+ var test = runTest([]);
+ test.stderr.expect(containsInOrder([
+ "tags must be a map",
+ "^^"
+ ]));
+ test.shouldExit(exit_codes.data);
+ });
+
+ test("rejects an inavlid tag configuration", () {
+ d.file("dart_test.yaml", JSON.encode({
+ "tags": {"foo": {"timeout": "12p"}}
+ })).create();
+
+ var test = runTest([]);
+ test.stderr.expect(containsInOrder([
+ "Invalid timeout: expected unit",
+ "^^^^"
+ ]));
+ test.shouldExit(exit_codes.data);
+ });
+
+ test("rejects runner configuration", () {
+ d.file("dart_test.yaml", JSON.encode({
+ "tags": {"foo": {"filename": "*_blorp.dart"}}
+ })).create();
+
+ var test = runTest([]);
+ test.stderr.expect(containsInOrder([
+ "filename isn't supported here.",
+ "^^^^^^^^^^"
+ ]));
+ test.shouldExit(exit_codes.data);
+ });
+ });
+}
« no previous file with comments | « test/runner/configuration/configuration_test.dart ('k') | test/runner/tag_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698