Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: lib/src/runner/configuration.dart

Issue 1264393004: Pass Configuration to Loader and Server. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/runner/browser/server.dart ('k') | lib/src/runner/loader.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library test.runner.configuration; 5 library test.runner.configuration;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'package:args/args.dart'; 10 import 'package:args/args.dart';
11 import 'package:path/path.dart' as p; 11 import 'package:path/path.dart' as p;
12 12
13 import '../frontend/timeout.dart'; 13 import '../frontend/timeout.dart';
14 import '../backend/metadata.dart';
14 import '../backend/test_platform.dart'; 15 import '../backend/test_platform.dart';
15 import '../util/io.dart'; 16 import '../util/io.dart';
16 17
17 /// The default number of test suites to run at once. 18 /// The default number of test suites to run at once.
18 /// 19 ///
19 /// This defaults to half the available processors, since presumably some of 20 /// This defaults to half the available processors, since presumably some of
20 /// them will be used for the OS and other processes. 21 /// them will be used for the OS and other processes.
21 final _defaultConcurrency = math.max(1, Platform.numberOfProcessors ~/ 2); 22 final _defaultConcurrency = math.max(1, Platform.numberOfProcessors ~/ 2);
22 23
23 /// A class that encapsulates the command-line configuration of the test runner. 24 /// A class that encapsulates the command-line configuration of the test runner.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 /// Whether the load paths were passed explicitly or the default was used. 124 /// Whether the load paths were passed explicitly or the default was used.
124 final bool explicitPaths; 125 final bool explicitPaths;
125 126
126 /// The pattern to match against test names to decide which to run, or `null` 127 /// The pattern to match against test names to decide which to run, or `null`
127 /// if all tests should be run. 128 /// if all tests should be run.
128 final Pattern pattern; 129 final Pattern pattern;
129 130
130 /// The set of platforms on which to run tests. 131 /// The set of platforms on which to run tests.
131 final List<TestPlatform> platforms; 132 final List<TestPlatform> platforms;
132 133
134 /// The global test metadata derived from this configuration.
135 Metadata get metadata =>
136 new Metadata(
137 timeout: pauseAfterLoad ? Timeout.none : null,
138 verboseTrace: verboseTrace);
139
133 /// Parses the configuration from [args]. 140 /// Parses the configuration from [args].
134 /// 141 ///
135 /// Throws a [FormatException] if [args] are invalid. 142 /// Throws a [FormatException] if [args] are invalid.
136 factory Configuration.parse(List<String> args) { 143 factory Configuration.parse(List<String> args) {
137 var options = _parser.parse(args); 144 var options = _parser.parse(args);
138 145
139 var pattern; 146 var pattern;
140 if (options['name'] != null) { 147 if (options['name'] != null) {
141 if (options["plain-name"] != null) { 148 if (options["plain-name"] != null) {
142 throw new FormatException( 149 throw new FormatException(
(...skipping 12 matching lines...) Expand all
155 verboseTrace: options['verbose-trace'], 162 verboseTrace: options['verbose-trace'],
156 jsTrace: options['js-trace'], 163 jsTrace: options['js-trace'],
157 pauseAfterLoad: options['pause-after-load'], 164 pauseAfterLoad: options['pause-after-load'],
158 color: options['color'], 165 color: options['color'],
159 packageRoot: options['package-root'], 166 packageRoot: options['package-root'],
160 reporter: options['reporter'], 167 reporter: options['reporter'],
161 pubServePort: _wrapFormatException(options, 'pub-serve', int.parse), 168 pubServePort: _wrapFormatException(options, 'pub-serve', int.parse),
162 concurrency: _wrapFormatException(options, 'concurrency', int.parse, 169 concurrency: _wrapFormatException(options, 'concurrency', int.parse,
163 orElse: () => _defaultConcurrency), 170 orElse: () => _defaultConcurrency),
164 pattern: pattern, 171 pattern: pattern,
165 platforms: options['platforms'].map(TestPlatform.find).toList(), 172 platforms: options['platform'].map(TestPlatform.find),
166 paths: options.rest.isEmpty ? null : options.rest); 173 paths: options.rest.isEmpty ? null : options.rest);
167 } 174 }
168 175
169 /// Runs [parse] on the value of the option [name], and wraps any 176 /// Runs [parse] on the value of the option [name], and wraps any
170 /// [FormatException] it throws with additional information. 177 /// [FormatException] it throws with additional information.
171 static _wrapFormatException(ArgResults options, String name, parse(value), 178 static _wrapFormatException(ArgResults options, String name, parse(value),
172 {orElse()}) { 179 {orElse()}) {
173 var value = options[name]; 180 var value = options[name];
174 if (value == null) return orElse == null ? null : orElse(); 181 if (value == null) return orElse == null ? null : orElse();
175 182
(...skipping 15 matching lines...) Expand all
191 packageRoot = packageRoot == null 198 packageRoot = packageRoot == null
192 ? p.join(p.current, 'packages') 199 ? p.join(p.current, 'packages')
193 : packageRoot, 200 : packageRoot,
194 reporter = reporter == null ? 'compact' : reporter, 201 reporter = reporter == null ? 'compact' : reporter,
195 pubServeUrl = pubServePort == null 202 pubServeUrl = pubServePort == null
196 ? null 203 ? null
197 : Uri.parse("http://localhost:$pubServePort"), 204 : Uri.parse("http://localhost:$pubServePort"),
198 concurrency = pauseAfterLoad 205 concurrency = pauseAfterLoad
199 ? 1 206 ? 1
200 : (concurrency == null ? _defaultConcurrency : concurrency), 207 : (concurrency == null ? _defaultConcurrency : concurrency),
201 platforms = platforms.toList(), 208 platforms = platforms == null ? [TestPlatform.vm] : platforms.toList(),
202 paths = paths == null ? ["test"] : paths.toList(), 209 paths = paths == null ? ["test"] : paths.toList(),
203 explicitPaths = paths != null; 210 explicitPaths = paths != null;
204 } 211 }
OLDNEW
« no previous file with comments | « lib/src/runner/browser/server.dart ('k') | lib/src/runner/loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698