OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 library testing.run_tests; | 5 library testing.run_tests; |
6 | 6 |
7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
8 | 8 |
9 import 'dart:io' show Directory, File, FileSystemEntity; | 9 import 'dart:io' show Directory, File, FileSystemEntity; |
10 | 10 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 return fail("Only one --config option is supported"); | 80 return fail("Only one --config option is supported"); |
81 } | 81 } |
82 String configurationPath; | 82 String configurationPath; |
83 if (configurationPaths.length == 1) { | 83 if (configurationPaths.length == 1) { |
84 configurationPath = configurationPaths.single; | 84 configurationPath = configurationPaths.single; |
85 } else { | 85 } else { |
86 configurationPath = "testing.json"; | 86 configurationPath = "testing.json"; |
87 if (!await new File(configurationPath).exists()) { | 87 if (!await new File(configurationPath).exists()) { |
88 Directory test = new Directory("test"); | 88 Directory test = new Directory("test"); |
89 if (await test.exists()) { | 89 if (await test.exists()) { |
90 List<FileSystemEntity> candiates = await test | 90 List<FileSystemEntity> candidates = await test |
91 .list(recursive: true, followLinks: false) | 91 .list(recursive: true, followLinks: false) |
92 .where((FileSystemEntity entity) { | 92 .where((FileSystemEntity entity) { |
93 return entity is File && entity.uri.path.endsWith("/testing.json"); | 93 return entity is File && entity.uri.path.endsWith("/testing.json"); |
94 }).toList(); | 94 }).toList(); |
95 switch (candiates.length) { | 95 switch (candidates.length) { |
96 case 0: | 96 case 0: |
97 return fail("Couldn't locate: '$configurationPath'."); | 97 return fail("Couldn't locate: '$configurationPath'."); |
98 | 98 |
99 case 1: | 99 case 1: |
100 configurationPath = candiates.single.path; | 100 configurationPath = candidates.single.path; |
101 break; | 101 break; |
102 | 102 |
103 default: | 103 default: |
104 return fail( | 104 return fail( |
105 "Usage: run_tests.dart [$configPrefix=configuration_file]\n" | 105 "Usage: run_tests.dart [$configPrefix=configuration_file]\n" |
106 "Where configuration_file is one of:\n " | 106 "Where configuration_file is one of:\n " |
107 "${candiates.map((file) => file.path).join('\n ')}"); | 107 "${candidates.map((file) => file.path).join('\n ')}"); |
108 } | 108 } |
109 } | 109 } |
110 } | 110 } |
111 } | 111 } |
112 logMessage("Reading configuration file '$configurationPath'."); | 112 logMessage("Reading configuration file '$configurationPath'."); |
113 Uri configuration = | 113 Uri configuration = |
114 await Isolate.resolvePackageUri(Uri.base.resolve(configurationPath)); | 114 await Isolate.resolvePackageUri(Uri.base.resolve(configurationPath)); |
115 if (configuration == null || | 115 if (configuration == null || |
116 !await new File.fromUri(configuration).exists()) { | 116 !await new File.fromUri(configuration).exists()) { |
117 return fail("Couldn't locate: '$configurationPath'."); | 117 return fail("Couldn't locate: '$configurationPath'."); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 }, printLineOnStdout: sb.writeln); | 179 }, printLineOnStdout: sb.writeln); |
180 logMessage(sb); | 180 logMessage(sb); |
181 } catch (e) { | 181 } catch (e) { |
182 print(sb); | 182 print(sb); |
183 rethrow; | 183 rethrow; |
184 } | 184 } |
185 logTestComplete(++completed, 0, tests.length, null, null); | 185 logTestComplete(++completed, 0, tests.length, null, null); |
186 } | 186 } |
187 logSuiteComplete(); | 187 logSuiteComplete(); |
188 }); | 188 }); |
OLD | NEW |