Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: tools/testing/dart/test_progress.dart

Issue 23714002: test.py: Print the warning about left-over dirs only for directories created using Directory.create… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/test_progress.dart
diff --git a/tools/testing/dart/test_progress.dart b/tools/testing/dart/test_progress.dart
index 104f88c788ff84d115376ee24693b1a646369932..abba2c9ae00913c14c43ec505db11c0c8efd108f 100644
--- a/tools/testing/dart/test_progress.dart
+++ b/tools/testing/dart/test_progress.dart
@@ -4,6 +4,7 @@
library test_progress;
+import "dart:async";
import "dart:io";
import "dart:io" as io;
import "http_server.dart" as http_server;
@@ -327,30 +328,47 @@ class SkippedCompilationsPrinter extends EventListener {
class LeftOverTempDirPrinter extends EventListener {
final MIN_NUMBER_OF_TEMP_DIRS = 50;
- Path _tempDir() {
+ static Directory _getTemporaryDirectory() {
// Dir will be located in the system temporary directory.
var dir = new Directory('').createTempSync();
var path = new Path(dir.path).directoryPath;
dir.deleteSync();
- return path;
+ return new Directory(path.toNativePath());
}
- void allDone() {
- var count = 0;
- var systemTempDir = _tempDir();
- var lister = new Directory(systemTempDir.toNativePath()).list().listen(
+ static RegExp _getTemporaryDirectoryRegexp() {
+ // These are the patterns of temporary directory names created by
+ // 'Directory.createTempSync()' on linux/macos and windows.
+ if (['macos', 'linux'].contains(Platform.operatingSystem)) {
+ return new RegExp(r'^temp_dir1_......$');
+ } else {
+ return new RegExp(r'tempdir-........-....-....-....-............$');
+ }
+ }
+
+ static Stream<Directory> getLeftOverTemporaryDirectories() {
+ var regExp = _getTemporaryDirectoryRegexp();
+ return _getTemporaryDirectory().list().where(
(FileSystemEntity fse) {
- if (fse is Directory) count++;
- },
- onError: (error) {
- DebugLogger.warning("Could not list temp directories, got: $error");
- },
- onDone: () {
- if (count > MIN_NUMBER_OF_TEMP_DIRS) {
- DebugLogger.warning("There are ${count} directories "
- "in the system tempdir ('$systemTempDir')! "
- "Maybe left over directories?\n");
+ if (fse is Directory) {
+ if (regExp.hasMatch(new Path(fse.path).filename)) {
+ return true;
+ }
+ }
+ return false;
+ });
+ }
+
+ void allDone() {
+ getLeftOverTemporaryDirectories().length.then((int count) {
+ if (count > MIN_NUMBER_OF_TEMP_DIRS) {
+ DebugLogger.warning("There are ${count} directories "
+ "in the system tempdir "
+ "('${_getTemporaryDirectory().path}')! "
+ "Maybe left over directories?\n");
}
+ }).catchError((error) {
+ DebugLogger.warning("Could not list temp directories, got: $error");
});
}
}
« no previous file with comments | « tools/test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698