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

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

Issue 1829483002: Add support for a global configuration file. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 9 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 | « lib/src/runner/configuration/load.dart ('k') | test/runner/configuration/top_level_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/runner/configuration/global_test.dart
diff --git a/test/runner/configuration/global_test.dart b/test/runner/configuration/global_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..07b2f82a676587d2927cb6cccf2ce6a0f059ca00
--- /dev/null
+++ b/test/runner/configuration/global_test.dart
@@ -0,0 +1,128 @@
+// 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: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("ignores an empty file", () {
+ d.file("global_test.yaml", "").create();
+
+ d.file("test.dart", """
+ import 'package:test/test.dart';
+
+ void main() {
+ test("success", () {});
+ }
+ """).create();
+
+ var test = runTest(["test.dart"], environment: {
+ "DART_TEST_CONFIG": "global_test.yaml"
+ });
+ test.stdout.expect(consumeThrough(contains("+1: All tests passed!")));
+ test.shouldExit(0);
+ });
+
+ test("uses supported test configuration", () {
+ d.file("global_test.yaml", JSON.encode({
+ "verbose_trace": true
+ })).create();
+
+ d.file("test.dart", """
+ import 'package:test/test.dart';
+
+ void main() {
+ test("failure", () => throw "oh no");
+ }
+ """).create();
+
+ var test = runTest(["test.dart"], environment: {
+ "DART_TEST_CONFIG": "global_test.yaml"
+ });
+ test.stdout.expect(consumeThrough(contains("dart:isolate-patch")));
+ test.shouldExit(1);
+ });
+
+ test("uses supported runner configuration", () {
+ d.file("global_test.yaml", JSON.encode({
+ "reporter": "json"
+ })).create();
+
+ d.file("test.dart", """
+ import 'package:test/test.dart';
+
+ void main() {
+ test("success", () {});
+ }
+ """).create();
+
+ var test = runTest(["test.dart"], environment: {
+ "DART_TEST_CONFIG": "global_test.yaml"
+ });
+ test.stdout.expect(consumeThrough(contains('"testStart"')));
+ test.shouldExit(0);
+ });
+
+ test("local configuration takes precedence", () {
+ d.file("global_test.yaml", JSON.encode({
+ "verbose_trace": true
+ })).create();
+
+ d.file("dart_test.yaml", JSON.encode({
+ "verbose_trace": false
+ })).create();
+
+ d.file("test.dart", """
+ import 'package:test/test.dart';
+
+ void main() {
+ test("failure", () => throw "oh no");
+ }
+ """).create();
+
+ var test = runTest(["test.dart"], environment: {
+ "DART_TEST_CONFIG": "global_test.yaml"
+ });
+ test.stdout.expect(never(contains("dart:isolate-patch")));
+ test.shouldExit(1);
+ });
+
+ group("disallows local-only configuration:", () {
+ for (var field in ["skip", "test_on", "paths", "filename", "names",
+ "plain_names", "include_tags", "exclude_tags", "pub_serve", "tags",
+ "add_tags"]) {
+ test("rejects local-only configuration", () {
+ d.file("global_test.yaml", JSON.encode({field: null})).create();
+
+ d.file("test.dart", """
+ import 'package:test/test.dart';
+
+ void main() {
+ test("success", () {});
+ }
+ """).create();
+
+ var test = runTest(["test.dart"], environment: {
+ "DART_TEST_CONFIG": "global_test.yaml"
+ });
+ test.stderr.expect(containsInOrder([
+ "of global_test.yaml: $field isn't supported here.",
+ "^^"
+ ]));
+ test.shouldExit(exit_codes.data);
+ });
+ }
+ });
+}
« no previous file with comments | « lib/src/runner/configuration/load.dart ('k') | test/runner/configuration/top_level_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698