Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 @TestOn("vm") | |
| 6 | |
| 7 import 'dart:convert'; | |
| 8 | |
| 9 import 'package:path/path.dart' as p; | |
|
kevmoo
2016/03/23 18:27:12
unused
nweiz
2016/03/23 20:41:18
Done.
| |
| 10 import 'package:scheduled_test/descriptor.dart' as d; | |
| 11 import 'package:scheduled_test/scheduled_stream.dart'; | |
| 12 import 'package:scheduled_test/scheduled_test.dart'; | |
| 13 | |
| 14 import 'package:test/src/util/exit_codes.dart' as exit_codes; | |
| 15 import 'package:test/src/util/io.dart'; | |
|
kevmoo
2016/03/23 18:27:12
unused
nweiz
2016/03/23 20:41:18
Done.
| |
| 16 | |
| 17 import '../../io.dart'; | |
| 18 | |
| 19 void main() { | |
| 20 useSandbox(); | |
| 21 | |
| 22 test("ignores an empty file", () { | |
| 23 d.file("global_test.yaml", "").create(); | |
| 24 | |
| 25 d.file("test.dart", """ | |
| 26 import 'package:test/test.dart'; | |
| 27 | |
| 28 void main() { | |
| 29 test("success", () {}); | |
| 30 } | |
| 31 """).create(); | |
| 32 | |
| 33 var test = runTest(["test.dart"], environment: { | |
| 34 "DART_TEST_CONFIG": "global_test.yaml" | |
| 35 }); | |
| 36 test.stdout.expect(consumeThrough(contains("+1: All tests passed!"))); | |
| 37 test.shouldExit(0); | |
| 38 }); | |
| 39 | |
| 40 test("uses supported test configuration", () { | |
| 41 d.file("global_test.yaml", JSON.encode({ | |
| 42 "verbose_trace": true | |
| 43 })).create(); | |
| 44 | |
| 45 d.file("test.dart", """ | |
| 46 import 'package:test/test.dart'; | |
| 47 | |
| 48 void main() { | |
| 49 test("failure", () => throw "oh no"); | |
| 50 } | |
| 51 """).create(); | |
| 52 | |
| 53 var test = runTest(["test.dart"], environment: { | |
| 54 "DART_TEST_CONFIG": "global_test.yaml" | |
| 55 }); | |
| 56 test.stdout.expect(consumeThrough(contains("dart:isolate-patch"))); | |
| 57 test.shouldExit(1); | |
| 58 }); | |
| 59 | |
| 60 test("uses supported runner configuration", () { | |
| 61 d.file("global_test.yaml", JSON.encode({ | |
| 62 "reporter": "json" | |
| 63 })).create(); | |
| 64 | |
| 65 d.file("test.dart", """ | |
| 66 import 'package:test/test.dart'; | |
| 67 | |
| 68 void main() { | |
| 69 test("success", () {}); | |
| 70 } | |
| 71 """).create(); | |
| 72 | |
| 73 var test = runTest(["test.dart"], environment: { | |
| 74 "DART_TEST_CONFIG": "global_test.yaml" | |
| 75 }); | |
| 76 test.stdout.expect(consumeThrough(contains('"testStart"'))); | |
| 77 test.shouldExit(0); | |
| 78 }); | |
| 79 | |
| 80 test("local configuration takes precedence", () { | |
| 81 d.file("global_test.yaml", JSON.encode({ | |
| 82 "verbose_trace": true | |
| 83 })).create(); | |
| 84 | |
| 85 d.file("dart_test.yaml", JSON.encode({ | |
| 86 "verbose_trace": false | |
| 87 })).create(); | |
| 88 | |
| 89 d.file("test.dart", """ | |
| 90 import 'package:test/test.dart'; | |
| 91 | |
| 92 void main() { | |
| 93 test("failure", () => throw "oh no"); | |
| 94 } | |
| 95 """).create(); | |
| 96 | |
| 97 var test = runTest(["test.dart"], environment: { | |
| 98 "DART_TEST_CONFIG": "global_test.yaml" | |
| 99 }); | |
| 100 test.stdout.expect(never(contains("dart:isolate-patch"))); | |
| 101 test.shouldExit(1); | |
| 102 }); | |
| 103 | |
| 104 group("disallows local-only configuration:", () { | |
| 105 for (var field in ["skip", "test_on", "paths", "filename", "names", | |
| 106 "plain_names", "include_tags", "exclude_tags", "pub_serve", "tags", | |
| 107 "add_tags"]) { | |
| 108 test("rejects local-only configuration", () { | |
| 109 d.file("global_test.yaml", JSON.encode({field: null})).create(); | |
| 110 | |
| 111 d.file("test.dart", """ | |
| 112 import 'package:test/test.dart'; | |
| 113 | |
| 114 void main() { | |
| 115 test("success", () {}); | |
| 116 } | |
| 117 """).create(); | |
| 118 | |
| 119 var test = runTest(["test.dart"], environment: { | |
| 120 "DART_TEST_CONFIG": "global_test.yaml" | |
| 121 }); | |
| 122 test.stderr.expect(containsInOrder([ | |
| 123 "of global_test.yaml: $field isn't supported here.", | |
| 124 "^^" | |
| 125 ])); | |
| 126 test.shouldExit(exit_codes.data); | |
| 127 }); | |
| 128 } | |
| 129 }); | |
| 130 } | |
| OLD | NEW |