@@ -128,39 +128,36 @@ async function runTests() {
128
128
console . log ( `Skipping docstrings tests on ${ process . platform } ` ) ;
129
129
} else if ( process . platform === "darwin" && os . release ( ) . startsWith ( "22" ) ) {
130
130
// Workaround for intermittent hangs in CI
131
- console . log ( "Skipping docstrings tests on macOS 13" )
131
+ console . log ( "Skipping docstrings tests on macOS 13" ) ;
132
132
} else {
133
133
console . log ( "Running runtime docstrings tests" ) ;
134
134
135
+ const docstringsTestsDir = path . join ( "tests" , "docstring_tests" ) ;
136
+
135
137
const generated_mocha_test_res = path . join (
136
- "tests" ,
137
- "docstring_tests" ,
138
+ docstringsTestsDir ,
138
139
"generated_mocha_test.res" ,
139
140
) ;
140
141
141
- // Remove `generated_mocha_test.res` if file exists
142
- if ( fs . existsSync ( generated_mocha_test_res ) ) {
143
- console . log ( `Removing ${ generated_mocha_test_res } ` ) ;
144
- fs . unlinkSync ( generated_mocha_test_res ) ;
145
- }
142
+ cp . execSync ( `${ rescript_exe } clean` , {
143
+ cwd : docstringsTestsDir ,
144
+ stdio : [ 0 , 1 , 2 ] ,
145
+ } ) ;
146
146
147
147
cp . execSync ( `${ rescript_exe } build` , {
148
- cwd : path . join ( __dirname , ".." , "tests/docstring_tests" ) ,
148
+ cwd : docstringsTestsDir ,
149
149
stdio : [ 0 , 1 , 2 ] ,
150
150
} ) ;
151
151
152
152
// Generate rescript file with all tests `generated_mocha_test.res`
153
- cp . execSync (
154
- `node ${ path . join ( "tests" , "docstring_tests" , "DocTest.res.mjs" ) } ` ,
155
- {
156
- cwd : path . join ( __dirname , ".." ) ,
157
- stdio : [ 0 , 1 , 2 ] ,
158
- } ,
159
- ) ;
153
+ cp . execSync ( `node ${ path . join ( docstringsTestsDir , "DocTest.res.mjs" ) } ` , {
154
+ cwd : path . join ( __dirname , ".." ) ,
155
+ stdio : [ 0 , 1 , 2 ] ,
156
+ } ) ;
160
157
161
158
// Build again to check if generated_mocha_test.res has syntax or type erros
162
159
cp . execSync ( `${ rescript_exe } build` , {
163
- cwd : path . join ( __dirname , ".." , "tests/docstring_tests" ) ,
160
+ cwd : docstringsTestsDir ,
164
161
stdio : [ 0 , 1 , 2 ] ,
165
162
} ) ;
166
163
@@ -173,7 +170,7 @@ async function runTests() {
173
170
174
171
console . log ( "Run mocha test" ) ;
175
172
cp . execSync (
176
- `npx mocha ${ path . join ( "tests" , "docstring_tests" , "generated_mocha_test.res.mjs" ) } ` ,
173
+ `npx mocha ${ path . join ( docstringsTestsDir , "generated_mocha_test.res.mjs" ) } ` ,
177
174
{
178
175
cwd : path . join ( __dirname , ".." ) ,
179
176
stdio : [ 0 , 1 , 2 ] ,
0 commit comments