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

Side by Side Diff: lib/test.dart

Issue 1405633004: feature: tag tests; choose tags on command line Base URL: git@github.com:yjbanov/test.git@tags
Patch Set: address comments Created 5 years 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/utils.dart ('k') | test/backend/declarer_test.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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; 5 library test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:path/path.dart' as p; 9 import 'package:path/path.dart' as p;
10 10
11 import 'src/backend/declarer.dart'; 11 import 'src/backend/declarer.dart';
12 import 'src/backend/test_platform.dart'; 12 import 'src/backend/test_platform.dart';
13 import 'src/frontend/timeout.dart'; 13 import 'src/frontend/timeout.dart';
14 import 'src/runner/engine.dart'; 14 import 'src/runner/engine.dart';
15 import 'src/runner/reporter/expanded.dart'; 15 import 'src/runner/reporter/expanded.dart';
16 import 'src/runner/runner_suite.dart'; 16 import 'src/runner/runner_suite.dart';
17 import 'src/runner/vm/environment.dart'; 17 import 'src/runner/vm/environment.dart';
18 import 'src/utils.dart'; 18 import 'src/utils.dart';
19 19
20 export 'package:matcher/matcher.dart'; 20 export 'package:matcher/matcher.dart';
21 21
22 export 'src/frontend/expect.dart'; 22 export 'src/frontend/expect.dart';
23 export 'src/frontend/expect_async.dart'; 23 export 'src/frontend/expect_async.dart';
24 export 'src/frontend/future_matchers.dart'; 24 export 'src/frontend/future_matchers.dart';
25 export 'src/frontend/on_platform.dart'; 25 export 'src/frontend/on_platform.dart';
26 export 'src/frontend/prints_matcher.dart'; 26 export 'src/frontend/prints_matcher.dart';
27 export 'src/frontend/skip.dart'; 27 export 'src/frontend/skip.dart';
28 export 'src/frontend/tags.dart';
28 export 'src/frontend/test_on.dart'; 29 export 'src/frontend/test_on.dart';
29 export 'src/frontend/throws_matcher.dart'; 30 export 'src/frontend/throws_matcher.dart';
30 export 'src/frontend/throws_matchers.dart'; 31 export 'src/frontend/throws_matchers.dart';
31 export 'src/frontend/timeout.dart'; 32 export 'src/frontend/timeout.dart';
32 33
33 /// The global declarer. 34 /// The global declarer.
34 /// 35 ///
35 /// This is used if a test file is run directly, rather than through the runner. 36 /// This is used if a test file is run directly, rather than through the runner.
36 Declarer _globalDeclarer; 37 Declarer _globalDeclarer;
37 38
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 /// "windows": new Timeout.factor(2), 106 /// "windows": new Timeout.factor(2),
106 /// "browser": [ 107 /// "browser": [
107 /// new Skip("TODO: add browser support"), 108 /// new Skip("TODO: add browser support"),
108 /// // This will be slow on browsers once it works on them. 109 /// // This will be slow on browsers once it works on them.
109 /// new Timeout.factor(2) 110 /// new Timeout.factor(2)
110 /// ] 111 /// ]
111 /// }); 112 /// });
112 /// 113 ///
113 /// If multiple platforms match, the annotations apply in order as through 114 /// If multiple platforms match, the annotations apply in order as through
114 /// they were in nested groups. 115 /// they were in nested groups.
115 void test(String description, body(), {String testOn, Timeout timeout, 116 void test(String description, body(),
116 skip, Map<String, dynamic> onPlatform, String tag, 117 {String testOn,
117 List<String> tags}) => _declarer.test(description, body, 118 Timeout timeout,
118 testOn: testOn, timeout: timeout, skip: skip, 119 skip,
119 onPlatform: onPlatform, tags: _deconvenienceTags(tag, tags)); 120 Map<String, dynamic> onPlatform,
121 tags}) =>
122 _declarer.test(description, body,
123 testOn: testOn,
124 timeout: timeout,
125 skip: skip,
126 onPlatform: onPlatform,
127 tags: tags);
120 128
121 /// Creates a group of tests. 129 /// Creates a group of tests.
122 /// 130 ///
123 /// A group's description is included in the descriptions of any tests or 131 /// A group's description is included in the descriptions of any tests or
124 /// sub-groups it contains. [setUp] and [tearDown] are also scoped to the 132 /// sub-groups it contains. [setUp] and [tearDown] are also scoped to the
125 /// containing group. 133 /// containing group.
126 /// 134 ///
127 /// If [testOn] is passed, it's parsed as a [platform selector][]; the test will 135 /// If [testOn] is passed, it's parsed as a [platform selector][]; the test will
128 /// only be run on matching platforms. 136 /// only be run on matching platforms.
129 /// 137 ///
(...skipping 20 matching lines...) Expand all
150 /// "windows": new Timeout.factor(2), 158 /// "windows": new Timeout.factor(2),
151 /// "browser": [ 159 /// "browser": [
152 /// new Skip("TODO: add browser support"), 160 /// new Skip("TODO: add browser support"),
153 /// // They'll be slow on browsers once it works on them. 161 /// // They'll be slow on browsers once it works on them.
154 /// new Timeout.factor(2) 162 /// new Timeout.factor(2)
155 /// ] 163 /// ]
156 /// }); 164 /// });
157 /// 165 ///
158 /// If multiple platforms match, the annotations apply in order as through 166 /// If multiple platforms match, the annotations apply in order as through
159 /// they were in nested groups. 167 /// they were in nested groups.
160 void group(String description, void body(), {String testOn, Timeout timeout, 168 void group(String description, void body(),
161 skip, Map<String, dynamic> onPlatform, String tag, 169 {String testOn,
162 List<String> tags}) => _declarer.group(description, body, 170 Timeout timeout,
163 testOn: testOn, timeout: timeout, skip: skip, 171 skip,
164 tags: _deconvenienceTags(tag, tags)); 172 Map<String, dynamic> onPlatform,
173 tags}) =>
174 _declarer.group(description, body,
175 testOn: testOn, timeout: timeout, skip: skip, tags: tags);
165 176
166 /// Registers a function to be run before tests. 177 /// Registers a function to be run before tests.
167 /// 178 ///
168 /// This function will be called before each test is run. [callback] may be 179 /// This function will be called before each test is run. [callback] may be
169 /// asynchronous; if so, it must return a [Future]. 180 /// asynchronous; if so, it must return a [Future].
170 /// 181 ///
171 /// If this is called within a test group, it applies only to tests in that 182 /// If this is called within a test group, it applies only to tests in that
172 /// group. [callback] will be run after any set-up callbacks in parent groups or 183 /// group. [callback] will be run after any set-up callbacks in parent groups or
173 /// at the top level. 184 /// at the top level.
174 /// 185 ///
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 /// prefer [tearDown], and only use [tearDOwnAll] if the callback is 227 /// prefer [tearDown], and only use [tearDOwnAll] if the callback is
217 /// prohibitively slow. 228 /// prohibitively slow.
218 void tearDownAll(callback()) => _declarer.tearDownAll(callback); 229 void tearDownAll(callback()) => _declarer.tearDownAll(callback);
219 230
220 /// Registers an exception that was caught for the current test. 231 /// Registers an exception that was caught for the current test.
221 void registerException(error, [StackTrace stackTrace]) { 232 void registerException(error, [StackTrace stackTrace]) {
222 // This will usually forward directly to [Invoker.current.handleError], but 233 // This will usually forward directly to [Invoker.current.handleError], but
223 // going through the zone API allows other zones to consistently see errors. 234 // going through the zone API allows other zones to consistently see errors.
224 Zone.current.handleUncaughtError(error, stackTrace); 235 Zone.current.handleUncaughtError(error, stackTrace);
225 } 236 }
226
227 List<String> _deconvenienceTags(String tag, List<String> tags) {
228 var result = const[];
229 if (tag != null || (tags != null && tags.isNotEmpty)) {
230 result = [];
231 if (tag != null) result.add(tag);
232 if (tags != null && tags.isNotEmpty) result.addAll(tags);
233 }
234 return result;
235 }
OLDNEW
« no previous file with comments | « lib/src/utils.dart ('k') | test/backend/declarer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698