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

Unified Diff: tools/test.dart

Issue 14244009: Support for removing left over temporary directories from dart processes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/test.dart
diff --git a/tools/test.dart b/tools/test.dart
index 1d78bbccd3bd9b908f2ce904ac43ef594367bcc2..354c79461cf4a04b2b1e5f9cf3c1a5c54dbb9139 100755
--- a/tools/test.dart
+++ b/tools/test.dart
@@ -232,11 +232,51 @@ void testConfigurations(List<Map> configurations) {
}
}
-void main() {
- var optionsParser = new TestOptionsParser();
- var configurations = optionsParser.parse(new Options().arguments);
- if (configurations != null && configurations.length > 0) {
- testConfigurations(configurations);
+Future deleteTemporaryDartDirectories() {
+ var completer = new Completer();
+ var environment = Platform.environment;
+ if (environment['DART_TESTING_DELETE_TEMPORARY_DIRECTORIES'] == '1') {
+ Directory getTempDir() {
+ // dir will be located in the system temporary directory.
+ var dir = new Directory('').createTempSync();
+ var path = new Path(dir.path).directoryPath;
+ dir.deleteSync();
+ return new Directory.fromPath(path);
+ }
+
+ // These are the patterns of temporary directory names created by
+ // 'Directory.createTempSync()' on linux/macos and windows.
+ var regExp;
+ if (['macos', 'linux'].contains(Platform.operatingSystem)) {
+ regExp = new RegExp(r'^temp_dir1_......$');
+ } else {
+ regExp = new RegExp(r'tempdir-........-....-....-....-............$');
+ }
+
+ getTempDir().list().listen((directoryEntry) {
+ if (directoryEntry is Directory) {
+ if (regExp.hasMatch(new Path(directoryEntry.path).filename)) {
+ try {
+ directoryEntry.deleteSync(recursive: true);
+ } catch (error) {
+ DebugLogger.error(error);
+ }
+ }
+ }
+ }, onDone: completer.complete());
+ } else {
+ completer.complete();
}
+ return completer.future;
+}
+
+void main() {
+ deleteTemporaryDartDirectories().then((_) {
+ var optionsParser = new TestOptionsParser();
+ var configurations = optionsParser.parse(new Options().arguments);
+ if (configurations != null && configurations.length > 0) {
+ testConfigurations(configurations);
+ }
+ });
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698