Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library test_progress; | 5 library test_progress; |
| 6 | 6 |
| 7 import "dart:async"; | |
| 8 import "dart:io"; | 7 import "dart:io"; |
| 9 import "dart:io" as io; | 8 import "dart:io" as io; |
| 10 import "dart:convert" show JSON; | 9 import "dart:convert" show JSON; |
| 11 import "path.dart"; | 10 import "path.dart"; |
| 12 import "status_file_parser.dart"; | 11 import "status_file_parser.dart"; |
| 13 import "summary_report.dart"; | 12 import "summary_report.dart"; |
| 14 import "test_runner.dart"; | 13 import "test_runner.dart"; |
| 15 import "test_suite.dart"; | 14 import "test_suite.dart"; |
| 16 import "utils.dart"; | 15 import "utils.dart"; |
| 17 | 16 |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 } | 494 } |
| 496 | 495 |
| 497 void allDone() { | 496 void allDone() { |
| 498 if (_skippedCompilations > 0) { | 497 if (_skippedCompilations > 0) { |
| 499 print('\n$_skippedCompilations compilations were skipped because ' | 498 print('\n$_skippedCompilations compilations were skipped because ' |
| 500 'the previous output was already up to date\n'); | 499 'the previous output was already up to date\n'); |
| 501 } | 500 } |
| 502 } | 501 } |
| 503 } | 502 } |
| 504 | 503 |
| 504 /// Discovers directories in the system temp directory that appear to have been | |
| 505 /// created by "dart:io"'s `Directory.createTemp()` method. | |
| 505 class LeftOverTempDirPrinter extends EventListener { | 506 class LeftOverTempDirPrinter extends EventListener { |
| 506 final MIN_NUMBER_OF_TEMP_DIRS = 50; | 507 /// The minimum number of left over temp directories that is considered |
| 508 /// excessive and causes a warning to be shown. | |
| 509 static const _excessiveCount = 50; | |
| 507 | 510 |
| 508 static RegExp _getTemporaryDirectoryRegexp() { | 511 static RegExp get _tempDirPattern { |
| 509 // These are the patterns of temporary directory names created by | 512 // These are the patterns of temporary directory names created by |
| 510 // 'Directory.systemTemp.createTemp()' on linux/macos and windows. | 513 // 'Directory.systemTemp.createTemp()' on linux/macos and windows. |
| 511 if (['macos', 'linux'].contains(Platform.operatingSystem)) { | 514 if (['macos', 'linux'].contains(Platform.operatingSystem)) { |
| 512 return new RegExp(r'^temp_dir1_......$'); | 515 return new RegExp(r'^temp_dir1_......$'); |
| 513 } else { | 516 } else { |
| 514 return new RegExp(r'tempdir-........-....-....-....-............$'); | 517 return new RegExp(r'tempdir-........-....-....-....-............$'); |
| 515 } | 518 } |
| 516 } | 519 } |
| 517 | 520 |
| 518 static Stream<FileSystemEntity> getLeftOverTemporaryDirectories() { | 521 /// Returns a stream of all of the apparently Dart-created temp directories. |
| 519 var regExp = _getTemporaryDirectoryRegexp(); | 522 static Iterable<Directory> list() { |
| 520 return Directory.systemTemp.list().where((FileSystemEntity fse) { | 523 return Directory.systemTemp |
| 521 if (fse is Directory) { | 524 .listSync() |
| 522 if (regExp.hasMatch(new Path(fse.path).filename)) { | 525 .where((FileSystemEntity entity) => |
| 523 return true; | 526 entity is Directory && |
| 524 } | 527 _tempDirPattern.hasMatch(new Path(entity.path).filename)) |
| 528 .map((entity) => entity as Directory); | |
| 529 } | |
| 530 | |
| 531 /// Attempts to delete all Dart-created temp directories. | |
| 532 /// | |
| 533 /// If any deletion fails, logs it and continues to delete others. | |
| 534 static void deleteAll() { | |
| 535 for (var directory in LeftOverTempDirPrinter.list()) { | |
| 536 try { | |
| 537 directory.deleteSync(recursive: true); | |
| 538 } catch (error) { | |
| 539 DebugLogger.error(error); | |
| 525 } | 540 } |
| 526 return false; | 541 } |
| 527 }); | |
| 528 } | 542 } |
| 529 | 543 |
| 530 void allDone() { | 544 void allDone() { |
|
Bill Hesse
2017/05/02 14:33:09
Could you try to locally test this code, by adding
Bob Nystrom
2017/05/02 23:48:15
Uh, now that you mention it, no, it does not seem
| |
| 531 getLeftOverTemporaryDirectories().length.then((int count) { | 545 try { |
| 532 if (count > MIN_NUMBER_OF_TEMP_DIRS) { | 546 var count = list().length; |
| 533 DebugLogger.warning("There are ${count} directories " | 547 if (count > _excessiveCount) { |
| 534 "in the system tempdir " | 548 DebugLogger |
| 535 "('${Directory.systemTemp.path}')! " | 549 .warning("There are $count directories in the system tempdir " |
| 536 "Maybe left over directories?\n"); | 550 "('${Directory.systemTemp.path}'). " |
| 551 "Maybe left over directories?\n"); | |
| 537 } | 552 } |
| 538 }).catchError((error) { | 553 } catch (error) { |
| 539 DebugLogger.warning("Could not list temp directories, got: $error"); | 554 DebugLogger.warning("Could not list temp directories, got: $error"); |
| 540 }); | 555 } |
| 541 } | 556 } |
| 542 } | 557 } |
| 543 | 558 |
| 544 class LineProgressIndicator extends EventListener { | 559 class LineProgressIndicator extends EventListener { |
| 545 void done(TestCase test) { | 560 void done(TestCase test) { |
| 546 var status = 'pass'; | 561 var status = 'pass'; |
| 547 if (test.unexpectedOutput) { | 562 if (test.unexpectedOutput) { |
| 548 status = 'fail'; | 563 status = 'fail'; |
| 549 } | 564 } |
| 550 print('Done ${test.configurationString} ${test.displayName}: $status'); | 565 print('Done ${test.configurationString} ${test.displayName}: $status'); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 717 return new VerboseProgressIndicator(startTime); | 732 return new VerboseProgressIndicator(startTime); |
| 718 case 'status': | 733 case 'status': |
| 719 return new ProgressIndicator(startTime); | 734 return new ProgressIndicator(startTime); |
| 720 case 'buildbot': | 735 case 'buildbot': |
| 721 return new BuildbotProgressIndicator(startTime); | 736 return new BuildbotProgressIndicator(startTime); |
| 722 default: | 737 default: |
| 723 assert(false); | 738 assert(false); |
| 724 return null; | 739 return null; |
| 725 } | 740 } |
| 726 } | 741 } |
| OLD | NEW |