OLD | NEW |
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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:path/path.dart' as p; | 7 import 'package:path/path.dart' as p; |
8 | 8 |
9 import 'src/backend/declarer.dart'; | 9 import 'src/backend/declarer.dart'; |
10 import 'src/backend/test_platform.dart'; | 10 import 'src/backend/test_platform.dart'; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 /// ] | 116 /// ] |
117 /// }); | 117 /// }); |
118 /// | 118 /// |
119 /// If multiple platforms match, the annotations apply in order as through | 119 /// If multiple platforms match, the annotations apply in order as through |
120 /// they were in nested groups. | 120 /// they were in nested groups. |
121 void test(description, body(), | 121 void test(description, body(), |
122 {String testOn, | 122 {String testOn, |
123 Timeout timeout, | 123 Timeout timeout, |
124 skip, | 124 skip, |
125 tags, | 125 tags, |
126 Map<String, dynamic> onPlatform}) => | 126 Map<String, dynamic> onPlatform}) { |
127 _declarer.test(description.toString(), body, | 127 _declarer.test(description.toString(), body, |
128 testOn: testOn, | 128 testOn: testOn, |
129 timeout: timeout, | 129 timeout: timeout, |
130 skip: skip, | 130 skip: skip, |
131 onPlatform: onPlatform, | 131 onPlatform: onPlatform, |
132 tags: tags); | 132 tags: tags); |
| 133 |
| 134 // Force dart2js not to inline this function. We need it to be separate from |
| 135 // `main()` in JS stack traces in order to properly determine the line and |
| 136 // column where the test was defined. See sdk#26705. |
| 137 return; |
| 138 return; |
| 139 } |
133 | 140 |
134 /// Creates a group of tests. | 141 /// Creates a group of tests. |
135 /// | 142 /// |
136 /// A group's description (converted to a string) is included in the description
s | 143 /// A group's description (converted to a string) is included in the description
s |
137 /// of any tests or sub-groups it contains. [setUp] and [tearDown] are also scop
ed | 144 /// of any tests or sub-groups it contains. [setUp] and [tearDown] are also scop
ed |
138 /// to the containing group. | 145 /// to the containing group. |
139 /// | 146 /// |
140 /// If [testOn] is passed, it's parsed as a [platform selector][]; the test will | 147 /// If [testOn] is passed, it's parsed as a [platform selector][]; the test will |
141 /// only be run on matching platforms. | 148 /// only be run on matching platforms. |
142 /// | 149 /// |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 /// ] | 183 /// ] |
177 /// }); | 184 /// }); |
178 /// | 185 /// |
179 /// If multiple platforms match, the annotations apply in order as through | 186 /// If multiple platforms match, the annotations apply in order as through |
180 /// they were in nested groups. | 187 /// they were in nested groups. |
181 void group(description, body(), | 188 void group(description, body(), |
182 {String testOn, | 189 {String testOn, |
183 Timeout timeout, | 190 Timeout timeout, |
184 skip, | 191 skip, |
185 tags, | 192 tags, |
186 Map<String, dynamic> onPlatform}) => | 193 Map<String, dynamic> onPlatform}) { |
187 _declarer.group(description.toString(), body, | 194 _declarer.group(description.toString(), body, |
188 testOn: testOn, timeout: timeout, skip: skip, tags: tags); | 195 testOn: testOn, timeout: timeout, skip: skip, tags: tags); |
| 196 |
| 197 // Force dart2js not to inline this function. We need it to be separate from |
| 198 // `main()` in JS stack traces in order to properly determine the line and |
| 199 // column where the test was defined. See sdk#26705. |
| 200 return; |
| 201 return; |
| 202 } |
189 | 203 |
190 /// Registers a function to be run before tests. | 204 /// Registers a function to be run before tests. |
191 /// | 205 /// |
192 /// This function will be called before each test is run. [callback] may be | 206 /// This function will be called before each test is run. [callback] may be |
193 /// asynchronous; if so, it must return a [Future]. | 207 /// asynchronous; if so, it must return a [Future]. |
194 /// | 208 /// |
195 /// If this is called within a test group, it applies only to tests in that | 209 /// If this is called within a test group, it applies only to tests in that |
196 /// group. [callback] will be run after any set-up callbacks in parent groups or | 210 /// group. [callback] will be run after any set-up callbacks in parent groups or |
197 /// at the top level. | 211 /// at the top level. |
198 /// | 212 /// |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 /// prefer [tearDown], and only use [tearDOwnAll] if the callback is | 254 /// prefer [tearDown], and only use [tearDOwnAll] if the callback is |
241 /// prohibitively slow. | 255 /// prohibitively slow. |
242 void tearDownAll(callback()) => _declarer.tearDownAll(callback); | 256 void tearDownAll(callback()) => _declarer.tearDownAll(callback); |
243 | 257 |
244 /// Registers an exception that was caught for the current test. | 258 /// Registers an exception that was caught for the current test. |
245 void registerException(error, [StackTrace stackTrace]) { | 259 void registerException(error, [StackTrace stackTrace]) { |
246 // This will usually forward directly to [Invoker.current.handleError], but | 260 // This will usually forward directly to [Invoker.current.handleError], but |
247 // going through the zone API allows other zones to consistently see errors. | 261 // going through the zone API allows other zones to consistently see errors. |
248 Zone.current.handleUncaughtError(error, stackTrace); | 262 Zone.current.handleUncaughtError(error, stackTrace); |
249 } | 263 } |
OLD | NEW |