Skip to content
Open
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
5 changes: 5 additions & 0 deletions implementors/node/globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import "./features.js";
import "./assert.js";
import "./load-addon.js";
import "./gc.js";
import "./must-call.js";
50 changes: 9 additions & 41 deletions implementors/node/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,16 @@ import path from "node:path";

assert(
typeof import.meta.dirname === "string",
"Expecting a recent Node.js runtime API version"
"Expecting a recent Node.js runtime API version",
);

const ROOT_PATH = path.resolve(import.meta.dirname, "..", "..");
const TESTS_ROOT_PATH = path.join(ROOT_PATH, "tests");
const FEATURES_MODULE_PATH = path.join(
const GLOBALS_MODULE_PATH = path.join(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call this harness module? Though it installs global functions, I would prefer calling it with it's purpose, not it's solution.

Suggested change
const GLOBALS_MODULE_PATH = path.join(
const HARNESS_MODULE_PATH = path.join(

ROOT_PATH,
"implementors",
"node",
"features.js"
);
const ASSERT_MODULE_PATH = path.join(
ROOT_PATH,
"implementors",
"node",
"assert.js"
);
const LOAD_ADDON_MODULE_PATH = path.join(
ROOT_PATH,
"implementors",
"node",
"load-addon.js"
);
const GC_MODULE_PATH = path.join(
ROOT_PATH,
"implementors",
"node",
"gc.js"
);
const MUST_CALL_MODULE_PATH = path.join(
ROOT_PATH,
"implementors",
"node",
"must-call.js"
"globals.js",
);

export function listDirectoryEntries(dir: string) {
Expand All @@ -62,7 +38,7 @@ export function listDirectoryEntries(dir: string) {

export function runFileInSubprocess(
cwd: string,
filePath: string
filePath: string,
): Promise<void> {
return new Promise((resolve, reject) => {
const child = spawn(
Expand All @@ -71,18 +47,10 @@ export function runFileInSubprocess(
// Using file scheme prefix when to enable imports on Windows
"--expose-gc",
"--import",
"file://" + FEATURES_MODULE_PATH,
"--import",
"file://" + ASSERT_MODULE_PATH,
"--import",
"file://" + LOAD_ADDON_MODULE_PATH,
"--import",
"file://" + GC_MODULE_PATH,
"--import",
"file://" + MUST_CALL_MODULE_PATH,
"file://" + GLOBALS_MODULE_PATH,
filePath,
],
{ cwd }
{ cwd },
);

let stderrOutput = "";
Expand Down Expand Up @@ -111,9 +79,9 @@ export function runFileInSubprocess(
new Error(
`Test file ${path.relative(
TESTS_ROOT_PATH,
filePath
)} failed (${reason})${stderrSuffix}`
)
filePath,
)} failed (${reason})${stderrSuffix}`,
),
);
});
});
Expand Down
Loading