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 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
10 import 'package:unittest/src/util/io.dart'; | 10 import 'package:test/src/util/io.dart'; |
11 import 'package:unittest/unittest.dart'; | 11 import 'package:test/test.dart'; |
12 | 12 |
13 import '../io.dart'; | 13 import '../io.dart'; |
14 | 14 |
15 void main() { | 15 void main() { |
16 test("reports when no tests are run", () { | 16 test("reports when no tests are run", () { |
17 return withTempDir((path) { | 17 return withTempDir((path) { |
18 new File(p.join(path, "test.dart")).writeAsStringSync("void main() {}"); | 18 new File(p.join(path, "test.dart")).writeAsStringSync("void main() {}"); |
19 var result = runUnittest(["test.dart"], workingDirectory: path); | 19 var result = runUnittest(["test.dart"], workingDirectory: path); |
20 expect(result.stdout, equals("No tests ran.\n")); | 20 expect(result.stdout, equals("No tests ran.\n")); |
21 }); | 21 }); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 +0 -1: test | 213 +0 -1: test |
214 first error | 214 first error |
215 test.dart 24:11 main.<fn> | 215 test.dart 24:11 main.<fn> |
216 | 216 |
217 three | 217 three |
218 four | 218 four |
219 second error | 219 second error |
220 test.dart 13:13 main.<fn>.<fn> | 220 test.dart 13:13 main.<fn>.<fn> |
221 ===== asynchronous gap =========================== | 221 ===== asynchronous gap =========================== |
222 dart:async scheduleMicrotask | 222 dart:async scheduleMicrotask |
223 test.dart 10:28 main.<fn> | 223 test.dart 10:11 main.<fn> |
224 | 224 |
225 five | 225 five |
226 six | 226 six |
227 | 227 |
228 +0 -1: wait | 228 +0 -1: wait |
229 +1 -1: wait | 229 +1 -1: wait |
230 +1 -1: Some tests failed."""); | 230 +1 -1: Some tests failed."""); |
231 }); | 231 }); |
232 }); | 232 }); |
233 } | 233 } |
234 | 234 |
235 void _expectReport(String tests, String expected, {List<String> args}) { | 235 void _expectReport(String tests, String expected, {List<String> args}) { |
236 var dart = """ | 236 var dart = """ |
237 import 'dart:async'; | 237 import 'dart:async'; |
238 | 238 |
239 import 'package:unittest/unittest.dart'; | 239 import 'package:test/test.dart'; |
240 | 240 |
241 void main() { | 241 void main() { |
242 $tests | 242 $tests |
243 } | 243 } |
244 """; | 244 """; |
245 | 245 |
246 expect(withTempDir((path) { | 246 expect(withTempDir((path) { |
247 new File(p.join(path, "test.dart")).writeAsStringSync(dart); | 247 new File(p.join(path, "test.dart")).writeAsStringSync(dart); |
248 if (args == null) args = []; | 248 if (args == null) args = []; |
249 args = args.toList()..add("test.dart"); | 249 args = args.toList()..add("test.dart"); |
250 var result = runUnittest(args, workingDirectory: path); | 250 var result = runUnittest(args, workingDirectory: path); |
251 | 251 |
252 // Convert CRs into newlines, remove excess trailing whitespace, and trim | 252 // Convert CRs into newlines, remove excess trailing whitespace, and trim |
253 // off timestamps. | 253 // off timestamps. |
254 var actual = result.stdout.trim().split(new RegExp(r"[\r\n]")).map((line) { | 254 var actual = result.stdout.trim().split(new RegExp(r"[\r\n]")).map((line) { |
255 if (line.startsWith(" ") || line.isEmpty) return line.trimRight(); | 255 if (line.startsWith(" ") || line.isEmpty) return line.trimRight(); |
256 return line.trim().replaceFirst(new RegExp("^[0-9]{2}:[0-9]{2} "), ""); | 256 return line.trim().replaceFirst(new RegExp("^[0-9]{2}:[0-9]{2} "), ""); |
257 }).join("\n"); | 257 }).join("\n"); |
258 | 258 |
259 // Un-indent the expected string. | 259 // Un-indent the expected string. |
260 var indentation = expected.indexOf(new RegExp("[^ ]")); | 260 var indentation = expected.indexOf(new RegExp("[^ ]")); |
261 expected = expected.split("\n").map((line) { | 261 expected = expected.split("\n").map((line) { |
262 if (line.isEmpty) return line; | 262 if (line.isEmpty) return line; |
263 return line.substring(indentation); | 263 return line.substring(indentation); |
264 }).join("\n"); | 264 }).join("\n"); |
265 | 265 |
266 expect(actual, equals(expected)); | 266 expect(actual, equals(expected)); |
267 }), completes); | 267 }), completes); |
268 } | 268 } |
OLD | NEW |