8
8
// except according to those terms.
9
9
10
10
extern crate markup5ever_rcdom as rcdom;
11
- extern crate rustc_test as test;
12
11
#[ macro_use]
13
12
extern crate html5ever;
14
13
@@ -20,12 +19,16 @@ use std::ffi::OsStr;
20
19
use std:: io:: BufRead ;
21
20
use std:: path:: Path ;
22
21
use std:: { env, fs, io, iter, mem} ;
23
- use test:: { DynTestName , TestDesc , TestDescAndFn , TestFn } ;
24
22
25
23
use html5ever:: tendril:: { StrTendril , TendrilSink } ;
26
24
use html5ever:: { parse_document, parse_fragment, ParseOpts } ;
27
25
use html5ever:: { LocalName , QualName } ;
28
26
use rcdom:: { Handle , NodeData , RcDom } ;
27
+ use util:: runner:: Test ;
28
+
29
+ mod util {
30
+ pub mod runner;
31
+ }
29
32
30
33
fn parse_tests < It : Iterator < Item = String > > ( mut lines : It ) -> Vec < HashMap < String , String > > {
31
34
let mut tests = vec ! [ ] ;
@@ -159,7 +162,7 @@ fn serialize(buf: &mut String, indent: usize, handle: Handle) {
159
162
}
160
163
161
164
fn make_test (
162
- tests : & mut Vec < TestDescAndFn > ,
165
+ tests : & mut Vec < Test > ,
163
166
ignores : & HashSet < String > ,
164
167
filename : & str ,
165
168
idx : usize ,
@@ -185,7 +188,7 @@ fn make_test_desc_with_scripting_flag(
185
188
name : & str ,
186
189
fields : & HashMap < String , String > ,
187
190
scripting_enabled : bool ,
188
- ) -> TestDescAndFn {
191
+ ) -> Test {
189
192
let get_field = |key| {
190
193
let field = fields. get ( key) . expect ( "missing field" ) ;
191
194
field. trim_end_matches ( '\n' ) . to_string ( )
@@ -197,24 +200,22 @@ fn make_test_desc_with_scripting_flag(
197
200
let context = fields
198
201
. get ( "document-fragment" )
199
202
. map ( |field| context_name ( field. trim_end_matches ( '\n' ) ) ) ;
200
- let ignore = ignores. contains ( name) ;
203
+ let skip = ignores. contains ( name) ;
201
204
let mut name = name. to_owned ( ) ;
202
205
if scripting_enabled {
203
206
name. push_str ( " (scripting enabled)" ) ;
204
207
} else {
205
208
name. push_str ( " (scripting disabled)" ) ;
206
209
} ;
207
- let mut opts: ParseOpts = Default :: default ( ) ;
208
- opts. tree_builder . scripting_enabled = scripting_enabled;
209
210
210
- TestDescAndFn {
211
- desc : TestDesc {
212
- ignore,
213
- ..TestDesc :: new ( DynTestName ( name) )
214
- } ,
215
- testfn : TestFn :: dyn_test_fn ( move || {
211
+ Test {
212
+ name,
213
+ skip,
214
+ test : Box :: new ( move || {
216
215
// Do this here because Tendril isn't Send.
217
216
let data = StrTendril :: from_slice ( & data) ;
217
+ let mut opts: ParseOpts = Default :: default ( ) ;
218
+ opts. tree_builder . scripting_enabled = scripting_enabled;
218
219
let mut result = String :: new ( ) ;
219
220
match context {
220
221
None => {
@@ -258,7 +259,7 @@ fn context_name(context: &str) -> QualName {
258
259
}
259
260
}
260
261
261
- fn tests ( src_dir : & Path , ignores : & HashSet < String > ) -> Vec < TestDescAndFn > {
262
+ fn tests ( src_dir : & Path , ignores : & HashSet < String > ) -> Vec < Test > {
262
263
let mut tests = vec ! [ ] ;
263
264
264
265
foreach_html5lib_test (
@@ -286,7 +287,6 @@ fn tests(src_dir: &Path, ignores: &HashSet<String>) -> Vec<TestDescAndFn> {
286
287
}
287
288
288
289
fn main ( ) {
289
- let args: Vec < _ > = env:: args ( ) . collect ( ) ;
290
290
let src_dir = Path :: new ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
291
291
let mut ignores = HashSet :: new ( ) ;
292
292
{
@@ -297,5 +297,7 @@ fn main() {
297
297
}
298
298
}
299
299
300
- test:: test_main ( & args, tests ( src_dir, & ignores) ) ;
300
+ for test in tests ( src_dir, & ignores) {
301
+ test. run ( ) ;
302
+ }
301
303
}
0 commit comments