Chromium Code Reviews| 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); |
| + } |
| + }); |
| } |