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

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

Issue 1668573003: Add configuration support for choosing test paths. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 4 years, 10 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
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 import 'dart:io'; 5 import 'dart:io';
6 6
7 import 'package:glob/glob.dart';
7 import 'package:path/path.dart' as p; 8 import 'package:path/path.dart' as p;
8 9
9 import '../frontend/timeout.dart'; 10 import '../frontend/timeout.dart';
10 import '../backend/metadata.dart'; 11 import '../backend/metadata.dart';
11 import '../backend/test_platform.dart'; 12 import '../backend/test_platform.dart';
12 import '../util/io.dart'; 13 import '../util/io.dart';
13 import 'configuration/args.dart' as args; 14 import 'configuration/args.dart' as args;
14 import 'configuration/load.dart'; 15 import 'configuration/load.dart';
15 import 'configuration/values.dart'; 16 import 'configuration/values.dart';
16 17
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 pauseAfterLoad ? 1 : (_concurrency ?? defaultConcurrency); 69 pauseAfterLoad ? 1 : (_concurrency ?? defaultConcurrency);
69 final int _concurrency; 70 final int _concurrency;
70 71
71 /// The paths from which to load tests. 72 /// The paths from which to load tests.
72 List<String> get paths => _paths ?? ["test"]; 73 List<String> get paths => _paths ?? ["test"];
73 final List<String> _paths; 74 final List<String> _paths;
74 75
75 /// Whether the load paths were passed explicitly or the default was used. 76 /// Whether the load paths were passed explicitly or the default was used.
76 bool get explicitPaths => _paths != null; 77 bool get explicitPaths => _paths != null;
77 78
79 /// The glob matching the basename of tests to run.
80 ///
81 /// This is used to find tests within a directory.
82 Glob get filename => _filename ?? new Glob("*_test.dart");
83 final Glob _filename;
84
78 /// The pattern to match against test names to decide which to run, or `null` 85 /// The pattern to match against test names to decide which to run, or `null`
79 /// if all tests should be run. 86 /// if all tests should be run.
80 final Pattern pattern; 87 final Pattern pattern;
81 88
82 /// The set of platforms on which to run tests. 89 /// The set of platforms on which to run tests.
83 List<TestPlatform> get platforms => _platforms ?? [TestPlatform.vm]; 90 List<TestPlatform> get platforms => _platforms ?? [TestPlatform.vm];
84 final List<TestPlatform> _platforms; 91 final List<TestPlatform> _platforms;
85 92
86 /// Restricts the set of tests to a set of tags. 93 /// Restricts the set of tests to a set of tags.
87 /// 94 ///
(...skipping 22 matching lines...) Expand all
110 /// Loads the configuration from [path]. 117 /// Loads the configuration from [path].
111 /// 118 ///
112 /// Throws an [IOException] if [path] does not exist or cannot be read. Throws 119 /// Throws an [IOException] if [path] does not exist or cannot be read. Throws
113 /// a [FormatException] if its contents are invalid. 120 /// a [FormatException] if its contents are invalid.
114 factory Configuration.load(String path) => load(path); 121 factory Configuration.load(String path) => load(path);
115 122
116 Configuration({bool help, bool version, bool verboseTrace, bool jsTrace, 123 Configuration({bool help, bool version, bool verboseTrace, bool jsTrace,
117 bool pauseAfterLoad, bool color, String packageRoot, String reporter, 124 bool pauseAfterLoad, bool color, String packageRoot, String reporter,
118 int pubServePort, int concurrency, Timeout timeout, this.pattern, 125 int pubServePort, int concurrency, Timeout timeout, this.pattern,
119 Iterable<TestPlatform> platforms, Iterable<String> paths, 126 Iterable<TestPlatform> platforms, Iterable<String> paths,
120 Iterable<String> tags, Iterable<String> excludeTags}) 127 Glob filename, Iterable<String> tags, Iterable<String> excludeTags})
121 : _help = help, 128 : _help = help,
122 _version = version, 129 _version = version,
123 _verboseTrace = verboseTrace, 130 _verboseTrace = verboseTrace,
124 _jsTrace = jsTrace, 131 _jsTrace = jsTrace,
125 _pauseAfterLoad = pauseAfterLoad, 132 _pauseAfterLoad = pauseAfterLoad,
126 _color = color, 133 _color = color,
127 _packageRoot = packageRoot, 134 _packageRoot = packageRoot,
128 _reporter = reporter, 135 _reporter = reporter,
129 pubServeUrl = pubServePort == null 136 pubServeUrl = pubServePort == null
130 ? null 137 ? null
131 : Uri.parse("http://localhost:$pubServePort"), 138 : Uri.parse("http://localhost:$pubServePort"),
132 _concurrency = concurrency, 139 _concurrency = concurrency,
133 timeout = (pauseAfterLoad ?? false) 140 timeout = (pauseAfterLoad ?? false)
134 ? Timeout.none 141 ? Timeout.none
135 : (timeout == null ? new Timeout.factor(1) : timeout), 142 : (timeout == null ? new Timeout.factor(1) : timeout),
136 _platforms = _list(platforms), 143 _platforms = _list(platforms),
137 _paths = _list(paths), 144 _paths = _list(paths),
145 _filename = filename,
kevmoo 2016/02/04 17:50:05 Set the final field here instead of doing the null
nweiz 2016/02/04 20:06:47 It's important to be able to differentiate between
138 tags = tags?.toSet() ?? new Set(), 146 tags = tags?.toSet() ?? new Set(),
139 excludeTags = excludeTags?.toSet() ?? new Set(); 147 excludeTags = excludeTags?.toSet() ?? new Set() {
148 if (_filename != null && _filename.context.style != p.style) {
149 throw new ArgumentError(
150 "filename's context must match the current operating system, was "
151 "${_filename.context.style}.");
152 }
153 }
140 154
141 /// Returns a [input] as a list or `null`. 155 /// Returns a [input] as a list or `null`.
142 /// 156 ///
143 /// If [input] is `null` or empty, this returns `null`. Otherwise, it returns 157 /// If [input] is `null` or empty, this returns `null`. Otherwise, it returns
144 /// `input.toList()`. 158 /// `input.toList()`.
145 static List _list(Iterable input) { 159 static List _list(Iterable input) {
146 if (input == null) return null; 160 if (input == null) return null;
147 input = input.toList(); 161 input = input.toList();
148 if (input.isEmpty) return null; 162 if (input.isEmpty) return null;
149 return input; 163 return input;
(...skipping 12 matching lines...) Expand all
162 pauseAfterLoad: other._pauseAfterLoad ?? _pauseAfterLoad, 176 pauseAfterLoad: other._pauseAfterLoad ?? _pauseAfterLoad,
163 color: other._color ?? _color, 177 color: other._color ?? _color,
164 packageRoot: other._packageRoot ?? _packageRoot, 178 packageRoot: other._packageRoot ?? _packageRoot,
165 reporter: other._reporter ?? _reporter, 179 reporter: other._reporter ?? _reporter,
166 pubServePort: (other.pubServeUrl ?? pubServeUrl)?.port, 180 pubServePort: (other.pubServeUrl ?? pubServeUrl)?.port,
167 concurrency: other._concurrency ?? _concurrency, 181 concurrency: other._concurrency ?? _concurrency,
168 timeout: timeout.merge(other.timeout), 182 timeout: timeout.merge(other.timeout),
169 pattern: other.pattern ?? pattern, 183 pattern: other.pattern ?? pattern,
170 platforms: other._platforms ?? _platforms, 184 platforms: other._platforms ?? _platforms,
171 paths: other._paths ?? _paths, 185 paths: other._paths ?? _paths,
186 filename: other._filename ?? _filename,
172 tags: other.tags.union(tags), 187 tags: other.tags.union(tags),
173 excludeTags: other.excludeTags.union(excludeTags)); 188 excludeTags: other.excludeTags.union(excludeTags));
174 } 189 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698