1
1
// @ts -check
2
2
3
3
const assert = require ( "assert" ) ;
4
+ const path = require ( "path" ) ;
4
5
const child_process = require ( "child_process" ) ;
6
+ const { normalizeNewlines } = require ( "../utils.js" ) ;
7
+
8
+ const rescriptPath = path . join ( __dirname , ".." , ".." , ".." , "rescript" )
5
9
6
10
// Shows compile time for `rescript build` command
7
- let out = child_process . spawnSync ( `../../../rescript` , [ "build" ] , {
11
+ let out = child_process . spawnSync ( "node" , [ rescriptPath , "build" ] , {
8
12
encoding : "utf8" ,
9
13
cwd : __dirname ,
10
14
} ) ;
11
15
assert . match (
12
- out . stdout ,
16
+ normalizeNewlines ( out . stdout ) ,
13
17
new RegExp ( `>>>> Start compiling
14
18
Dependency Finished
15
19
>>>> Finish compiling \\d+ mseconds` ) ,
16
20
) ;
17
21
18
22
// Shows compile time for `rescript` command
19
- out = child_process . spawnSync ( `../../../rescript` , {
23
+ out = child_process . spawnSync ( "node" , [ rescriptPath ] , {
20
24
encoding : "utf8" ,
21
25
cwd : __dirname ,
22
26
} ) ;
23
27
assert . match (
24
- out . stdout ,
28
+ normalizeNewlines ( out . stdout ) ,
25
29
new RegExp ( `>>>> Start compiling
26
30
Dependency Finished
27
31
>>>> Finish compiling \\d+ mseconds` ) ,
@@ -31,13 +35,10 @@ Dependency Finished
31
35
// Because we can't be sure that -verbose is a valid argument
32
36
// And bsb won't fail with a usage message.
33
37
// It works this way not only for -verbose, but any other arg, including -h/--help/-help
34
- out = child_process . spawnSync ( `../../../rescript` , [ "build" , "-verbose" ] , {
38
+ out = child_process . spawnSync ( "node" , [ rescriptPath , "build" , "-verbose" ] , {
35
39
encoding : "utf8" ,
36
40
cwd : __dirname ,
37
41
} ) ;
38
- assert . match (
39
- out . stdout ,
40
- new RegExp (
41
- `Package stack: test \nDependency Finished\nninja.exe -C lib/bs \n` ,
42
- ) ,
43
- ) ;
42
+
43
+ assert . match ( normalizeNewlines ( out . stdout ) , / P a c k a g e s t a c k : t e s t \n D e p e n d e n c y F i n i s h e d \n / ) ;
44
+ assert . match ( normalizeNewlines ( out . stdout ) , / n i n j a .e x e " ? - C l i b [ \\ / ] b s ? \n / ) ;
0 commit comments