Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#### :house: Internal

- Reanalyze server: redesign incremental fixpoint with delete-then-rederive strategy and predecessor tracking, improving speed on deletions. https://github.com/rescript-lang/rescript/pull/8276
- Fix build tests failing silently. https://github.com/rescript-lang/rescript/pull/8295

# 13.0.0-alpha.2

Expand Down
20 changes: 20 additions & 0 deletions lib_dev/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const {
execBin,
rescript,
execBuild,
execBuildOrThrow,
execClean,
} = setup();

Expand Down Expand Up @@ -196,6 +197,25 @@ export function setup(cwd = process.cwd()) {
return exec(rescript_exe, ["build", ...args], options);
},

/**
* Execute ReScript `build` command directly and throw on non-zero exit
* while preserving captured stdout/stderr for quiet successful tests.
*
* @param {string[]} [args]
* @param {ExecOptions} [options]
* @return {Promise<ExecResult>}
*/
async execBuildOrThrow(args = [], options = {}) {
const out = await exec(rescript_exe, ["build", ...args], options);
if (out.status !== 0) {
const err = new Error("ReScript build failed");
err.stack = out.stdout + out.stderr;
Object.assign(err, { execResult: out });
throw err;
}
return out;
},

/**
* Execute ReScript `clean` command directly
*
Expand Down
4 changes: 2 additions & 2 deletions tests/build_tests/case3/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import fs from "node:fs/promises";
import path from "node:path";
import { setup } from "#dev/process";

const { execBuild, execClean } = setup(import.meta.dirname);
const { execBuildOrThrow, execClean } = setup(import.meta.dirname);

await execClean();
await execBuild();
await execBuildOrThrow();

const o = await fs.readFile(path.join("src", "hello.res.js"), "ascii");
assert.ok(/HelloGen\.f/.test(o));
4 changes: 2 additions & 2 deletions tests/build_tests/custom_namespace/input.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as assert from "node:assert";
import { setup } from "#dev/process";

const { execClean, execBuild } = setup(import.meta.dirname);
const { execClean, execBuildOrThrow } = setup(import.meta.dirname);

await execClean();
await execBuild();
await execBuildOrThrow();

const x = await import("./src/demo.res.js");
assert.equal(x.v, 42);
4 changes: 2 additions & 2 deletions tests/build_tests/devonly/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

import { setup } from "#dev/process";

const { execBuild } = setup(import.meta.dirname);
const { execBuildOrThrow } = setup(import.meta.dirname);

await execBuild();
await execBuildOrThrow();
5 changes: 3 additions & 2 deletions tests/build_tests/exports/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { setup } from "#dev/process";

const { execBuild, execClean } = setup(import.meta.dirname);
const { execBuildOrThrow, execClean } = setup(import.meta.dirname);

await execBuild();
await execClean();
await execBuildOrThrow();
await execClean();
4 changes: 2 additions & 2 deletions tests/build_tests/hyphen2/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { setup } from "#dev/process";

const { execBuild, execClean } = setup(import.meta.dirname);
const { execBuildOrThrow, execClean } = setup(import.meta.dirname);

await execBuild();
await execBuildOrThrow();
await execClean();
4 changes: 2 additions & 2 deletions tests/build_tests/jsx_settings_inheritance/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { setup } from "#dev/process";

const { execBuild, execClean } = setup(import.meta.dirname);
const { execBuildOrThrow, execClean } = setup(import.meta.dirname);

await execClean();
await execBuild();
await execBuildOrThrow();
4 changes: 2 additions & 2 deletions tests/build_tests/nested/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import * as fs from "node:fs/promises";
import * as path from "node:path";
import { setup } from "#dev/process";

const { execBuild, execClean } = setup(import.meta.dirname);
const { execBuildOrThrow, execClean } = setup(import.meta.dirname);

await execBuild();
await execBuildOrThrow();

const content = await fs.readFile(
path.join(import.meta.dirname, "src", "demo.js"),
Expand Down
4 changes: 2 additions & 2 deletions tests/build_tests/nnest/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import * as fs from "node:fs/promises";
import * as path from "node:path";
import { setup } from "#dev/process";

const { execBuild, execClean } = setup(import.meta.dirname);
const { execBuildOrThrow, execClean } = setup(import.meta.dirname);

await execBuild();
await execBuildOrThrow();

const content = await fs.readFile(
path.join(import.meta.dirname, "src", "demo.js"),
Expand Down
4 changes: 2 additions & 2 deletions tests/build_tests/ns/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

import { setup } from "#dev/process";

const { execBuild } = setup(import.meta.dirname);
const { execBuildOrThrow } = setup(import.meta.dirname);

await execBuild();
await execBuildOrThrow();
4 changes: 2 additions & 2 deletions tests/build_tests/react_ppx/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

import { setup } from "#dev/process";

const { execBuild } = setup(import.meta.dirname);
const { execBuildOrThrow } = setup(import.meta.dirname);

await execBuild();
await execBuildOrThrow();
2 changes: 1 addition & 1 deletion tests/build_tests/react_ppx/src/gpr_3695_test.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module React = {
type element
type componentLike<'props, 'return> = 'props => 'return
type component<'props> = 'props => element
}

module Test = {
Expand Down
2 changes: 1 addition & 1 deletion tests/build_tests/transitive_dependency/a/tests/test.res
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Js.Console.log("test")
Console.log("test")
6 changes: 4 additions & 2 deletions tests/build_tests/transitive_dependency/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import { existsSync } from "node:fs";
import * as path from "node:path";
import { setup } from "#dev/process";

const { execBuild, execClean } = setup(path.join(import.meta.dirname, "a"));
const { execBuildOrThrow, execClean } = setup(
path.join(import.meta.dirname, "a"),
);
await execClean();
await execBuild();
await execBuildOrThrow();

assert.ok(
!existsSync(
Expand Down
4 changes: 2 additions & 2 deletions tests/build_tests/uncurried-always/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { setup } from "#dev/process";

const { execBuild, execClean } = setup(import.meta.dirname);
const { execBuildOrThrow, execClean } = setup(import.meta.dirname);

await execBuild();
await execBuildOrThrow();
await execClean();
4 changes: 2 additions & 2 deletions tests/build_tests/unicode/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import * as fs from "node:fs/promises";
import * as path from "node:path";
import { setup } from "#dev/process";

const { execBuild, execClean } = setup(import.meta.dirname);
const { execBuildOrThrow, execClean } = setup(import.meta.dirname);

if (process.platform === "win32") {
console.log("Skipping test on Windows");
process.exit(0);
}

await execBuild();
await execBuildOrThrow();

await fs.access(
path.join(import.meta.dirname, "lib", "bs", "src", "📕annotation", "a.js"),
Expand Down
4 changes: 2 additions & 2 deletions tests/build_tests/x-y/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { setup } from "#dev/process";

const { execBuild, execClean } = setup(import.meta.dirname);
const { execBuildOrThrow, execClean } = setup(import.meta.dirname);

await execBuild();
await execBuildOrThrow();
await execClean();
Loading