@@ -18,20 +18,22 @@ process.on("unhandledRejection", err => {
18
18
// 1. Go to https://github.com/web-platform-tests/wpt/tree/master/url
19
19
// 2. Press "y" on your keyboard to get a permalink
20
20
// 3. Copy the commit hash
21
- const commitHash = "c95d15338d3d4380beffb8b1b8dda62a8d746ab9 " ;
21
+ const commitHash = "6d461b4ddb2f1b8d226ca6ae92e14bbd464731a5 " ;
22
22
23
23
const urlPrefix = `https://raw.githubusercontent.com/web-platform-tests/wpt/${ commitHash } /url/` ;
24
24
const targetDir = path . resolve ( __dirname , ".." , "test" , "web-platform-tests" ) ;
25
25
26
- ( fs . rmSync || fs . rmdirSync ) ( targetDir , { recursive : true , force : true } ) ;
27
- fs . mkdirSync ( path . resolve ( targetDir , "resources" ) , { recursive : true } ) ;
28
-
29
- for ( const file of [
26
+ // These resources we download, but the test runner doesn't need to know about them.
27
+ const resources = [
30
28
"resources/percent-encoding.json" ,
31
29
"resources/setters_tests.json" ,
32
30
"resources/toascii.json" ,
33
31
"resources/urltestdata.json" ,
34
- "resources/IdnaTestV2.json" ,
32
+ "resources/IdnaTestV2.json"
33
+ ] ;
34
+
35
+ // These tests we can download and run directly in /test/web-platform.js.
36
+ exports . directlyRunnableTests = [
35
37
"url-searchparams.any.js" ,
36
38
"url-setters-stripping.any.js" ,
37
39
"url-tojson.any.js" ,
@@ -46,8 +48,31 @@ for (const file of [
46
48
"urlsearchparams-set.any.js" ,
47
49
"urlsearchparams-sort.any.js" ,
48
50
"urlsearchparams-stringifier.any.js"
49
- ] ) {
50
- fetch ( `${ urlPrefix } ${ file } ` ) . then ( res => {
51
- res . body . pipe ( fs . createWriteStream ( path . resolve ( targetDir , file ) ) ) ;
52
- } ) ;
51
+ ] ;
52
+
53
+ // These tests need some special handling in /test/web-platform.js, since they need to be hooked up to their resource
54
+ // files in a case-by-case way. We still download them, but they're in a separately-exported array so that the runner
55
+ // can distinguish.
56
+ exports . resourceDependentTests = [
57
+ "IdnaTestV2.window.js" ,
58
+ "url-constructor.any.js" ,
59
+ "url-origin.any.js" ,
60
+ "url-setters.any.js"
61
+ ] ;
62
+
63
+ // These tests need their logic duplicated in /test/web-platform.js, because we can't easly shim them. They are not
64
+ // downloaded, but we list them here so that it's easy to understand our categorization scheme.
65
+ // - failure.html
66
+ // - percent-encoding.window.js
67
+ // - toascii.window.js
68
+
69
+ if ( require . main === module ) {
70
+ ( fs . rmSync || fs . rmdirSync ) ( targetDir , { recursive : true , force : true } ) ;
71
+ fs . mkdirSync ( path . resolve ( targetDir , "resources" ) , { recursive : true } ) ;
72
+
73
+ for ( const file of [ ...resources , ...exports . directlyRunnableTests , ...exports . resourceDependentTests ] ) {
74
+ fetch ( `${ urlPrefix } ${ file } ` ) . then ( res => {
75
+ res . body . pipe ( fs . createWriteStream ( path . resolve ( targetDir , file ) ) ) ;
76
+ } ) ;
77
+ }
53
78
}
0 commit comments