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; |
| 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 import 'package:test/src/util/exit_codes.dart' as exit_codes; |
| 14 |
| 15 import '../../io.dart'; |
| 16 |
| 17 void main() { |
| 18 useSandbox(); |
| 19 |
| 20 test("doesn't warn for tags that exist in the configuration", () { |
| 21 d.file("dart_test.yaml", JSON.encode({ |
| 22 "tags": {"foo": null} |
| 23 })).create(); |
| 24 |
| 25 d.file("test.dart", """ |
| 26 import 'package:test/test.dart'; |
| 27 |
| 28 void main() { |
| 29 test("test", () {}); |
| 30 } |
| 31 """).create(); |
| 32 |
| 33 var test = runTest(["test.dart"]); |
| 34 test.stdout.expect(never(contains("Warning: Tags were used"))); |
| 35 test.shouldExit(0); |
| 36 }); |
| 37 |
| 38 test("applies tag-specific configuration only to matching tests", () { |
| 39 d.file("dart_test.yaml", JSON.encode({ |
| 40 "tags": {"foo": {"timeout": "0s"}} |
| 41 })).create(); |
| 42 |
| 43 d.file("test.dart", """ |
| 44 import 'dart:async'; |
| 45 |
| 46 import 'package:test/test.dart'; |
| 47 |
| 48 void main() { |
| 49 test("test 1", () => new Future.delayed(Duration.ZERO), tags: ['foo']); |
| 50 test("test 2", () => new Future.delayed(Duration.ZERO)); |
| 51 } |
| 52 """).create(); |
| 53 |
| 54 var test = runTest(["test.dart"]); |
| 55 test.stdout.expect(containsInOrder([ |
| 56 "-1: test 1", |
| 57 "+1 -1: Some tests failed." |
| 58 ])); |
| 59 test.shouldExit(1); |
| 60 }); |
| 61 |
| 62 group("errors", () { |
| 63 test("rejects an invalid tag type", () { |
| 64 d.file("dart_test.yaml", '{"tags": {12: null}}').create(); |
| 65 |
| 66 var test = runTest([]); |
| 67 test.stderr.expect(containsInOrder([ |
| 68 "tags key must be a string", |
| 69 "^^" |
| 70 ])); |
| 71 test.shouldExit(exit_codes.data); |
| 72 }); |
| 73 |
| 74 test("rejects an invalid tag name", () { |
| 75 d.file("dart_test.yaml", JSON.encode({ |
| 76 "tags": {"foo bar": null} |
| 77 })).create(); |
| 78 |
| 79 var test = runTest([]); |
| 80 test.stderr.expect(containsInOrder([ |
| 81 "Invalid tag. Tags must be (optionally hyphenated) Dart identifiers.", |
| 82 "^^^^^^^^^" |
| 83 ])); |
| 84 test.shouldExit(exit_codes.data); |
| 85 }); |
| 86 |
| 87 test("rejects an inavlid tag map", () { |
| 88 d.file("dart_test.yaml", JSON.encode({ |
| 89 "tags": 12 |
| 90 })).create(); |
| 91 |
| 92 var test = runTest([]); |
| 93 test.stderr.expect(containsInOrder([ |
| 94 "tags must be a map", |
| 95 "^^" |
| 96 ])); |
| 97 test.shouldExit(exit_codes.data); |
| 98 }); |
| 99 |
| 100 test("rejects an inavlid tag configuration", () { |
| 101 d.file("dart_test.yaml", JSON.encode({ |
| 102 "tags": {"foo": {"timeout": "12p"}} |
| 103 })).create(); |
| 104 |
| 105 var test = runTest([]); |
| 106 test.stderr.expect(containsInOrder([ |
| 107 "Invalid timeout: expected unit", |
| 108 "^^^^" |
| 109 ])); |
| 110 test.shouldExit(exit_codes.data); |
| 111 }); |
| 112 |
| 113 test("rejects runner configuration", () { |
| 114 d.file("dart_test.yaml", JSON.encode({ |
| 115 "tags": {"foo": {"filename": "*_blorp.dart"}} |
| 116 })).create(); |
| 117 |
| 118 var test = runTest([]); |
| 119 test.stderr.expect(containsInOrder([ |
| 120 "filename isn't supported here.", |
| 121 "^^^^^^^^^^" |
| 122 ])); |
| 123 test.shouldExit(exit_codes.data); |
| 124 }); |
| 125 }); |
| 126 } |
OLD | NEW |