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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 new File(p.join(path, "test.dart")).writeAsStringSync(dart); | 362 new File(p.join(path, "test.dart")).writeAsStringSync(dart); |
363 if (args == null) args = []; | 363 if (args == null) args = []; |
364 args = args.toList() | 364 args = args.toList() |
365 ..add("test.dart") | 365 ..add("test.dart") |
366 ..add("--concurrency=$concurrency") | 366 ..add("--concurrency=$concurrency") |
367 ..add("--reporter=compact"); | 367 ..add("--reporter=compact"); |
368 var result = runTest(args, workingDirectory: path); | 368 var result = runTest(args, workingDirectory: path); |
369 | 369 |
370 // Convert CRs into newlines, remove excess trailing whitespace, and trim | 370 // Convert CRs into newlines, remove excess trailing whitespace, and trim |
371 // off timestamps. | 371 // off timestamps. |
| 372 var lastLine; |
372 var actual = result.stdout.trim().split(new RegExp(r"[\r\n]")).map((line) { | 373 var actual = result.stdout.trim().split(new RegExp(r"[\r\n]")).map((line) { |
373 if (line.startsWith(" ") || line.isEmpty) return line.trimRight(); | 374 if (line.startsWith(" ") || line.isEmpty) return line.trimRight(); |
374 return line.trim().replaceFirst(new RegExp("^[0-9]{2}:[0-9]{2} "), ""); | 375 |
375 }).join("\n"); | 376 var trimmed = line.trim() |
| 377 .replaceFirst(new RegExp("^[0-9]{2}:[0-9]{2} "), ""); |
| 378 |
| 379 // Trim identical lines so the test isn't dependent on how fast each test |
| 380 // runs. |
| 381 if (trimmed == lastLine) return null; |
| 382 lastLine = trimmed; |
| 383 return trimmed; |
| 384 }).where((line) => line != null).join("\n"); |
376 | 385 |
377 // Un-indent the expected string. | 386 // Un-indent the expected string. |
378 var indentation = expected.indexOf(new RegExp("[^ ]")); | 387 var indentation = expected.indexOf(new RegExp("[^ ]")); |
379 expected = expected.split("\n").map((line) { | 388 expected = expected.split("\n").map((line) { |
380 if (line.isEmpty) return line; | 389 if (line.isEmpty) return line; |
381 return line.substring(indentation); | 390 return line.substring(indentation); |
382 }).join("\n"); | 391 }).join("\n"); |
383 | 392 |
384 expect(actual, equals(expected)); | 393 expect(actual, equals(expected)); |
385 }), completes); | 394 }), completes); |
386 } | 395 } |
OLD | NEW |