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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"@cosyte/eslint-config": "^0.1.4",
"@cosyte/prettier-config": "^0.1.2",
"@cosyte/process": "^0.1.10",
"@cosyte/script-utils": "^0.1.16",
"@cosyte/script-utils": "^0.1.17",
"@cosyte/synth": "^0.1.5",
"@cosyte/test-utils": "^0.1.4",
"@cosyte/tsconfig": "^0.1.2",
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion test/docs-content.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ const ENTRY_POINTS: Readonly<Record<string, string>> = {
const resolve = (specifier: string): string | undefined => ENTRY_POINTS[specifier];

beforeAll(() => {
execFileSync("pnpm", ["build"], { cwd: root, stdio: "inherit" });
// Windows starts `pnpm` only through its `.cmd` launcher, so a shell runs it there. The command
// and its argument are fixed strings.
execFileSync("pnpm", ["build"], {
cwd: root,
stdio: "inherit",
shell: process.platform === "win32",
});
}, 120_000);

/** The hand-written pages: every `.md` file at the top of `docs-content/`, not the generated `api/`. */
Expand Down
17 changes: 13 additions & 4 deletions test/pipe-close.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { spawn } from "node:child_process";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { createRequire } from "node:module";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { dirname, join } from "node:path";

import { afterAll, beforeAll, describe, expect, it } from "vitest";

Expand Down Expand Up @@ -58,7 +59,15 @@ import { EXIT } from "../src/core/exit-codes.js";
const SLOW_MS = 60_000;

const REPO_ROOT = process.cwd();
const TSX_BIN = join(REPO_ROOT, "node_modules", ".bin", "tsx");
/**
* The entry `tsx` declares in its own `package.json`, run with this Node. Starting
* `node_modules/.bin/tsx` instead needs a shell on Windows, where that name is a `.cmd` launcher.
*/
const TSX_MANIFEST = createRequire(import.meta.url).resolve("tsx/package.json");
const TSX_CLI = join(
dirname(TSX_MANIFEST),
(JSON.parse(readFileSync(TSX_MANIFEST, "utf8")) as { bin: string }).bin,
);
const COSYTE = join(REPO_ROOT, "src", "bin", "cosyte.ts");
const COSYTE_MCP = join(REPO_ROOT, "src", "bin", "cosyte-mcp.ts");

Expand Down Expand Up @@ -138,7 +147,7 @@ function spawnBin(argv: readonly string[], options: Options = {}): Promise<Spawn
return new Promise<Spawned>((resolve) => {
// Every stream is a pipe so this helper owns all three ends. Nothing reads the child's stdin
// unless a case supplies bytes for it, and it is released once the process is gone.
const child = spawn(TSX_BIN, [...argv], {
const child = spawn(process.execPath, [TSX_CLI, ...argv], {
cwd: REPO_ROOT,
shell: false,
stdio: ["pipe", "pipe", "pipe"],
Expand Down
5 changes: 1 addition & 4 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,12 @@ const DENO_EXCLUDES: readonly string[] = [
* (`.cmd` launchers). What they test runs on Linux and macOS in CI, and the library API and both
* bins' code paths run on Windows in every other file.
*
* - `test/pipe-close.test.ts`: it starts each bin through `node_modules/.bin/tsx` and closes its
* stdout, to prove how the Node process exits.
* - `test/release-install-gate.test.ts`: it runs the release install gate, which packs with pnpm
* and installs with npm, a step that runs on Linux in the release workflow.
* - `test/docs-content.test.ts`: it runs a bare `pnpm build`, and its shell samples run under bash.
* - `test/docs-content.test.ts`: its shell samples run under bash.
* - `test/docs-standard.test.ts`: it starts `node_modules/.bin/cosyte-docs-content` directly.
*/
const WINDOWS_EXCLUDES: readonly string[] = [
"test/pipe-close.test.ts",
"test/release-install-gate.test.ts",
"test/docs-content.test.ts",
"test/docs-standard.test.ts",
Expand Down
Loading