OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
6 * Classes and methods for enumerating and preparing tests. | 6 * Classes and methods for enumerating and preparing tests. |
7 * | 7 * |
8 * This library includes: | 8 * This library includes: |
9 * | 9 * |
10 * - Creating tests by listing all the Dart files in certain directories, | 10 * - Creating tests by listing all the Dart files in certain directories, |
11 * and creating [TestCase]s for those files that meet the relevant criteria. | 11 * and creating [TestCase]s for those files that meet the relevant criteria. |
12 * - Preparing tests, including copying files and frameworks to temporary | 12 * - Preparing tests, including copying files and frameworks to temporary |
13 * directories, and computing the command line and arguments to be run. | 13 * directories, and computing the command line and arguments to be run. |
14 */ | 14 */ |
15 library test_suite; | 15 library test_suite; |
16 | 16 |
17 import "dart:async"; | 17 import "dart:async"; |
18 import "dart:io"; | 18 import "dart:io"; |
| 19 import "dart:math"; |
19 import "drt_updater.dart"; | 20 import "drt_updater.dart"; |
20 import "html_test.dart" as htmlTest; | 21 import "html_test.dart" as htmlTest; |
21 import "path.dart"; | 22 import "path.dart"; |
22 import "multitest.dart"; | 23 import "multitest.dart"; |
23 import "status_file_parser.dart"; | 24 import "status_file_parser.dart"; |
24 import "summary_report.dart"; | 25 import "summary_report.dart"; |
25 import "test_runner.dart"; | 26 import "test_runner.dart"; |
26 import "utils.dart"; | 27 import "utils.dart"; |
27 import "http_server.dart" show PREFIX_BUILDDIR, PREFIX_DARTDIR; | 28 import "http_server.dart" show PREFIX_BUILDDIR, PREFIX_DARTDIR; |
28 | 29 |
(...skipping 2113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2142 | 2143 |
2143 class TestUtils { | 2144 class TestUtils { |
2144 /** | 2145 /** |
2145 * Any script using TestUtils must set dartDirUri to a file:// URI | 2146 * Any script using TestUtils must set dartDirUri to a file:// URI |
2146 * pointing to the root of the Dart checkout. | 2147 * pointing to the root of the Dart checkout. |
2147 */ | 2148 */ |
2148 static setDartDirUri(uri) { | 2149 static setDartDirUri(uri) { |
2149 dartDirUri = uri; | 2150 dartDirUri = uri; |
2150 dartDir = new Path(uri.toFilePath()); | 2151 dartDir = new Path(uri.toFilePath()); |
2151 } | 2152 } |
| 2153 static Random rand = new Random.secure(); |
2152 static Uri dartDirUri; | 2154 static Uri dartDirUri; |
2153 static Path dartDir; | 2155 static Path dartDir; |
2154 static LastModifiedCache lastModifiedCache = new LastModifiedCache(); | 2156 static LastModifiedCache lastModifiedCache = new LastModifiedCache(); |
2155 static ExistsCache existsCache = new ExistsCache(); | 2157 static ExistsCache existsCache = new ExistsCache(); |
2156 static Path currentWorkingDirectory = | 2158 static Path currentWorkingDirectory = |
2157 new Path(Directory.current.path); | 2159 new Path(Directory.current.path); |
2158 | 2160 |
2159 /** | 2161 /** |
| 2162 * Generates a random number. |
| 2163 */ |
| 2164 static int getRandomNumber() { |
| 2165 return rand.nextInt(0xffffffff); |
| 2166 } |
| 2167 |
| 2168 /** |
2160 * Creates a directory using a [relativePath] to an existing | 2169 * Creates a directory using a [relativePath] to an existing |
2161 * [base] directory if that [relativePath] does not already exist. | 2170 * [base] directory if that [relativePath] does not already exist. |
2162 */ | 2171 */ |
2163 static Directory mkdirRecursive(Path base, Path relativePath) { | 2172 static Directory mkdirRecursive(Path base, Path relativePath) { |
2164 if (relativePath.isAbsolute) { | 2173 if (relativePath.isAbsolute) { |
2165 base = new Path('/'); | 2174 base = new Path('/'); |
2166 } | 2175 } |
2167 Directory dir = new Directory(base.toNativePath()); | 2176 Directory dir = new Directory(base.toNativePath()); |
2168 assert(dir.existsSync()); | 2177 assert(dir.existsSync()); |
2169 var segments = relativePath.segments(); | 2178 var segments = relativePath.segments(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2225 throw new Exception('Can\'t delete path $native_path. ' | 2234 throw new Exception('Can\'t delete path $native_path. ' |
2226 'This path might be too long'); | 2235 'This path might be too long'); |
2227 } | 2236 } |
2228 }); | 2237 }); |
2229 } else { | 2238 } else { |
2230 var dir = new Directory(path); | 2239 var dir = new Directory(path); |
2231 return dir.delete(recursive: true); | 2240 return dir.delete(recursive: true); |
2232 } | 2241 } |
2233 } | 2242 } |
2234 | 2243 |
| 2244 static deleteTempSnapshotDirectory(Map configuration) { |
| 2245 if (configuration['compiler'] == 'dart2app') { |
| 2246 var checked = configuration['checked'] ? '-checked' : ''; |
| 2247 var minified = configuration['minified'] ? '-minified' : ''; |
| 2248 var csp = configuration['csp'] ? '-csp' : ''; |
| 2249 var sdk = configuration['use_sdk'] ? '-sdk' : ''; |
| 2250 var packages = configuration['use_public_packages'] |
| 2251 ? '-public_packages' : ''; |
| 2252 var dirName = "${configuration['compiler']}" |
| 2253 "$checked$minified$csp$packages$sdk"; |
| 2254 String generatedPath = "${TestUtils.buildDir(configuration)}" |
| 2255 "/generated_compilations/$dirName"; |
| 2256 TestUtils.deleteDirectory(generatedPath); |
| 2257 } |
| 2258 } |
| 2259 |
2235 static Path debugLogfile() { | 2260 static Path debugLogfile() { |
2236 return new Path(".debug.log"); | 2261 return new Path(".debug.log"); |
2237 } | 2262 } |
2238 | 2263 |
2239 static String flakyFileName() { | 2264 static String flakyFileName() { |
2240 // If a flaky test did fail, infos about it (i.e. test name, stdin, stdout) | 2265 // If a flaky test did fail, infos about it (i.e. test name, stdin, stdout) |
2241 // will be written to this file. This is useful for the debugging of | 2266 // will be written to this file. This is useful for the debugging of |
2242 // flaky tests. | 2267 // flaky tests. |
2243 // When running on a built bot, the file can be made visible in the | 2268 // When running on a built bot, the file can be made visible in the |
2244 // waterfall UI. | 2269 // waterfall UI. |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2474 for (var key in PATH_REPLACEMENTS.keys) { | 2499 for (var key in PATH_REPLACEMENTS.keys) { |
2475 if (path.startsWith(key)) { | 2500 if (path.startsWith(key)) { |
2476 path = path.replaceFirst(key, PATH_REPLACEMENTS[key]); | 2501 path = path.replaceFirst(key, PATH_REPLACEMENTS[key]); |
2477 break; | 2502 break; |
2478 } | 2503 } |
2479 } | 2504 } |
2480 } | 2505 } |
2481 return path; | 2506 return path; |
2482 } | 2507 } |
2483 } | 2508 } |
OLD | NEW |