Skip to content

Add bsc_path helper + use bsc.exe for super-errors test #5471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ lib/
vendor/
ninja/
syntax/
ocaml-tree/
ocaml-tree/
_opam
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ var assert = require('assert')
var path = require('path')
var p = require('child_process')
var fs = require('fs')
var rescript_exe = require("../../../scripts/bin_path").rescript_exe
var output = p.spawnSync(
`../node_modules/.bin/rescript clean -with-deps && ../node_modules/.bin/rescript build`,
`${rescript_exe} clean -with-deps && ${rescript_exe} build`,
{
cwd: __dirname,
encoding: "utf8",
Expand All @@ -14,4 +15,4 @@ var output = p.spawnSync(
fs.rmSync('overridden_node_modules/liba/lib', { recursive: true, force: true })

var u = require("./examples/test.js")
assert.equal(path.basename(u.v), 'demo.mldemo.ml')
assert.equal(path.basename(u.v), 'demo.mldemo.ml')
5 changes: 3 additions & 2 deletions jscomp/build_tests/bucklescript-tea/input.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
var p = require("child_process");
const { assert } = require("console");
var rescript_exe = require("../../../scripts/bin_path").rescript_exe

var o = p.spawnSync(`../node_modules/.bin/rescript`);
var o = p.spawnSync(rescript_exe);

console.log(o.stderr + "");
console.log("-----");
console.log(o.stdout + "");
assert(o.status === 0)
assert(o.status === 0)
5 changes: 3 additions & 2 deletions jscomp/build_tests/case/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

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


assert.ok(o.stderr.match(/different cases/).length > 0 )
assert.ok(o.stderr.match(/different cases/).length > 0 )
3 changes: 2 additions & 1 deletion jscomp/build_tests/case2/input.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var p = require("child_process");
var assert = require("assert");
var o = p.spawnSync(`../node_modules/.bin/rescript`, { encoding: "utf8", cwd: __dirname });
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
var o = p.spawnSync(rescript_exe, { encoding: "utf8", cwd: __dirname });

assert.ok(o.stderr.match(/different cases/).length > 0);
3 changes: 2 additions & 1 deletion jscomp/build_tests/case3/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ var p = require("child_process");
var fs = require("fs");
var path = require("path");
var assert = require("assert");
p.spawnSync(`../node_modules/.bin/rescript`, {
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
p.spawnSync(rescript_exe, {
encoding: "utf8",
cwd: __dirname,
stdio: [0, 1, 2],
Expand Down
4 changes: 3 additions & 1 deletion jscomp/build_tests/cmd/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ var p = require("child_process");

var assert = require("assert");

var bsc_exe_path = require("../../../scripts/bin_path").bsc_exe;

var react = `
type u

Expand All @@ -28,7 +30,7 @@ let d = bar ()

function evalCode(code) {
var bsc_exe = p.spawnSync(
`../node_modules/.bin/bsc -bs-no-version-header -bs-cross-module-opt -w -40 -bs-eval '${code}'`,
`${bsc_exe_path} -bs-no-version-header -bs-cross-module-opt -w -40 -bs-eval '${code}'`,
{
encoding: "utf8",
shell: true,
Expand Down
3 changes: 2 additions & 1 deletion jscomp/build_tests/customize_namespace/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

assert.equal(require("./src/demo.bs").v, 5);
5 changes: 3 additions & 2 deletions jscomp/build_tests/cycle/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ const cp = require("child_process");
const assert = require("assert");
const fs = require('fs')
const path = require('path')
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;

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

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

var compilerLogFile = path.join(__dirname, 'lib', 'bs', '.compiler.log');
var compilerLog = fs.readFileSync(compilerLogFile, 'utf8');
assert(/dependency cycle/.test(compilerLog));
assert(/dependency cycle/.test(compilerLog));
5 changes: 3 additions & 2 deletions jscomp/build_tests/cycle1/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ const cp = require("child_process");
const assert = require("assert");
const fs = require('fs')
const path = require('path')
var rescript_exe = require("../../../scripts/bin_path").rescript_exe

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

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

var compilerLogFile = path.join(__dirname, 'lib', 'bs', '.compiler.log');
var compilerLog = fs.readFileSync(compilerLogFile, 'utf8');
assert(/is dangling/.test(compilerLog));
assert(/is dangling/.test(compilerLog));
3 changes: 2 additions & 1 deletion jscomp/build_tests/dev/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
var assert = require("assert");
var path = require("path");
var p = require("child_process");
p.execSync(`npx rescript build`, { cwd: __dirname, shell: true, encoding: "utf8" });
var rescript_exe = require("../../../scripts/bin_path").rescript_exe
p.execSync(`${rescript_exe} build`, { cwd: __dirname, shell: true, encoding: "utf8" });
var u = require("./examples/test.js");
assert.equal(path.basename(u.v), "demo.mldemo.ml");
5 changes: 3 additions & 2 deletions jscomp/build_tests/devdeps/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ var cp = require("child_process");
var assert = require("assert");
var targetOne = `test/test.cmj`;
var targetTwo = `src/demo.cmj`;
var rescript_exe = require("../../../scripts/bin_path").rescript_exe


cp.exec(
`../node_modules/.bin/rescript build -- -t commands ${targetOne}`,
`${rescript_exe} build -- -t commands ${targetOne}`,
{ encoding: "ascii" },
function (err, output) {
if (err !== null) {
Expand All @@ -16,7 +17,7 @@ cp.exec(
}
assert(output.split("\n").some((x) => x.includes("weird")));
cp.exec(
`../node_modules/.bin/rescript build -- -t commands ${targetTwo}`,
`${rescript_exe} build -- -t commands ${targetTwo}`,
{ encoding: "ascii" },
function (err, output) {
if (err !== null) {
Expand Down
3 changes: 2 additions & 1 deletion jscomp/build_tests/devonly/input.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ts-check
var cp = require("child_process");
var rescript_exe = require("../../../scripts/bin_path").rescript_exe

cp.execSync(`../node_modules/.bin/rescript`, { cwd: __dirname, encoding: "utf8" });
cp.execSync(rescript_exe, { cwd: __dirname, encoding: "utf8" });
5 changes: 3 additions & 2 deletions jscomp/build_tests/duplicated_symlinked_packages/input.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require('fs')
const path = require('path')
const child_process = require('child_process')
const rescript_exe = require("../../../scripts/bin_path").rescript_exe

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

Expand All @@ -11,8 +12,8 @@ function postProcessErrorOutput (output) {
output = output.replace(new RegExp(__dirname, 'gi'), '.')
return output
}
child_process.execSync(`../node_modules/.bin/rescript clean -with-deps`,{cwd:__dirname})
child_process.exec('../node_modules/.bin/rescript', {cwd: __dirname}, (err, stdout, stderr) => {
child_process.execSync(`${rescript_exe} clean -with-deps`,{cwd:__dirname})
child_process.exec(rescript_exe, {cwd: __dirname}, (err, stdout, stderr) => {
const actualErrorOutput = postProcessErrorOutput(stderr.toString())
if (updateTests) {
fs.writeFileSync(expectedFilePath, actualErrorOutput)
Expand Down
3 changes: 2 additions & 1 deletion jscomp/build_tests/exports/input.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var child_process = require("child_process");
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;

child_process.execSync(`../node_modules/.bin/rescript`, {
child_process.execSync(rescript_exe, {
cwd: __dirname,
encoding: "utf8",
stdio: [0, 1, 2],
Expand Down
3 changes: 2 additions & 1 deletion jscomp/build_tests/generator/input.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var child_process = require("child_process");
var assert = require("assert");
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
var output = child_process.spawnSync(
`../node_modules/.bin/rescript clean -with-deps && ../node_modules/.bin/rescript build`,
`${rescript_exe} clean -with-deps && ${rescript_exe} build`,
{
cwd: __dirname,
encoding: "utf8",
Expand Down
3 changes: 2 additions & 1 deletion jscomp/build_tests/hyphen2/input.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var p = require("child_process");
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;

p.execSync(`../node_modules/.bin/rescript`, { cwd: __dirname, stdio: [0, 1, 2] });
p.execSync(rescript_exe, { cwd: __dirname, stdio: [0, 1, 2] });
6 changes: 3 additions & 3 deletions jscomp/build_tests/in_source/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ var child_process = require('child_process')

var assert = require('assert')


var rescript_exe = require("../../../scripts/bin_path").rescript_exe


assert.throws(
() => {
var output = child_process.execSync(`../node_modules/.bin/rescript build -regen`,
var output = child_process.execSync(`${rescript_exe} build -regen`,
{ cwd: __dirname, encoding: 'utf8' }
)
}
Expand All @@ -24,4 +24,4 @@ assert.throws(

// assert.throws(()=>{
// throw new Error('Wrong value')
// }, /x/)
// }, /x/)
11 changes: 6 additions & 5 deletions jscomp/build_tests/install/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ var p = require("child_process");
var fs = require("fs");
var path = require("path");
var assert = require("assert");
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;

p.spawnSync(`../node_modules/.bin/rescript`, [`clean`], {
p.spawnSync(rescript_exe, [`clean`], {
encoding: "utf8",
cwd: __dirname,
stdio: [0, 1, 2]
});
p.spawnSync(`../node_modules/.bin/rescript`, [`build`,`-install`], {
p.spawnSync(rescript_exe, [`build`,`-install`], {
encoding: "utf8",
cwd: __dirname,
stdio: [0, 1, 2]
Expand All @@ -17,16 +18,16 @@ p.spawnSync(`../node_modules/.bin/rescript`, [`build`,`-install`], {
var fooExists = fs.existsSync(path.join(__dirname, "lib", "ocaml", "Foo.cmi"));
assert.ok(fooExists == false);

p.spawnSync(`../node_modules/.bin/rescript`, {
p.spawnSync(rescript_exe, {
encoding: "utf8",
cwd: __dirname,
stdio: [0, 1, 2]
});
p.spawnSync(`../node_modules/.bin/rescript` ,[`build`,`-install`], {
p.spawnSync(rescript_exe ,[`build`,`-install`], {
encoding: "utf8",
cwd: __dirname,
stdio: [0, 1, 2]
});

fooExists = fs.existsSync(path.join(__dirname, "lib", "ocaml", "Foo.cmi"));
assert.ok(fooExists);
assert.ok(fooExists);
4 changes: 3 additions & 1 deletion jscomp/build_tests/jsxv/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ var assert = require("assert");

var p = require("child_process");

var output = p.spawnSync(`../node_modules/.bin/rescript`, {
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;

var output = p.spawnSync(rescript_exe, {
cwd: __dirname,
encoding: "utf8",
shell: true,
Expand Down
3 changes: 2 additions & 1 deletion jscomp/build_tests/namespace/input.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var child_process = require("child_process");
var fs = require("fs");
var path = require("path");
child_process.execSync(`../node_modules/.bin/rescript clean -with-deps && ../node_modules/.bin/rescript build`, {
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
child_process.execSync(`${rescript_exe} clean -with-deps && ${rescript_exe} build`, {
cwd: __dirname,
stdio: [0, 1, 2],
});
Expand Down
3 changes: 2 additions & 1 deletion jscomp/build_tests/nested/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ var p = require("child_process");
var assert = require("assert");
var fs = require("fs");
var path = require("path");
p.execSync(`../node_modules/.bin/rescript`, { cwd: __dirname, stdio: [0, 1, 2] });
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
p.execSync(rescript_exe, { cwd: __dirname, stdio: [0, 1, 2] });

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

Expand Down
3 changes: 2 additions & 1 deletion jscomp/build_tests/nnest/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ var p = require("child_process");
var assert = require("assert");
var fs = require("fs");
var path = require("path");
p.execSync(`../node_modules/.bin/rescript`, { cwd: __dirname, stdio: [0, 1, 2] });
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
p.execSync(rescript_exe, { cwd: __dirname, stdio: [0, 1, 2] });

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

Expand Down
3 changes: 2 additions & 1 deletion jscomp/build_tests/ns/input.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var child_process = require("child_process");
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;

child_process.execSync(`../node_modules/.bin/rescript`, { cwd: __dirname, stdio: [0, 1, 2] });
child_process.execSync(rescript_exe, { cwd: __dirname, stdio: [0, 1, 2] });
8 changes: 4 additions & 4 deletions jscomp/build_tests/pinned/input.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var cp = require("child_process");
var assert = require("assert");
var fs = require("fs");
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;
function checkSpawnOut(out) {
if (out.error) {
throw out.error;
Expand All @@ -11,13 +11,13 @@ function checkSpawnOut(out) {
}

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

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

var out2 = cp.spawnSync(
`../node_modules/.bin/rescript build -- -C node_modules/test/lib/bs/ -t targets`,
`${rescript_exe} build -- -C node_modules/test/lib/bs/ -t targets`,
{
encoding: "utf-8",
shell: true,
Expand Down
3 changes: 2 additions & 1 deletion jscomp/build_tests/post-build/input.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var child_process = require("child_process");
var assert = require("assert");
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;

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

if (out.status !== 0) {
assert.fail(out.stdout + out.stderr);
Expand Down
3 changes: 2 additions & 1 deletion jscomp/build_tests/priv/input.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var child_process = require("child_process");
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;

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

Expand Down
3 changes: 2 additions & 1 deletion jscomp/build_tests/priv2/input.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
var child_process = require("child_process");
var assert = require("assert");
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;

assert.throws(
() => {
child_process.execSync(`../node_modules/.bin/rescript clean -with-deps && ../node_modules/.bin/rescript build`, {
child_process.execSync(`${rescript_exe} clean -with-deps && ${rescript_exe} build`, {
cwd: __dirname,
encoding: "utf8",
});
Expand Down
3 changes: 2 additions & 1 deletion jscomp/build_tests/react_ppx/input.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ts-check
var cp = require("child_process");
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;

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