| 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, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 * and a status file containing the expected results when these tests are run. | 124 * and a status file containing the expected results when these tests are run. |
| 125 */ | 125 */ |
| 126 abstract class TestSuite { | 126 abstract class TestSuite { |
| 127 final Map configuration; | 127 final Map configuration; |
| 128 final String suiteName; | 128 final String suiteName; |
| 129 // This function is set by subclasses before enqueueing starts. | 129 // This function is set by subclasses before enqueueing starts. |
| 130 Function doTest; | 130 Function doTest; |
| 131 Map<String, String> _environmentOverrides; | 131 Map<String, String> _environmentOverrides; |
| 132 | 132 |
| 133 TestSuite(this.configuration, this.suiteName) { | 133 TestSuite(this.configuration, this.suiteName) { |
| 134 _environmentOverrides = { | 134 if (configuration['build_directory'] == '') { |
| 135 _environmentOverrides = { |
| 135 'DART_CONFIGURATION' : TestUtils.configurationDir(configuration) | 136 'DART_CONFIGURATION' : TestUtils.configurationDir(configuration) |
| 136 }; | 137 }; |
| 138 } |
| 137 } | 139 } |
| 138 | 140 |
| 139 Map<String, String> get environmentOverrides => _environmentOverrides; | 141 Map<String, String> get environmentOverrides => _environmentOverrides; |
| 140 | 142 |
| 141 /** | 143 /** |
| 142 * Whether or not binaries should be found in the root build directory or | 144 * Whether or not binaries should be found in the root build directory or |
| 143 * in the built SDK. | 145 * in the built SDK. |
| 144 */ | 146 */ |
| 145 bool get useSdk { | 147 bool get useSdk { |
| 146 // The pub suite always uses the SDK. | 148 // The pub suite always uses the SDK. |
| (...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2258 // is relative to the current working directory. | 2260 // is relative to the current working directory. |
| 2259 // Thus, if we pass in an absolute path (e.g. '--build-directory=/tmp/out') | 2261 // Thus, if we pass in an absolute path (e.g. '--build-directory=/tmp/out') |
| 2260 // we get into trouble. | 2262 // we get into trouble. |
| 2261 if (configuration['build_directory'] != '') { | 2263 if (configuration['build_directory'] != '') { |
| 2262 return configuration['build_directory']; | 2264 return configuration['build_directory']; |
| 2263 } | 2265 } |
| 2264 | 2266 |
| 2265 return "${outputDir(configuration)}${configurationDir(configuration)}"; | 2267 return "${outputDir(configuration)}${configurationDir(configuration)}"; |
| 2266 } | 2268 } |
| 2267 | 2269 |
| 2268 static getValidOutputDir(Map configuration, String mode, String arch) { | 2270 static String configurationDir(Map configuration) { |
| 2271 // This returns the correct configuration directory (the last component |
| 2272 // of the output directory path) for regular dart checkouts. |
| 2273 // Do not call this function if the --build-directory option is used. |
| 2274 // Dartium checkouts use the --build-directory option to pass in the |
| 2275 // correct build directory explicitly. |
| 2269 // We allow our code to have been cross compiled, i.e., that there | 2276 // We allow our code to have been cross compiled, i.e., that there |
| 2270 // is an X in front of the arch. We don't allow both a cross compiled | 2277 // is an X in front of the arch. We don't allow both a cross compiled |
| 2271 // and a normal version to be present (except if you specifically pass | 2278 // and a normal version to be present (except if you specifically pass |
| 2272 // in the build_directory). | 2279 // in the build_directory). |
| 2280 if (configuration['build_directory'] != '') { |
| 2281 throw "Internal test.dart error: Don't call TestUtils.configurationDir " |
| 2282 "if the --build-directory option is used."; |
| 2283 } |
| 2284 var mode = (configuration['mode'] == 'debug') ? 'Debug' : 'Release'; |
| 2285 var arch = configuration['arch'].toUpperCase(); |
| 2273 var normal = '$mode$arch'; | 2286 var normal = '$mode$arch'; |
| 2274 var cross = '${mode}X$arch'; | 2287 var cross = '${mode}X$arch'; |
| 2275 var outDir = outputDir(configuration); | 2288 var outDir = outputDir(configuration); |
| 2276 var normalDir = new Directory(new Path('$outDir$normal').toNativePath()); | 2289 var normalDir = new Directory(new Path('$outDir$normal').toNativePath()); |
| 2277 var crossDir = new Directory(new Path('$outDir$cross').toNativePath()); | 2290 var crossDir = new Directory(new Path('$outDir$cross').toNativePath()); |
| 2278 if (normalDir.existsSync() && crossDir.existsSync()) { | 2291 if (normalDir.existsSync() && crossDir.existsSync()) { |
| 2279 throw "You can't have both $normalDir and $crossDir, we don't know which" | 2292 throw "You can't have both $normalDir and $crossDir, we don't know which" |
| 2280 " binary to use"; | 2293 " binary to use"; |
| 2281 } | 2294 } |
| 2282 if (crossDir.existsSync()) { | 2295 if (crossDir.existsSync()) { |
| 2283 return cross; | 2296 return cross; |
| 2284 } | 2297 } |
| 2285 return normal; | 2298 return normal; |
| 2286 } | 2299 } |
| 2287 | 2300 |
| 2288 static String configurationDir(Map configuration) { | |
| 2289 // For regular dart checkouts, the configDir by default is mode+arch. | |
| 2290 // For Dartium, the configDir by default is mode (as defined by the Chrome | |
| 2291 // build setup). We can detect this because in the dartium checkout, the | |
| 2292 // "output" directory is a sibling of the dart directory instead of a child. | |
| 2293 var mode = (configuration['mode'] == 'debug') ? 'Debug' : 'Release'; | |
| 2294 var arch = configuration['arch'].toUpperCase(); | |
| 2295 if (currentWorkingDirectory != dartDir) { | |
| 2296 return getValidOutputDir(configuration, mode, arch); | |
| 2297 } else { | |
| 2298 return mode; | |
| 2299 } | |
| 2300 } | |
| 2301 | |
| 2302 /** | 2301 /** |
| 2303 * Returns the path to the dart binary checked into the repo, used for | 2302 * Returns the path to the dart binary checked into the repo, used for |
| 2304 * bootstrapping test.dart. | 2303 * bootstrapping test.dart. |
| 2305 */ | 2304 */ |
| 2306 static Path get dartTestExecutable { | 2305 static Path get dartTestExecutable { |
| 2307 var path = '$dartDir/tools/testing/bin/' | 2306 var path = '$dartDir/tools/testing/bin/' |
| 2308 '${Platform.operatingSystem}/dart'; | 2307 '${Platform.operatingSystem}/dart'; |
| 2309 if (Platform.operatingSystem == 'windows') { | 2308 if (Platform.operatingSystem == 'windows') { |
| 2310 path = '$path.exe'; | 2309 path = '$path.exe'; |
| 2311 } | 2310 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2400 for (var key in PATH_REPLACEMENTS.keys) { | 2399 for (var key in PATH_REPLACEMENTS.keys) { |
| 2401 if (path.startsWith(key)) { | 2400 if (path.startsWith(key)) { |
| 2402 path = path.replaceFirst(key, PATH_REPLACEMENTS[key]); | 2401 path = path.replaceFirst(key, PATH_REPLACEMENTS[key]); |
| 2403 break; | 2402 break; |
| 2404 } | 2403 } |
| 2405 } | 2404 } |
| 2406 } | 2405 } |
| 2407 return path; | 2406 return path; |
| 2408 } | 2407 } |
| 2409 } | 2408 } |
| OLD | NEW |