mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
test: split napi tests into separate files (#21475)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -74,7 +74,6 @@ const testsPath = join(cwd, "test");
|
||||
const spawnTimeout = 5_000;
|
||||
const testTimeout = 3 * 60_000;
|
||||
const integrationTimeout = 5 * 60_000;
|
||||
const napiTimeout = 10 * 60_000;
|
||||
|
||||
function getNodeParallelTestTimeout(testPath) {
|
||||
if (testPath.includes("test-dns")) {
|
||||
@@ -1289,9 +1288,6 @@ function getTestTimeout(testPath) {
|
||||
if (/integration|3rd_party|docker|bun-install-registry|v8/i.test(testPath)) {
|
||||
return integrationTimeout;
|
||||
}
|
||||
if (/napi/i.test(testPath) || /v8/i.test(testPath)) {
|
||||
return napiTimeout;
|
||||
}
|
||||
return testTimeout;
|
||||
}
|
||||
|
||||
|
||||
52
test/napi/node-napi-tests/harness.ts
Normal file
52
test/napi/node-napi-tests/harness.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { spawn, spawnSync } from "bun";
|
||||
import { bunExe, bunEnv, isCI, isMusl } from "../../harness";
|
||||
|
||||
// Tests that intentionally abort and should not generate core dumps when they abort
|
||||
// due to a Node-API error
|
||||
const abortingJsNativeApiTests = ["test_finalizer/test_fatal_finalize.js"];
|
||||
|
||||
export async function build(dir: string) {
|
||||
const child = spawn({
|
||||
cmd: [bunExe(), "x", "node-gyp@11", "rebuild", "--debug", "-j", "max", "--verbose"],
|
||||
cwd: dir,
|
||||
stderr: "pipe",
|
||||
stdout: "ignore",
|
||||
stdin: "inherit",
|
||||
env: {
|
||||
...bunEnv,
|
||||
npm_config_target: "v24.3.0",
|
||||
CXXFLAGS: (bunEnv.CXXFLAGS ?? "") + (process.platform == "win32" ? " -std=c++20" : " -std=gnu++20"),
|
||||
// on linux CI, node-gyp will default to g++ and the version installed there is very old,
|
||||
// so we make it use clang instead
|
||||
...(process.platform == "linux" && isCI
|
||||
? {
|
||||
CC: !isMusl ? "/usr/lib/llvm-19/bin/clang" : "/usr/lib/llvm19/bin/clang",
|
||||
CXX: !isMusl ? "/usr/lib/llvm-19/bin/clang++" : "/usr/lib/llvm19/bin/clang++",
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
});
|
||||
await child.exited;
|
||||
if (child.exitCode !== 0) {
|
||||
const stderr = await new Response(child.stderr).text();
|
||||
console.error(`node-gyp rebuild in ${dir} failed:\n${stderr}`);
|
||||
console.error("bailing out!");
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
export function run(dir: string, test: string) {
|
||||
const env = abortingJsNativeApiTests.includes(test)
|
||||
? { ...bunEnv, BUN_INTERNAL_SUPPRESS_CRASH_ON_NAPI_ABORT: "1" }
|
||||
: bunEnv;
|
||||
const result = spawnSync({
|
||||
cmd: [bunExe(), "run", test],
|
||||
cwd: dir,
|
||||
stderr: "inherit",
|
||||
stdout: "ignore",
|
||||
stdin: "inherit",
|
||||
env,
|
||||
});
|
||||
expect(result.success).toBeTrue();
|
||||
expect(result.exitCode).toBe(0);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test.todoIf(["test.js", "test-uncaught.js", "test-async-hooks.js"].includes(file))(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test.todoIf(["test.js"].includes(file))(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test.todoIf(["test.js", "test-gcable.js", "test-gcable-callback.js"].includes(file))(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test.todoIf(["test.js"].includes(file))(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { isWindows } from "harness";
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
// https://github.com/oven-sh/bun/issues/12827 is the latter
|
||||
test.todoIf(["test-resolve-async.js", "test-async-hooks.js"].includes(file) || (file === "test.js" && isWindows))(
|
||||
file,
|
||||
() => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test.todoIf(["test.js"].includes(file))(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test.todoIf(["test.js", "test2.js", "test_threads.js"].includes(file))(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test.todoIf(["test.js"].includes(file))(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test.todoIf(["test.js"].includes(file))(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test.todoIf(["test-async-hooks.js"].includes(file))(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test.todoIf(["test.js"].includes(file))(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { isMacOS } from "harness";
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test.todoIf(["test.js"].includes(file) && isMacOS)(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test.todoIf(["test.js", "test_legacy_uncaught_exception.js"].includes(file))(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test.todoIf(["test.js"].includes(file))(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test.todoIf(["test.js", "node-options.js"].includes(file))(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test.todoIf(["test.js", "test-free-called.js"].includes(file))(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test.todoIf(["test.js"].includes(file))(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { basename, dirname, sep } from "node:path";
|
||||
import { build, run } from "../../../harness";
|
||||
|
||||
test("build", async () => {
|
||||
await build(import.meta.dir);
|
||||
});
|
||||
|
||||
for (const file of Array.from(new Bun.Glob("*.js").scanSync(import.meta.dir))) {
|
||||
test(file, () => {
|
||||
run(dirname(import.meta.dir), basename(import.meta.dir) + sep + file);
|
||||
});
|
||||
}
|
||||
@@ -1,171 +0,0 @@
|
||||
import { Glob, spawn, spawnSync } from "bun";
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { bunEnv, bunExe, isBroken, isCI, isIntelMacOS, isMusl, isWindows } from "harness";
|
||||
import { dirname, join } from "path";
|
||||
|
||||
const jsNativeApiRoot = join(__dirname, "node-napi-tests", "test", "js-native-api");
|
||||
const nodeApiRoot = join(__dirname, "node-napi-tests", "test", "node-api");
|
||||
|
||||
const jsNativeApiTests = Array.from(new Glob("**/*.js").scanSync(jsNativeApiRoot));
|
||||
const nodeApiTests = Array.from(new Glob("**/*.js").scanSync(nodeApiRoot));
|
||||
|
||||
// These js-native-api tests are known to fail and will be fixed in later PRs
|
||||
let failingJsNativeApiTests: string[] = [
|
||||
// We skip certain parts of test_string/test.js because we don't support creating empty external
|
||||
// strings. We don't skip the entire thing because the other tests are useful to check.
|
||||
// "test_string/test.js",
|
||||
];
|
||||
|
||||
// These are the tests from node-api that failed as of commit 83f536f4d, except for those that
|
||||
// passed in Bun v1.1.34. It'll take some time to get all these to work, as we've been focusing more
|
||||
// on js-native-api tests so far, and we don't want these tests to pollute CI. But we do want to
|
||||
// know if we regressed any of the other tests.
|
||||
let failingNodeApiTests = [
|
||||
"test_uv_threadpool_size/test.js",
|
||||
"test_uv_threadpool_size/node-options.js",
|
||||
"test_uv_loop/test.js",
|
||||
"test_callback_scope/test-resolve-async.js",
|
||||
"test_callback_scope/test-async-hooks.js",
|
||||
"test_fatal/test.js",
|
||||
"test_fatal/test2.js",
|
||||
"test_fatal/test_threads.js",
|
||||
"test_threadsafe_function/test.js",
|
||||
"test_threadsafe_function/test_legacy_uncaught_exception.js",
|
||||
"test_worker_buffer_callback/test.js",
|
||||
"test_worker_buffer_callback/test-free-called.js", // TODO(@heimskr)
|
||||
"test_make_callback_recurse/test.js",
|
||||
"test_buffer/test.js",
|
||||
"test_instance_data/test.js",
|
||||
"test_make_callback/test-async-hooks.js",
|
||||
"test_async_context/test.js",
|
||||
"test_async_context/test-gcable.js",
|
||||
"test_async_context/test-gcable-callback.js",
|
||||
"test_async_cleanup_hook/test.js",
|
||||
"test_async/test.js",
|
||||
"test_async/test-uncaught.js",
|
||||
"test_async/test-async-hooks.js",
|
||||
"test_general/test.js",
|
||||
"test_env_teardown_gc/test.js",
|
||||
"test_worker_terminate/test.js",
|
||||
];
|
||||
|
||||
if (isBroken && isIntelMacOS) {
|
||||
// TODO(@190n)
|
||||
// these are flaky on Intel Mac
|
||||
failingJsNativeApiTests.push("test_reference/test.js");
|
||||
failingNodeApiTests.push("test_reference_by_node_api_version/test.js");
|
||||
}
|
||||
|
||||
if (isWindows) {
|
||||
if (isBroken) {
|
||||
failingNodeApiTests.push("test_callback_scope/test.js"); // TODO: remove once #12827 is fixed
|
||||
}
|
||||
|
||||
for (const i in failingJsNativeApiTests) {
|
||||
failingJsNativeApiTests[i] = failingJsNativeApiTests[i].replaceAll("/", "\\");
|
||||
}
|
||||
for (const i in failingNodeApiTests) {
|
||||
failingNodeApiTests[i] = failingNodeApiTests[i].replaceAll("/", "\\");
|
||||
}
|
||||
}
|
||||
|
||||
if (isMusl) {
|
||||
failingNodeApiTests = nodeApiTests;
|
||||
failingJsNativeApiTests = jsNativeApiTests;
|
||||
}
|
||||
|
||||
// Tests that intentionally abort and should not generate core dumps when they abort
|
||||
// due to a Node-API error
|
||||
const abortingJsNativeApiTests = ["test_finalizer/test_fatal_finalize.js"];
|
||||
|
||||
for (const t of failingJsNativeApiTests) {
|
||||
if (!jsNativeApiTests.includes(t)) {
|
||||
console.error(`attempt to skip ${t} which is not a real js-native-api test`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
for (const t of failingNodeApiTests) {
|
||||
if (!nodeApiTests.includes(t)) {
|
||||
console.error(`attempt to skip ${t} which is not a real node-api test`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
const directories = jsNativeApiTests
|
||||
.filter(t => !failingJsNativeApiTests.includes(t))
|
||||
.map(t => join(jsNativeApiRoot, t))
|
||||
.concat(nodeApiTests.filter(t => !failingNodeApiTests.includes(t)).map(t => join(nodeApiRoot, t)))
|
||||
.map(t => dirname(t));
|
||||
const uniqueDirectories = Array.from(new Set(directories));
|
||||
|
||||
describe("build", () => {
|
||||
for (const dir of uniqueDirectories) {
|
||||
it(`${dir.slice(import.meta.dir.length + 1)}`, async () => {
|
||||
const child = spawn({
|
||||
cmd: [bunExe(), "x", "node-gyp@11", "rebuild", "--debug", "-j", "max"],
|
||||
cwd: dir,
|
||||
stderr: "pipe",
|
||||
stdout: "ignore",
|
||||
stdin: "inherit",
|
||||
env: {
|
||||
...bunEnv,
|
||||
npm_config_target: "v24.3.0",
|
||||
CXXFLAGS: (bunEnv.CXXFLAGS ?? "") + (process.platform == "win32" ? " -std=c++20" : " -std=gnu++20"),
|
||||
// on linux CI, node-gyp will default to g++ and the version installed there is very old,
|
||||
// so we make it use clang instead
|
||||
...(process.platform == "linux" && isCI
|
||||
? { "CC": "/usr/lib/llvm-19/bin/clang", CXX: "/usr/lib/llvm-19/bin/clang++" }
|
||||
: {}),
|
||||
},
|
||||
});
|
||||
await child.exited;
|
||||
if (child.exitCode !== 0) {
|
||||
const stderr = await new Response(child.stderr).text();
|
||||
console.error(`node-gyp rebuild in ${dir} failed:\n${stderr}`);
|
||||
console.error("bailing out!");
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe("js-native-api tests", () => {
|
||||
for (const test of jsNativeApiTests) {
|
||||
describe.skipIf(failingJsNativeApiTests.includes(test))(`${test}`, () => {
|
||||
it("passes", () => {
|
||||
const env = abortingJsNativeApiTests.includes(test)
|
||||
? { ...bunEnv, BUN_INTERNAL_SUPPRESS_CRASH_ON_NAPI_ABORT: "1" }
|
||||
: bunEnv;
|
||||
const result = spawnSync({
|
||||
cmd: [bunExe(), "run", test],
|
||||
cwd: jsNativeApiRoot,
|
||||
stderr: "inherit",
|
||||
stdout: "ignore",
|
||||
stdin: "inherit",
|
||||
env,
|
||||
});
|
||||
expect(result.success).toBeTrue();
|
||||
expect(result.exitCode).toBe(0);
|
||||
}, 60_000);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe("node-api tests", () => {
|
||||
for (const test of nodeApiTests) {
|
||||
describe.skipIf(failingNodeApiTests.includes(test))(`${test}`, () => {
|
||||
it("passes", () => {
|
||||
const result = spawnSync({
|
||||
cmd: [bunExe(), "run", test],
|
||||
cwd: nodeApiRoot,
|
||||
stderr: "inherit",
|
||||
stdout: "ignore",
|
||||
stdin: "inherit",
|
||||
env: bunEnv,
|
||||
});
|
||||
expect(result.success).toBeTrue();
|
||||
expect(result.exitCode).toBe(0);
|
||||
}, 60_000);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -252,9 +252,29 @@ test/js/third_party/prisma/prisma.test.ts
|
||||
test/js/third_party/remix/remix.test.ts
|
||||
test/js/third_party/resvg/bbox.test.js
|
||||
test/js/third_party/rollup-v4/rollup-v4.test.ts
|
||||
test/napi/node-napi.test.ts
|
||||
test/napi/uv.test.ts
|
||||
test/napi/uv_stub.test.ts
|
||||
test/napi/node-napi-tests/test/node-api/test_fatal_exception/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/test_typedarray/do.test.ts
|
||||
test/napi/node-napi-tests/test/node-api/test_async/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/test_symbol/do.test.ts
|
||||
test/napi/node-napi-tests/test/node-api/1_hello_world/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/test_instance_data/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/test_object/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/test_number/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/test_new_target/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/test_constructor/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/test_handle_scope/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/test_conversions/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/test_dataview/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/test_array/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/test_date/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/test_bigint/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/test_cannot_run_js/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/3_callbacks/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/4_object_factory/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/5_function_factory/do.test.ts
|
||||
test/napi/node-napi-tests/test/js-native-api/2_function_arguments/do.test.ts
|
||||
|
||||
# normalizeCryptoAlgorithmParameters
|
||||
test/js/node/test/parallel/test-webcrypto-derivekey.js
|
||||
|
||||
Reference in New Issue
Block a user