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

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..75c185d548191128c9d95f9a95486ddf3e6f85a8 100755
--- a/tools/test.dart
+++ b/tools/test.dart
@@ -232,11 +232,49 @@ 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') {
ahe 2013/04/17 15:08:13 if (environment['DART_TESTING_DELETE_TEMPORARY_DIR
kustermann 2013/04/18 09:24:08 Unfortunatly, I saw that comment too late. I commi
+ Directory getTempDir() {
+ // dir will be located in the system temporary directory.
+ var dir = new Directory('').createTempSync();
ahe 2013/04/17 15:08:13 I don't understand why it is OK to use synchronous
kustermann 2013/04/18 09:24:08 I don't understand why we have to use async API he
ahe 2013/04/18 09:26:44 Why are you using async API then? Why does delete
+ 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) {}
ricow1 2013/04/15 13:35:47 maybe print this to our debug log?
kustermann 2013/04/17 14:04:49 I can do it, but then people will get these messag
ahe 2013/04/17 15:08:13 Never ever catch all exceptions and ignore them :-
kustermann 2013/04/18 09:24:08 I added a DebugLogger.error() statment now.
+ }
+ }
+ }, onDone: completer.complete(null));
ricow1 2013/04/15 13:35:47 don't give argument to complete
kustermann 2013/04/17 14:04:49 Done.
+ } else {
+ completer.complete(null);
ricow1 2013/04/15 13:35:47 no need to return null here
kustermann 2013/04/17 14:04:49 Done.
}
+ return completer.future;
+}
+
+void main() {
+ deleteTemporaryDartDirectories().then((_) {
ricow1 2013/04/15 13:35:47 remove argument in closure
kustermann 2013/04/17 14:04:49 Future.then takes a closure with exactly one argum
ricow1 2013/04/18 07:07:59 Yes that is true
+ 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