| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:io'; | 5 import 'dart:io'; |
| 6 | 6 |
| 7 import 'package:path/path.dart' as p; | 7 import 'package:path/path.dart' as p; |
| 8 | 8 |
| 9 /// True if the file system should be left untouched. | 9 /// True if the file system should be left untouched. |
| 10 bool dryRun = false; | 10 bool dryRun = false; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 return; | 41 return; |
| 42 } | 42 } |
| 43 | 43 |
| 44 new File(p.join(testRoot, path)).deleteSync(); | 44 new File(p.join(testRoot, path)).deleteSync(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 /// Returns a list of the paths to all files within [dir], which is | 47 /// Returns a list of the paths to all files within [dir], which is |
| 48 /// assumed to be relative to the SDK's "tests" directory and having file | 48 /// assumed to be relative to the SDK's "tests" directory and having file |
| 49 /// [extension]. | 49 /// [extension]. |
| 50 Iterable<String> listFiles(String dir, {String extension = ".dart"}) { | 50 Iterable<String> listFiles(String dir, {String extension = ".dart"}) { |
| 51 return new Directory(p.join(testRoot, dir)) | 51 try { |
| 52 .listSync(recursive: true) | 52 return new Directory(p.join(testRoot, dir)) |
| 53 .map((entry) { | 53 .listSync(recursive: true) |
| 54 if (!entry.path.endsWith(extension)) return null; | 54 .map((entry) { |
| 55 | 55 if (!entry.path.endsWith(extension)) return null; |
| 56 return entry.path; | 56 return entry.path; |
| 57 }).where((path) => path != null); | 57 }).where((path) => path != null); |
| 58 } catch (FileSystemException) { |
| 59 return []; |
| 60 } |
| 58 } | 61 } |
| OLD | NEW |