Skip to content
This repository was archived by the owner on May 24, 2026. It is now read-only.
Closed
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
27 changes: 26 additions & 1 deletion typescript-sdk/scripts/template-tests.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
import { spawnSync } from "node:child_process";
import { existsSync, readdirSync } from "node:fs";
import path from "node:path";

const repoRoot = new URL("../..", import.meta.url);

const suites = [
"runtime/tests/*.test.mjs",
"typescript-sdk/tests/*.test.mjs"
];

function hasGlobMatches(pattern) {
const dir = pattern.slice(0, pattern.lastIndexOf("/"));
const namePattern = pattern.slice(pattern.lastIndexOf("/") + 1);
const dirPath = path.resolve(repoRoot.pathname, dir);

if (!existsSync(dirPath)) {
return false;
}

const matcher = new RegExp(
`^${namePattern.replace(/[.+?^${}()|[\\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`
);

return readdirSync(dirPath).some((file) => matcher.test(file));
}

for (const pattern of suites) {
if (!hasGlobMatches(pattern)) {
continue;
}

const run = spawnSync("node", ["--test", pattern], {
stdio: "inherit",
cwd: new URL("../..", import.meta.url)
cwd: repoRoot
});

if (run.status !== 0) {
process.exit(run.status ?? 1);
}
Expand Down
Loading