| 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:test/src/util/io.dart'; | 10 import 'package:test/src/util/io.dart'; |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 int concurrency}) { |
| 237 if (concurrency == null) concurrency = 1; |
| 238 |
| 236 var dart = """ | 239 var dart = """ |
| 237 import 'dart:async'; | 240 import 'dart:async'; |
| 238 | 241 |
| 239 import 'package:test/test.dart'; | 242 import 'package:test/test.dart'; |
| 240 | 243 |
| 241 void main() { | 244 void main() { |
| 242 $tests | 245 $tests |
| 243 } | 246 } |
| 244 """; | 247 """; |
| 245 | 248 |
| 246 expect(withTempDir((path) { | 249 expect(withTempDir((path) { |
| 247 new File(p.join(path, "test.dart")).writeAsStringSync(dart); | 250 new File(p.join(path, "test.dart")).writeAsStringSync(dart); |
| 248 if (args == null) args = []; | 251 if (args == null) args = []; |
| 249 args = args.toList()..add("test.dart"); | 252 args = args.toList()..add("test.dart"); |
| 253 args.add("--concurrency=$concurrency"); |
| 250 var result = runUnittest(args, workingDirectory: path); | 254 var result = runUnittest(args, workingDirectory: path); |
| 251 | 255 |
| 252 // Convert CRs into newlines, remove excess trailing whitespace, and trim | 256 // Convert CRs into newlines, remove excess trailing whitespace, and trim |
| 253 // off timestamps. | 257 // off timestamps. |
| 254 var actual = result.stdout.trim().split(new RegExp(r"[\r\n]")).map((line) { | 258 var actual = result.stdout.trim().split(new RegExp(r"[\r\n]")).map((line) { |
| 255 if (line.startsWith(" ") || line.isEmpty) return line.trimRight(); | 259 if (line.startsWith(" ") || line.isEmpty) return line.trimRight(); |
| 256 return line.trim().replaceFirst(new RegExp("^[0-9]{2}:[0-9]{2} "), ""); | 260 return line.trim().replaceFirst(new RegExp("^[0-9]{2}:[0-9]{2} "), ""); |
| 257 }).join("\n"); | 261 }).join("\n"); |
| 258 | 262 |
| 259 // Un-indent the expected string. | 263 // Un-indent the expected string. |
| 260 var indentation = expected.indexOf(new RegExp("[^ ]")); | 264 var indentation = expected.indexOf(new RegExp("[^ ]")); |
| 261 expected = expected.split("\n").map((line) { | 265 expected = expected.split("\n").map((line) { |
| 262 if (line.isEmpty) return line; | 266 if (line.isEmpty) return line; |
| 263 return line.substring(indentation); | 267 return line.substring(indentation); |
| 264 }).join("\n"); | 268 }).join("\n"); |
| 265 | 269 |
| 266 expect(actual, equals(expected)); | 270 expect(actual, equals(expected)); |
| 267 }), completes); | 271 }), completes); |
| 268 } | 272 } |
| OLD | NEW |