| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 @TestOn("vm") | 5 @TestOn("vm") |
| 6 | 6 |
| 7 import 'package:scheduled_test/descriptor.dart' as d; | 7 import 'package:scheduled_test/descriptor.dart' as d; |
| 8 import 'package:scheduled_test/scheduled_stream.dart'; | 8 import 'package:scheduled_test/scheduled_stream.dart'; |
| 9 import 'package:scheduled_test/scheduled_test.dart'; | 9 import 'package:scheduled_test/scheduled_test.dart'; |
| 10 | 10 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 d.file("test.dart", """ | 171 d.file("test.dart", """ |
| 172 import 'package:test/test.dart'; | 172 import 'package:test/test.dart'; |
| 173 | 173 |
| 174 void main() { | 174 void main() { |
| 175 test("foo", () {}, tags: ["a", "b"]); | 175 test("foo", () {}, tags: ["a", "b"]); |
| 176 } | 176 } |
| 177 """).create(); | 177 """).create(); |
| 178 | 178 |
| 179 var test = runTest(["test.dart"]); | 179 var test = runTest(["test.dart"]); |
| 180 test.stdout.expect(consumeThrough(lines( | 180 test.stdout.expect(consumeThrough(lines( |
| 181 'Warning: Tags were used that weren\'t specified on the command ' | 181 'Warning: Tags were used that weren\'t specified in dart_test.yaml.\n' |
| 182 'line.\n' | |
| 183 ' a was used in the test "foo"\n' | 182 ' a was used in the test "foo"\n' |
| 184 ' b was used in the test "foo"'))); | 183 ' b was used in the test "foo"'))); |
| 185 test.shouldExit(0); | 184 test.shouldExit(0); |
| 186 }); | 185 }); |
| 187 | 186 |
| 188 test("for multiple tests", () { | 187 test("for multiple tests", () { |
| 189 d.file("test.dart", """ | 188 d.file("test.dart", """ |
| 190 import 'package:test/test.dart'; | 189 import 'package:test/test.dart'; |
| 191 | 190 |
| 192 void main() { | 191 void main() { |
| 193 test("foo", () {}, tags: "a"); | 192 test("foo", () {}, tags: "a"); |
| 194 test("bar", () {}, tags: "a"); | 193 test("bar", () {}, tags: "a"); |
| 195 } | 194 } |
| 196 """).create(); | 195 """).create(); |
| 197 | 196 |
| 198 var test = runTest(["test.dart"]); | 197 var test = runTest(["test.dart"]); |
| 199 test.stdout.expect(consumeThrough(lines( | 198 test.stdout.expect(consumeThrough(lines( |
| 200 'Warning: A tag was used that wasn\'t specified on the command ' | 199 'Warning: A tag was used that wasn\'t specified in dart_test.yaml.\n' |
| 201 'line.\n' | |
| 202 ' a was used in:\n' | 200 ' a was used in:\n' |
| 203 ' the test "foo"\n' | 201 ' the test "foo"\n' |
| 204 ' the test "bar"'))); | 202 ' the test "bar"'))); |
| 205 test.shouldExit(0); | 203 test.shouldExit(0); |
| 206 }); | 204 }); |
| 207 | 205 |
| 208 test("for groups", () { | 206 test("for groups", () { |
| 209 d.file("test.dart", """ | 207 d.file("test.dart", """ |
| 210 import 'package:test/test.dart'; | 208 import 'package:test/test.dart'; |
| 211 | 209 |
| 212 void main() { | 210 void main() { |
| 213 group("group", () { | 211 group("group", () { |
| 214 test("foo", () {}); | 212 test("foo", () {}); |
| 215 test("bar", () {}); | 213 test("bar", () {}); |
| 216 }, tags: "a"); | 214 }, tags: "a"); |
| 217 } | 215 } |
| 218 """).create(); | 216 """).create(); |
| 219 | 217 |
| 220 var test = runTest(["test.dart"]); | 218 var test = runTest(["test.dart"]); |
| 221 test.stdout.expect(consumeThrough(lines( | 219 test.stdout.expect(consumeThrough(lines( |
| 222 'Warning: A tag was used that wasn\'t specified on the command ' | 220 'Warning: A tag was used that wasn\'t specified in dart_test.yaml.\n' |
| 223 'line.\n' | |
| 224 ' a was used in the group "group"'))); | 221 ' a was used in the group "group"'))); |
| 225 test.shouldExit(0); | 222 test.shouldExit(0); |
| 226 }); | 223 }); |
| 227 | 224 |
| 228 test("for suites", () { | 225 test("for suites", () { |
| 229 d.file("test.dart", """ | 226 d.file("test.dart", """ |
| 230 @Tags(const ["a"]) | 227 @Tags(const ["a"]) |
| 231 import 'package:test/test.dart'; | 228 import 'package:test/test.dart'; |
| 232 | 229 |
| 233 void main() { | 230 void main() { |
| 234 test("foo", () {}); | 231 test("foo", () {}); |
| 235 test("bar", () {}); | 232 test("bar", () {}); |
| 236 } | 233 } |
| 237 """).create(); | 234 """).create(); |
| 238 | 235 |
| 239 var test = runTest(["test.dart"]); | 236 var test = runTest(["test.dart"]); |
| 240 test.stdout.expect(consumeThrough(lines( | 237 test.stdout.expect(consumeThrough(lines( |
| 241 'Warning: A tag was used that wasn\'t specified on the command ' | 238 'Warning: A tag was used that wasn\'t specified in dart_test.yaml.\n' |
| 242 'line.\n' | |
| 243 ' a was used in the suite itself'))); | 239 ' a was used in the suite itself'))); |
| 244 test.shouldExit(0); | 240 test.shouldExit(0); |
| 245 }); | 241 }); |
| 246 | 242 |
| 247 test("doesn't double-print a tag warning", () { | 243 test("doesn't double-print a tag warning", () { |
| 248 d.file("test.dart", """ | 244 d.file("test.dart", """ |
| 249 import 'package:test/test.dart'; | 245 import 'package:test/test.dart'; |
| 250 | 246 |
| 251 void main() { | 247 void main() { |
| 252 test("foo", () {}, tags: "a"); | 248 test("foo", () {}, tags: "a"); |
| 253 } | 249 } |
| 254 """).create(); | 250 """).create(); |
| 255 | 251 |
| 256 var test = runTest(["-p", "vm,content-shell", "test.dart"]); | 252 var test = runTest(["-p", "vm,content-shell", "test.dart"]); |
| 257 test.stdout.expect(consumeThrough(lines( | 253 test.stdout.expect(consumeThrough(lines( |
| 258 'Warning: A tag was used that wasn\'t specified on the command ' | 254 'Warning: A tag was used that wasn\'t specified in dart_test.yaml.\n' |
| 259 'line.\n' | |
| 260 ' a was used in the test "foo"'))); | 255 ' a was used in the test "foo"'))); |
| 261 test.stdout.expect(never(startsWith("Warning:"))); | 256 test.stdout.expect(never(startsWith("Warning:"))); |
| 262 test.shouldExit(0); | 257 test.shouldExit(0); |
| 263 }); | 258 }); |
| 264 }); | 259 }); |
| 265 | 260 |
| 266 group("invalid tags", () { | 261 group("invalid tags", () { |
| 267 test("are disallowed by test()", () { | 262 test("are disallowed by test()", () { |
| 268 d.file("test.dart", """ | 263 d.file("test.dart", """ |
| 269 import 'package:test/test.dart'; | 264 import 'package:test/test.dart'; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 test.shouldExit(1); | 312 test.shouldExit(1); |
| 318 }); | 313 }); |
| 319 }); | 314 }); |
| 320 } | 315 } |
| 321 | 316 |
| 322 /// Returns a [StreamMatcher] that asserts that a test emits warnings for [tags] | 317 /// Returns a [StreamMatcher] that asserts that a test emits warnings for [tags] |
| 323 /// in order. | 318 /// in order. |
| 324 StreamMatcher tagWarnings(List<String> tags) => inOrder(() sync* { | 319 StreamMatcher tagWarnings(List<String> tags) => inOrder(() sync* { |
| 325 yield consumeThrough( | 320 yield consumeThrough( |
| 326 "Warning: ${tags.length == 1 ? 'A tag was' : 'Tags were'} used that " | 321 "Warning: ${tags.length == 1 ? 'A tag was' : 'Tags were'} used that " |
| 327 "${tags.length == 1 ? "wasn't" : "weren't"} specified on the command " | 322 "${tags.length == 1 ? "wasn't" : "weren't"} specified in " |
| 328 "line."); | 323 "dart_test.yaml."); |
| 329 | 324 |
| 330 for (var tag in tags) { | 325 for (var tag in tags) { |
| 331 yield consumeWhile(isNot(contains(" was used in"))); | 326 yield consumeWhile(isNot(contains(" was used in"))); |
| 332 yield consumeThrough(startsWith(" $tag was used in")); | 327 yield consumeThrough(startsWith(" $tag was used in")); |
| 333 } | 328 } |
| 334 | 329 |
| 335 // Consume until the end of the warning block, and assert that it has no | 330 // Consume until the end of the warning block, and assert that it has no |
| 336 // further tags than the ones we specified. | 331 // further tags than the ones we specified. |
| 337 yield consumeWhile(isNot(anyOf([contains(" was used in"), isEmpty]))); | 332 yield consumeWhile(isNot(anyOf([contains(" was used in"), isEmpty]))); |
| 338 yield isEmpty; | 333 yield isEmpty; |
| 339 }()); | 334 }()); |
| 340 | 335 |
| 341 /// Returns a [StreamMatcher] that matches the lines of [string] in order. | 336 /// Returns a [StreamMatcher] that matches the lines of [string] in order. |
| 342 StreamMatcher lines(String string) => inOrder(string.split("\n")); | 337 StreamMatcher lines(String string) => inOrder(string.split("\n")); |
| OLD | NEW |