Skip to content

Commit d16bf32

Browse files
committed
tests: point all input.js files to exes directly
1 parent a373cb7 commit d16bf32

File tree

39 files changed

+97
-59
lines changed

39 files changed

+97
-59
lines changed

jscomp/build_tests/bs_dependencies_node_path_override/testcase.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ var assert = require('assert')
33
var path = require('path')
44
var p = require('child_process')
55
var fs = require('fs')
6+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe
67
var output = p.spawnSync(
7-
`../node_modules/.bin/rescript clean -with-deps && ../node_modules/.bin/rescript build`,
8+
`${rescript_exe} clean -with-deps && ${rescript_exe} build`,
89
{
910
cwd: __dirname,
1011
encoding: "utf8",
@@ -14,4 +15,4 @@ var output = p.spawnSync(
1415
fs.rmSync('overridden_node_modules/liba/lib', { recursive: true, force: true })
1516

1617
var u = require("./examples/test.js")
17-
assert.equal(path.basename(u.v), 'demo.mldemo.ml')
18+
assert.equal(path.basename(u.v), 'demo.mldemo.ml')
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
var p = require("child_process");
22
const { assert } = require("console");
3+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe
34

4-
var o = p.spawnSync(`../node_modules/.bin/rescript`);
5+
var o = p.spawnSync(rescript_exe);
56

67
console.log(o.stderr + "");
78
console.log("-----");
89
console.log(o.stdout + "");
9-
assert(o.status === 0)
10+
assert(o.status === 0)

jscomp/build_tests/case/input.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
var p = require('child_process')
44
var assert = require('assert')
5-
var o = p.spawnSync(`../node_modules/.bin/rescript`,{encoding: 'utf8',cwd : __dirname})
5+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe
6+
var o = p.spawnSync(rescript_exe,{encoding: 'utf8',cwd : __dirname})
67

78

8-
assert.ok(o.stderr.match(/different cases/).length > 0 )
9+
assert.ok(o.stderr.match(/different cases/).length > 0 )

jscomp/build_tests/case2/input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var p = require("child_process");
22
var assert = require("assert");
3-
var o = p.spawnSync(`../node_modules/.bin/rescript`, { encoding: "utf8", cwd: __dirname });
3+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
4+
var o = p.spawnSync(rescript_exe, { encoding: "utf8", cwd: __dirname });
45

56
assert.ok(o.stderr.match(/different cases/).length > 0);

jscomp/build_tests/case3/input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ var p = require("child_process");
44
var fs = require("fs");
55
var path = require("path");
66
var assert = require("assert");
7-
p.spawnSync(`../node_modules/.bin/rescript`, {
7+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
8+
p.spawnSync(rescript_exe, {
89
encoding: "utf8",
910
cwd: __dirname,
1011
stdio: [0, 1, 2],

jscomp/build_tests/cmd/input.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ var p = require("child_process");
22

33
var assert = require("assert");
44

5+
var bsc_exe_path = require("../../../scripts/bin_path").bsc_exe;
6+
57
var react = `
68
type u
79
@@ -28,7 +30,7 @@ let d = bar ()
2830

2931
function evalCode(code) {
3032
var bsc_exe = p.spawnSync(
31-
`../node_modules/.bin/bsc -bs-no-version-header -bs-cross-module-opt -w -40 -bs-eval '${code}'`,
33+
`${bsc_exe_path} -bs-no-version-header -bs-cross-module-opt -w -40 -bs-eval '${code}'`,
3234
{
3335
encoding: "utf8",
3436
shell: true,

jscomp/build_tests/customize_namespace/input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
var cp = require("child_process");
44
var assert = require("assert");
5-
cp.execSync(`../node_modules/.bin/rescript build`, { cwd: __dirname, encoding: "utf8" });
5+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
6+
cp.execSync(`${rescript_exe} build`, { cwd: __dirname, encoding: "utf8" });
67

78
assert.equal(require("./src/demo.bs").v, 5);

jscomp/build_tests/cycle/input.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ const cp = require("child_process");
33
const assert = require("assert");
44
const fs = require('fs')
55
const path = require('path')
6+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
67

7-
var output = cp.spawnSync(`../node_modules/.bin/rescript`, { encoding: "utf8", shell: true });
8+
var output = cp.spawnSync(rescript_exe, { encoding: "utf8", shell: true });
89

910
assert(/dependency cycle/.test(output.stdout));
1011

1112
var compilerLogFile = path.join(__dirname, 'lib', 'bs', '.compiler.log');
1213
var compilerLog = fs.readFileSync(compilerLogFile, 'utf8');
13-
assert(/dependency cycle/.test(compilerLog));
14+
assert(/dependency cycle/.test(compilerLog));

jscomp/build_tests/cycle1/input.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ const cp = require("child_process");
33
const assert = require("assert");
44
const fs = require('fs')
55
const path = require('path')
6+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe
67

7-
var output = cp.spawnSync(`../node_modules/.bin/rescript`, { encoding: "utf8", shell: true });
8+
var output = cp.spawnSync(rescript_exe, { encoding: "utf8", shell: true });
89

910
assert(/is dangling/.test(output.stdout));
1011

1112
var compilerLogFile = path.join(__dirname, 'lib', 'bs', '.compiler.log');
1213
var compilerLog = fs.readFileSync(compilerLogFile, 'utf8');
13-
assert(/is dangling/.test(compilerLog));
14+
assert(/is dangling/.test(compilerLog));

jscomp/build_tests/dev/input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
var assert = require("assert");
33
var path = require("path");
44
var p = require("child_process");
5-
p.execSync(`npx rescript build`, { cwd: __dirname, shell: true, encoding: "utf8" });
5+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe
6+
p.execSync(`${rescript_exe} build`, { cwd: __dirname, shell: true, encoding: "utf8" });
67
var u = require("./examples/test.js");
78
assert.equal(path.basename(u.v), "demo.mldemo.ml");

jscomp/build_tests/devdeps/input.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ var cp = require("child_process");
44
var assert = require("assert");
55
var targetOne = `test/test.cmj`;
66
var targetTwo = `src/demo.cmj`;
7+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe
78

89

910
cp.exec(
10-
`../node_modules/.bin/rescript build -- -t commands ${targetOne}`,
11+
`${rescript_exe} build -- -t commands ${targetOne}`,
1112
{ encoding: "ascii" },
1213
function (err, output) {
1314
if (err !== null) {
@@ -16,7 +17,7 @@ cp.exec(
1617
}
1718
assert(output.split("\n").some((x) => x.includes("weird")));
1819
cp.exec(
19-
`../node_modules/.bin/rescript build -- -t commands ${targetTwo}`,
20+
`${rescript_exe} build -- -t commands ${targetTwo}`,
2021
{ encoding: "ascii" },
2122
function (err, output) {
2223
if (err !== null) {

jscomp/build_tests/devonly/input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ts-check
22
var cp = require("child_process");
3+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe
34

4-
cp.execSync(`../node_modules/.bin/rescript`, { cwd: __dirname, encoding: "utf8" });
5+
cp.execSync(rescript_exe, { cwd: __dirname, encoding: "utf8" });

jscomp/build_tests/duplicated_symlinked_packages/input.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fs = require('fs')
22
const path = require('path')
33
const child_process = require('child_process')
4+
const rescript_exe = require("../../../scripts/bin_path").rescript_exe
45

56
const expectedFilePath = path.join(__dirname, 'out.expected')
67

@@ -11,8 +12,8 @@ function postProcessErrorOutput (output) {
1112
output = output.replace(new RegExp(__dirname, 'gi'), '.')
1213
return output
1314
}
14-
child_process.execSync(`../node_modules/.bin/rescript clean -with-deps`,{cwd:__dirname})
15-
child_process.exec('../node_modules/.bin/rescript', {cwd: __dirname}, (err, stdout, stderr) => {
15+
child_process.execSync(`${rescript_exe} clean -with-deps`,{cwd:__dirname})
16+
child_process.exec(rescript_exe, {cwd: __dirname}, (err, stdout, stderr) => {
1617
const actualErrorOutput = postProcessErrorOutput(stderr.toString())
1718
if (updateTests) {
1819
fs.writeFileSync(expectedFilePath, actualErrorOutput)

jscomp/build_tests/exports/input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var child_process = require("child_process");
2+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
23

3-
child_process.execSync(`../node_modules/.bin/rescript`, {
4+
child_process.execSync(rescript_exe, {
45
cwd: __dirname,
56
encoding: "utf8",
67
stdio: [0, 1, 2],

jscomp/build_tests/generator/input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
var child_process = require("child_process");
22
var assert = require("assert");
3+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
34
var output = child_process.spawnSync(
4-
`../node_modules/.bin/rescript clean -with-deps && ../node_modules/.bin/rescript build`,
5+
`${rescript_exe} clean -with-deps && ${rescript_exe} build`,
56
{
67
cwd: __dirname,
78
encoding: "utf8",

jscomp/build_tests/hyphen2/input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
var p = require("child_process");
2+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
23

3-
p.execSync(`../node_modules/.bin/rescript`, { cwd: __dirname, stdio: [0, 1, 2] });
4+
p.execSync(rescript_exe, { cwd: __dirname, stdio: [0, 1, 2] });

jscomp/build_tests/in_source/input.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ var child_process = require('child_process')
22

33
var assert = require('assert')
44

5-
5+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe
66

77

88
assert.throws(
99
() => {
10-
var output = child_process.execSync(`../node_modules/.bin/rescript build -regen`,
10+
var output = child_process.execSync(`${rescript_exe} build -regen`,
1111
{ cwd: __dirname, encoding: 'utf8' }
1212
)
1313
}
@@ -24,4 +24,4 @@ assert.throws(
2424

2525
// assert.throws(()=>{
2626
// throw new Error('Wrong value')
27-
// }, /x/)
27+
// }, /x/)

jscomp/build_tests/install/input.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ var p = require("child_process");
22
var fs = require("fs");
33
var path = require("path");
44
var assert = require("assert");
5+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
56

6-
p.spawnSync(`../node_modules/.bin/rescript`, [`clean`], {
7+
p.spawnSync(rescript_exe, [`clean`], {
78
encoding: "utf8",
89
cwd: __dirname,
910
stdio: [0, 1, 2]
1011
});
11-
p.spawnSync(`../node_modules/.bin/rescript`, [`build`,`-install`], {
12+
p.spawnSync(rescript_exe, [`build`,`-install`], {
1213
encoding: "utf8",
1314
cwd: __dirname,
1415
stdio: [0, 1, 2]
@@ -17,16 +18,16 @@ p.spawnSync(`../node_modules/.bin/rescript`, [`build`,`-install`], {
1718
var fooExists = fs.existsSync(path.join(__dirname, "lib", "ocaml", "Foo.cmi"));
1819
assert.ok(fooExists == false);
1920

20-
p.spawnSync(`../node_modules/.bin/rescript`, {
21+
p.spawnSync(rescript_exe, {
2122
encoding: "utf8",
2223
cwd: __dirname,
2324
stdio: [0, 1, 2]
2425
});
25-
p.spawnSync(`../node_modules/.bin/rescript` ,[`build`,`-install`], {
26+
p.spawnSync(rescript_exe ,[`build`,`-install`], {
2627
encoding: "utf8",
2728
cwd: __dirname,
2829
stdio: [0, 1, 2]
2930
});
3031

3132
fooExists = fs.existsSync(path.join(__dirname, "lib", "ocaml", "Foo.cmi"));
32-
assert.ok(fooExists);
33+
assert.ok(fooExists);

jscomp/build_tests/jsxv/input.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ var assert = require("assert");
44

55
var p = require("child_process");
66

7-
var output = p.spawnSync(`../node_modules/.bin/rescript`, {
7+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
8+
9+
var output = p.spawnSync(rescript_exe, {
810
cwd: __dirname,
911
encoding: "utf8",
1012
shell: true,

jscomp/build_tests/namespace/input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
var child_process = require("child_process");
22
var fs = require("fs");
33
var path = require("path");
4-
child_process.execSync(`../node_modules/.bin/rescript clean -with-deps && ../node_modules/.bin/rescript build`, {
4+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
5+
child_process.execSync(`${rescript_exe} clean -with-deps && ${rescript_exe} build`, {
56
cwd: __dirname,
67
stdio: [0, 1, 2],
78
});

jscomp/build_tests/nested/input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ var p = require("child_process");
22
var assert = require("assert");
33
var fs = require("fs");
44
var path = require("path");
5-
p.execSync(`../node_modules/.bin/rescript`, { cwd: __dirname, stdio: [0, 1, 2] });
5+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
6+
p.execSync(rescript_exe, { cwd: __dirname, stdio: [0, 1, 2] });
67

78
var content = fs.readFileSync(path.join(__dirname, "src", "demo.js"), "utf8");
89

jscomp/build_tests/nnest/input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ var p = require("child_process");
44
var assert = require("assert");
55
var fs = require("fs");
66
var path = require("path");
7-
p.execSync(`../node_modules/.bin/rescript`, { cwd: __dirname, stdio: [0, 1, 2] });
7+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
8+
p.execSync(rescript_exe, { cwd: __dirname, stdio: [0, 1, 2] });
89

910
var content = fs.readFileSync(path.join(__dirname, "src", "demo.js"), "utf8");
1011

jscomp/build_tests/ns/input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
var child_process = require("child_process");
2+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
23

3-
child_process.execSync(`../node_modules/.bin/rescript`, { cwd: __dirname, stdio: [0, 1, 2] });
4+
child_process.execSync(rescript_exe, { cwd: __dirname, stdio: [0, 1, 2] });

jscomp/build_tests/pinned/input.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var cp = require("child_process");
22
var assert = require("assert");
3-
var fs = require("fs");
3+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
44
function checkSpawnOut(out) {
55
if (out.error) {
66
throw out.error;
@@ -11,13 +11,13 @@ function checkSpawnOut(out) {
1111
}
1212

1313
// Clean beforehand to force its dependency to be rebuilt
14-
var out = cp.spawnSync(`../node_modules/.bin/rescript clean`, {
14+
var out = cp.spawnSync(`${rescript_exe} clean`, {
1515
encoding: "utf-8",
1616
shell: true,
1717
});
1818
checkSpawnOut(out);
1919

20-
var out = cp.spawnSync(`../node_modules/.bin/rescript build`, {
20+
var out = cp.spawnSync(`${rescript_exe} build`, {
2121
encoding: "utf-8",
2222
shell: true,
2323
});
@@ -29,7 +29,7 @@ assert.ok(
2929
);
3030

3131
var out2 = cp.spawnSync(
32-
`../node_modules/.bin/rescript build -- -C node_modules/test/lib/bs/ -t targets`,
32+
`${rescript_exe} build -- -C node_modules/test/lib/bs/ -t targets`,
3333
{
3434
encoding: "utf-8",
3535
shell: true,

jscomp/build_tests/post-build/input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
var child_process = require("child_process");
22
var assert = require("assert");
3+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
34

4-
var out = child_process.spawnSync(`../node_modules/.bin/rescript`, { encoding: "utf8" });
5+
var out = child_process.spawnSync(rescript_exe, { encoding: "utf8" });
56

67
if (out.status !== 0) {
78
assert.fail(out.stdout + out.stderr);

jscomp/build_tests/priv/input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
var child_process = require("child_process");
2+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
23

34
var output = child_process.spawnSync(
4-
`npx rescript clean -with-deps && npx rescript build`,
5+
`${rescript_exe} -with-deps && ${rescript_exe} build`,
56
{ cwd: __dirname, shell: true, encoding: "utf8" }
67
);
78

jscomp/build_tests/priv2/input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
var child_process = require("child_process");
22
var assert = require("assert");
3+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
34

45
assert.throws(
56
() => {
6-
child_process.execSync(`../node_modules/.bin/rescript clean -with-deps && ../node_modules/.bin/rescript build`, {
7+
child_process.execSync(`${rescript_exe} clean -with-deps && ${rescript_exe} build`, {
78
cwd: __dirname,
89
encoding: "utf8",
910
});

jscomp/build_tests/react_ppx/input.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ts-check
22
var cp = require("child_process");
3+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
34

4-
cp.execSync(`../node_modules/.bin/rescript`, { cwd: __dirname, stdio: [0, 1, 2] });
5+
cp.execSync(rescript_exe, { cwd: __dirname, stdio: [0, 1, 2] });

jscomp/build_tests/rerror/input.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
var child_process = require("child_process");
22
var assert = require("assert");
3-
child_process.spawnSync(`../node_modules/.bin/rescript clean -with-deps`, {
3+
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
4+
child_process.spawnSync(`${rescript_exe} clean -with-deps`, {
45
cwd: __dirname,
56
encoding: "utf8",
67
stdio: [0, 1, 2],
78
});
8-
var o = child_process.spawnSync(`../node_modules/.bin/rescript `, {
9+
var o = child_process.spawnSync(rescript_exe, {
910
cwd: __dirname,
1011
encoding: "utf8",
1112
shell: true,

0 commit comments

Comments
 (0)