11// @ts -check 
22
33const  assert  =  require ( "assert" ) ; 
4+ const  path  =  require ( "path" ) ; 
45const  child_process  =  require ( "child_process" ) ; 
6+ const  {  normalizeNewlines }  =  require ( "../utils.js" ) ; 
7+ 
8+ const  rescriptPath  =  path . join ( __dirname ,  ".." ,  ".." ,  ".." ,  "rescript" ) 
59
610// Shows compile time for `rescript build` command 
7- let  out  =  child_process . spawnSync ( `../../../rescript` ,  [ "build" ] ,  { 
11+ let  out  =  child_process . spawnSync ( "node" ,  [ rescriptPath ,   "build" ] ,  { 
812  encoding : "utf8" , 
913  cwd : __dirname , 
1014} ) ; 
1115assert . match ( 
12-   out . stdout , 
16+   normalizeNewlines ( out . stdout ) , 
1317  new  RegExp ( `>>>> Start compiling 
1418Dependency Finished 
1519>>>> Finish compiling \\d+ mseconds` ) , 
1620) ; 
1721
1822// Shows compile time for `rescript` command 
19- out  =  child_process . spawnSync ( `../../../rescript` ,  { 
23+ out  =  child_process . spawnSync ( "node" ,   [ rescriptPath ] ,  { 
2024  encoding : "utf8" , 
2125  cwd : __dirname , 
2226} ) ; 
2327assert . match ( 
24-   out . stdout , 
28+   normalizeNewlines ( out . stdout ) , 
2529  new  RegExp ( `>>>> Start compiling 
2630Dependency Finished 
2731>>>> Finish compiling \\d+ mseconds` ) , 
@@ -31,13 +35,10 @@ Dependency Finished
3135// Because we can't be sure that -verbose is a valid argument 
3236// And bsb won't fail with a usage message. 
3337// 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" ] ,  { 
3539  encoding : "utf8" , 
3640  cwd : __dirname , 
3741} ) ; 
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 ) ,  new  RegExp ( `Package stack: test  \nDependency Finished\n` ) ) ; 
44+ assert . match ( normalizeNewlines ( out . stdout ) ,  new  RegExp ( `ninja.exe -C lib/bs \n` ) ) ; 
0 commit comments