Skip to content

Commit bb4ba65

Browse files
committed
clean some tests
1 parent 6654cb2 commit bb4ba65

File tree

4 files changed

+29
-18
lines changed

4 files changed

+29
-18
lines changed

scripts/test.js

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,39 +128,36 @@ async function runTests() {
128128
console.log(`Skipping docstrings tests on ${process.platform}`);
129129
} else if (process.platform === "darwin" && os.release().startsWith("22")) {
130130
// Workaround for intermittent hangs in CI
131-
console.log("Skipping docstrings tests on macOS 13")
131+
console.log("Skipping docstrings tests on macOS 13");
132132
} else {
133133
console.log("Running runtime docstrings tests");
134134

135+
const docstringsTestsDir = path.join("tests", "docstring_tests");
136+
135137
const generated_mocha_test_res = path.join(
136-
"tests",
137-
"docstring_tests",
138+
docstringsTestsDir,
138139
"generated_mocha_test.res",
139140
);
140141

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+
});
146146

147147
cp.execSync(`${rescript_exe} build`, {
148-
cwd: path.join(__dirname, "..", "tests/docstring_tests"),
148+
cwd: docstringsTestsDir,
149149
stdio: [0, 1, 2],
150150
});
151151

152152
// 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+
});
160157

161158
// Build again to check if generated_mocha_test.res has syntax or type erros
162159
cp.execSync(`${rescript_exe} build`, {
163-
cwd: path.join(__dirname, "..", "tests/docstring_tests"),
160+
cwd: docstringsTestsDir,
164161
stdio: [0, 1, 2],
165162
});
166163

@@ -173,7 +170,7 @@ async function runTests() {
173170

174171
console.log("Run mocha test");
175172
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")}`,
177174
{
178175
cwd: path.join(__dirname, ".."),
179176
stdio: [0, 1, 2],

tests/build_tests/jsx_settings_inheritance/input.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
var cp = require("child_process");
33
var { rescript_exe } = require("#cli/bin_path");
44

5+
cp.execSync(`${rescript_exe} clean`, { cwd: __dirname });
56
cp.execSync(rescript_exe, { cwd: __dirname });

tests/build_tests/transitive_pinned_dependency1/input.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ var assert = require("assert");
44
var fs = require("fs");
55
var { rescript_exe } = require("#cli/bin_path");
66

7+
console.log(
8+
child_process.execSync(`${rescript_exe} clean`, {
9+
encoding: "utf8",
10+
cwd: "./a",
11+
}),
12+
);
13+
714
console.log(
815
child_process.execSync(rescript_exe, { encoding: "utf8", cwd: "./a" }),
916
);

tests/build_tests/transitive_pinned_dependency2/input.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ var assert = require("assert");
44
var fs = require("fs");
55
var { rescript_exe } = require("#cli/bin_path");
66

7+
console.log(
8+
child_process.execSync(`${rescript_exe} clean`, {
9+
encoding: "utf8",
10+
cwd: "./a",
11+
}),
12+
);
713
console.log(
814
child_process.execSync(rescript_exe, { encoding: "utf8", cwd: "./a" }),
915
);

0 commit comments

Comments
 (0)