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

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 review comments Created 5 years, 1 month 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) 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
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 /// "windows": new Timeout.factor(2), 105 /// "windows": new Timeout.factor(2),
106 /// "browser": [ 106 /// "browser": [
107 /// new Skip("TODO: add browser support"), 107 /// new Skip("TODO: add browser support"),
108 /// // This will be slow on browsers once it works on them. 108 /// // This will be slow on browsers once it works on them.
109 /// new Timeout.factor(2) 109 /// new Timeout.factor(2)
110 /// ] 110 /// ]
111 /// }); 111 /// });
112 /// 112 ///
113 /// If multiple platforms match, the annotations apply in order as through 113 /// If multiple platforms match, the annotations apply in order as through
114 /// they were in nested groups. 114 /// they were in nested groups.
115 void test(String description, body(), {String testOn, Timeout timeout, 115 void test(String description, body(),
116 skip, Map<String, dynamic> onPlatform, String tag, 116 {String testOn,
117 List<String> tags}) => _declarer.test(description, body, 117 Timeout timeout,
118 testOn: testOn, timeout: timeout, skip: skip, 118 skip,
119 onPlatform: onPlatform, tags: _deconvenienceTags(tag, tags)); 119 Map<String, dynamic> onPlatform,
120 tags}) =>
121 _declarer.test(description, body,
122 testOn: testOn,
123 timeout: timeout,
124 skip: skip,
125 onPlatform: onPlatform,
126 tags: tags);
120 127
121 /// Creates a group of tests. 128 /// Creates a group of tests.
122 /// 129 ///
123 /// A group's description is included in the descriptions of any tests or 130 /// 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 131 /// sub-groups it contains. [setUp] and [tearDown] are also scoped to the
125 /// containing group. 132 /// containing group.
126 /// 133 ///
127 /// If [testOn] is passed, it's parsed as a [platform selector][]; the test will 134 /// If [testOn] is passed, it's parsed as a [platform selector][]; the test will
128 /// only be run on matching platforms. 135 /// only be run on matching platforms.
129 /// 136 ///
(...skipping 20 matching lines...) Expand all
150 /// "windows": new Timeout.factor(2), 157 /// "windows": new Timeout.factor(2),
151 /// "browser": [ 158 /// "browser": [
152 /// new Skip("TODO: add browser support"), 159 /// new Skip("TODO: add browser support"),
153 /// // They'll be slow on browsers once it works on them. 160 /// // They'll be slow on browsers once it works on them.
154 /// new Timeout.factor(2) 161 /// new Timeout.factor(2)
155 /// ] 162 /// ]
156 /// }); 163 /// });
157 /// 164 ///
158 /// If multiple platforms match, the annotations apply in order as through 165 /// If multiple platforms match, the annotations apply in order as through
159 /// they were in nested groups. 166 /// they were in nested groups.
160 void group(String description, void body(), {String testOn, Timeout timeout, 167 void group(String description, void body(),
161 skip, Map<String, dynamic> onPlatform, String tag, 168 {String testOn,
162 List<String> tags}) => _declarer.group(description, body, 169 Timeout timeout,
163 testOn: testOn, timeout: timeout, skip: skip, 170 skip,
164 tags: _deconvenienceTags(tag, tags)); 171 Map<String, dynamic> onPlatform,
172 tags}) =>
173 _declarer.group(description, body,
174 testOn: testOn, timeout: timeout, skip: skip, tags: tags);
165 175
166 /// Registers a function to be run before tests. 176 /// Registers a function to be run before tests.
167 /// 177 ///
168 /// This function will be called before each test is run. [callback] may be 178 /// This function will be called before each test is run. [callback] may be
169 /// asynchronous; if so, it must return a [Future]. 179 /// asynchronous; if so, it must return a [Future].
170 /// 180 ///
171 /// If this is called within a test group, it applies only to tests in that 181 /// 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 182 /// group. [callback] will be run after any set-up callbacks in parent groups or
173 /// at the top level. 183 /// at the top level.
174 /// 184 ///
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 /// prefer [tearDown], and only use [tearDOwnAll] if the callback is 226 /// prefer [tearDown], and only use [tearDOwnAll] if the callback is
217 /// prohibitively slow. 227 /// prohibitively slow.
218 void tearDownAll(callback()) => _declarer.tearDownAll(callback); 228 void tearDownAll(callback()) => _declarer.tearDownAll(callback);
219 229
220 /// Registers an exception that was caught for the current test. 230 /// Registers an exception that was caught for the current test.
221 void registerException(error, [StackTrace stackTrace]) { 231 void registerException(error, [StackTrace stackTrace]) {
222 // This will usually forward directly to [Invoker.current.handleError], but 232 // This will usually forward directly to [Invoker.current.handleError], but
223 // going through the zone API allows other zones to consistently see errors. 233 // going through the zone API allows other zones to consistently see errors.
224 Zone.current.handleUncaughtError(error, stackTrace); 234 Zone.current.handleUncaughtError(error, stackTrace);
225 } 235 }
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

Powered by Google App Engine
This is Rietveld 408576698