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 part of testrunner; | 5 part of testrunner; |
6 | 6 |
7 /** Create and return an options parser for the test runner. */ | 7 /** Create and return an options parser for the test runner. */ |
8 ArgParser getOptionParser() { | 8 ArgParser getOptionParser() { |
9 var parser = new ArgParser(); | 9 var parser = new ArgParser(); |
10 | 10 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 188 } |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
192 /** | 192 /** |
193 * Get the test runner configuration. This loads options from multiple | 193 * Get the test runner configuration. This loads options from multiple |
194 * sources, in increasing order of priority: a test.config file in the | 194 * sources, in increasing order of priority: a test.config file in the |
195 * current directory, a test config file specified with --configfile on | 195 * current directory, a test config file specified with --configfile on |
196 * the command line, and other arguments specified on the command line. | 196 * the command line, and other arguments specified on the command line. |
197 */ | 197 */ |
198 ArgResults loadConfiguration(optionsParser) { | 198 ArgResults loadConfiguration(optionsParser, List<String> commandLineArgs) { |
199 var options = new List(); | 199 var options = new List(); |
200 // We first load options from a test.config file in the working directory. | 200 // We first load options from a test.config file in the working directory. |
201 options.addAll(getFileContents('test.config', false). | 201 options.addAll(getFileContents('test.config', false). |
202 where((e) => e.trim().length > 0 && e[0] != '#')); | 202 where((e) => e.trim().length > 0 && e[0] != '#')); |
203 // Next we look to see if the command line included a -testconfig argument, | 203 // Next we look to see if the command line included a -testconfig argument, |
204 // and if so, load options from that file too; where these are not | 204 // and if so, load options from that file too; where these are not |
205 // multi-valued they will take precedence over the ones in test.config. | 205 // multi-valued they will take precedence over the ones in test.config. |
206 var commandLineArgs = new Options().arguments; | |
207 var cfgarg = '--configfile'; | 206 var cfgarg = '--configfile'; |
208 var cfgarge = '--configfile='; | 207 var cfgarge = '--configfile='; |
209 for (var i = 0; i < commandLineArgs.length; i++) { | 208 for (var i = 0; i < commandLineArgs.length; i++) { |
210 if (commandLineArgs[i].startsWith(cfgarg)) { | 209 if (commandLineArgs[i].startsWith(cfgarg)) { |
211 if (commandLineArgs[i] == cfgarg) { | 210 if (commandLineArgs[i] == cfgarg) { |
212 if (i == commandLineArgs.length - 1) { | 211 if (i == commandLineArgs.length - 1) { |
213 throw new Exception('Missing argument to $cfgarg'); | 212 throw new Exception('Missing argument to $cfgarg'); |
214 } | 213 } |
215 options.addAll(getFileContents(commandLineArgs[++i], true). | 214 options.addAll(getFileContents(commandLineArgs[++i], true). |
216 where((e) => e.trim().length > 0 && e[0] != '#')); | 215 where((e) => e.trim().length > 0 && e[0] != '#')); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 print('--include and --exclude are mutually exclusive.'); | 251 print('--include and --exclude are mutually exclusive.'); |
253 return false; | 252 return false; |
254 } | 253 } |
255 if ((config['layout-text'] || config['layout-pixel']) && | 254 if ((config['layout-text'] || config['layout-pixel']) && |
256 config['runtime'] == 'vm') { | 255 config['runtime'] == 'vm') { |
257 print('Layout tests must use --runtime values of "drt-dart" or "drt-js"'); | 256 print('Layout tests must use --runtime values of "drt-dart" or "drt-js"'); |
258 return false; | 257 return false; |
259 } | 258 } |
260 return true; | 259 return true; |
261 } | 260 } |
OLD | NEW |