Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
dc33bb3
test: the in-memory filesystem reads Windows and POSIX paths as one e…
V3RON Nov 18, 2026
d5aef53
feat(ports): the in-memory filesystem reads Windows and POSIX paths a…
V3RON Nov 18, 2026
38b8007
test: CI runs the unit tests on Windows and Quality needs that job (#…
V3RON Nov 18, 2026
a693e45
ci: the unit tests run on Windows and Quality needs that job (#1705)
V3RON Nov 18, 2026
16079c4
test: windowsSkipped is the Windows job's list of left-out files (#1705)
V3RON Nov 18, 2026
2c6ae4d
feat(test): the unit project leaves out windowsSkipped on a Windows h…
V3RON Nov 18, 2026
99e418b
docs: toolchain, testing rule 5 and the test-support manual name the …
V3RON Nov 18, 2026
3999175
fix(ports): the in-memory filesystem reads backslashes only in absolu…
V3RON Nov 18, 2026
f288e6f
Merge origin/feature/1693-adr into task/1705
V3RON Nov 18, 2026
dfdad82
test: the Windows job leaves out the files that failed in three runs …
V3RON Nov 18, 2026
c4eafec
test: the printed-text path check leaves out src/test-support, which …
V3RON Nov 18, 2026
9f30279
test: the Windows job also leaves out rig-ports.e2e.test.ts, which fa…
V3RON Nov 18, 2026
cd00f14
test: the Windows job also leaves out docs-surface-check and host-loa…
V3RON Nov 18, 2026
47cbf17
fix(ports): the real directorySize keeps its path; the fake's injecte…
V3RON Nov 18, 2026
7fee05c
fix(ports): the relative-path case of the fake fails when a relative …
V3RON Nov 18, 2026
60623b3
test(ports): a relative `rel/file` is not the injected `rel\\file` (#…
V3RON Nov 18, 2026
fe879d1
Merge remote-tracking branch 'origin/feature/1693-adr' into HEAD
V3RON Nov 18, 2026
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
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
# a union merge keeps both instead of stopping the stack sync on an add/add conflict. The
# src/adr-index.repo.test.ts check keeps the table complete and in order.
docs/internal/adr/README.md merge=union

# why: a Windows checkout would otherwise turn text files into CRLF, which breaks the tests that
# compare file text and the scripts bash runs.
* text=auto eol=lf
32 changes: 31 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,36 @@ jobs:
- name: Unit tests
run: pnpm run test:unit

# why: the Windows paths are otherwise tested only by passing `platform: "win32"` on Linux;
# bash is Git Bash, which the repository's tooling needs on Windows (ADR 0087 section 6).
windows-unit:
name: Unit tests (Windows)
runs-on: windows-2025
permissions:
contents: read
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.13"
- name: Enable Corepack
run: |
corepack enable
corepack prepare pnpm@12.8.1+sha512.f64ba907507f5ceafe06c8d38e6052d0179444580ec1279ddd5bfc11cb48aa8a2644b66598e07e761da84872a9fc57d5f902b87fa49d024198d558612aabbe45 --activate
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Unit tests
run: pnpm run test:unit

timing:
name: Timing tests
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -126,7 +156,7 @@ jobs:
# by a failed need would count as passed.
quality:
name: Quality
needs: [static, unit, timing, e2e]
needs: [static, unit, windows-unit, timing, e2e]
if: always()
runs-on: ubuntu-24.04
permissions: {}
Expand Down
6 changes: 5 additions & 1 deletion docs/internal/agent-rules/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ here and moves into its module's test file.
guesses. Check out the base commit, run the same test, and let the result
decide; a failure that reproduces there is not yours to fix in this
change, and one that does not reproduce is yours. Never skip, disable, or
quarantine a test to get to green.
quarantine a test to get to green. A test of a fact Windows does not have
(a POSIX mode, a launchd file) is skipped on `win32`: that is not
skipping to get to green. Until the Windows feature ends, the files on
`src/test-support/windows-skipped.ts` are left out of the Windows job
too, and that list only shrinks.
Most flakes are written, not found: an assertion on a deadline, a
duration, a throughput or a frame time without a fake clock passes on
an idle machine and fails on a loaded runner. A bound on real time
Expand Down
10 changes: 7 additions & 3 deletions docs/internal/agent-rules/toolchain.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ list and this one the same.
`.fallowrc.json` limits, and refactoring targets never fail. Its findings
show as annotations on the PR. A `fallow-ignore` comment names its reason
after ` -- `, and one that no longer hides a finding fails. The `pnpm
check` steps run as parallel jobs (static checks, unit tests, the timing
tests, the e2e lane in three shards); the Quality check passes only when all of them
do. The console DOM tests run with the unit tests. The console lane runs
check` steps run as parallel jobs (static checks, unit tests, the unit
tests on Windows, the timing tests, the e2e lane in three shards); the
Quality check passes only when all of them do. A contributor on Windows
runs the tests from Git Bash with Python 3 installed, never PowerShell. A
failure only the `Unit tests (Windows)` job shows is reproduced by
rerunning that job on the base commit's CI run (`gh run rerun <run> --job
<job>`), not locally. The console DOM tests run with the unit tests. The console lane runs
in Chromium in two shards (the required Console check passes only when
they all do) on every push to `main`, and on a pull request when it
changes a source, UI, console spec or build file.
Expand Down
2 changes: 1 addition & 1 deletion src/docs-audience.repo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const REPO_PATH =
const printingSources = trackedFiles.filter(
(name) =>
/^(?:src|ui\/src)\/.+\.tsx?$/.test(name) &&
!/\.test\.tsx?$|(?:^|\/)testing\.ts$|(?:^|\/)test-[^/]*$/.test(name),
!/\.test\.tsx?$|(?:^|\/)testing\.ts$|(?:^|\/)test-[^/]*$|^src\/test-support\//.test(name),
);

function repoPaths(name: string, text: string): string[] {
Expand Down
76 changes: 46 additions & 30 deletions src/ports/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ export class MemoryFilesystem implements Filesystem {
}

async readFile(path: string): Promise<string> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);
const entry = this.#entryAt(path);

if (entry.kind !== "file") {
Expand All @@ -529,7 +529,7 @@ export class MemoryFilesystem implements Filesystem {
body: ReadableStream<Uint8Array>,
options: { readonly mode?: number } = {},
): Promise<number> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);
path = this.#underResolvedParent(path);
this.#requireDirectory(parentPath(path));
if (this.#entries.has(path)) throw errnoError("EEXIST", `File already exists: ${path}`);
Expand All @@ -549,7 +549,7 @@ export class MemoryFilesystem implements Filesystem {
}

async openFile(path: string): Promise<OpenedFile> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);
const entry = this.#entryAt(path);
if (entry.kind !== "file") throw errnoError("EISDIR", `Is a directory: ${path}`);
const bytes = fileBytes(entry);
Expand All @@ -573,8 +573,8 @@ export class MemoryFilesystem implements Filesystem {
to: string,
_options: { readonly timeoutMs: number },
): Promise<void> {
this.#failIfDefined(from);
this.#failIfDefined(to);
from = this.#failIfDefined(from);
to = this.#failIfDefined(to);
this.#rawEntryAt(from);
if (this.#entries.has(to)) throw errnoError("EEXIST", `File already exists: ${to}`);
this.#requireDirectory(parentPath(to));
Expand Down Expand Up @@ -602,7 +602,7 @@ export class MemoryFilesystem implements Filesystem {
contents: string,
options?: WriteFileAtomicOptions,
): Promise<void> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);
path = this.#underResolvedParent(path);
this.#requireDirectory(parentPath(path));
this.#entries.set(path, {
Expand All @@ -616,7 +616,7 @@ export class MemoryFilesystem implements Filesystem {
contents: string,
options: { readonly mode: number },
): Promise<void> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);
path = this.#underResolvedParent(path);
const existing = this.#entries.get(path);

Expand All @@ -635,7 +635,7 @@ export class MemoryFilesystem implements Filesystem {
contents: string,
options?: WriteFileExclusiveOptions,
): Promise<void> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);
path = this.#underResolvedParent(path);

if (this.#entries.has(path)) {
Expand All @@ -650,7 +650,7 @@ export class MemoryFilesystem implements Filesystem {
}

async mkdirp(path: string, options: MkdirpOptions = {}): Promise<void> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);
let currentPath = "";

for (const segment of path.split("/")) {
Expand Down Expand Up @@ -678,8 +678,8 @@ export class MemoryFilesystem implements Filesystem {
* is what tells it another process won the race.
*/
async rename(from: string, to: string): Promise<void> {
this.#failIfDefined(from);
this.#failIfDefined(to);
from = this.#failIfDefined(from);
to = this.#failIfDefined(to);
const moved = this.#rawEntryAt(from);
const occupant = this.#entries.get(to);

Expand Down Expand Up @@ -714,7 +714,7 @@ export class MemoryFilesystem implements Filesystem {
}

async rm(path: string): Promise<void> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);
const prefix = path.endsWith("/") ? path : `${path}/`;

for (const entryPath of this.#entries.keys()) {
Expand All @@ -725,7 +725,7 @@ export class MemoryFilesystem implements Filesystem {
}

async stat(path: string): Promise<FileStat> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);
const entry = this.#entryAt(path);

return {
Expand All @@ -738,14 +738,14 @@ export class MemoryFilesystem implements Filesystem {
}

async lstat(path: string): Promise<PathDetails> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);
const entry = this.#rawEntryAt(path);

return { kind: entry.kind, uid: entry.uid, mode: entry.mode };
}

async mkdir(path: string, options: { readonly mode?: number } = {}): Promise<void> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);
path = this.#underResolvedParent(path);

if (this.#entries.has(path)) {
Expand All @@ -759,12 +759,12 @@ export class MemoryFilesystem implements Filesystem {
}

async chmod(path: string, mode: number): Promise<void> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);
this.#rawEntryAt(path).mode = mode & 0o777;
}

async realpath(path: string): Promise<string> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);
const resolved = this.#resolveLinks(path, 0);

if (!this.#entries.has(resolved)) {
Expand All @@ -775,7 +775,7 @@ export class MemoryFilesystem implements Filesystem {
}

async readdir(path: string): Promise<string[]> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);
this.#requireDirectory(path);
const prefix = path === "/" ? "/" : `${path}/`;
const children = new Set<string>();
Expand All @@ -802,7 +802,7 @@ export class MemoryFilesystem implements Filesystem {
* the double pass for correct.
*/
async exists(path: string): Promise<boolean> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);

try {
this.#entryAt(path);
Expand All @@ -827,10 +827,10 @@ export class MemoryFilesystem implements Filesystem {
}

async directorySize(path: string): Promise<number> {
path = memoryPath(path);
let total = 0;
for (const name of await this.readdir(path)) {
const child = joinMemoryPath(path, name);
this.#failIfDefined(child);
const child = this.#failIfDefined(joinMemoryPath(path, name));
const entry = this.#rawEntryAt(child);
if (entry.kind === "directory") total += await this.directorySize(child);
else if (entry.kind === "file") total += fileBytes(entry).byteLength;
Expand All @@ -839,22 +839,23 @@ export class MemoryFilesystem implements Filesystem {
}

async readlink(path: string): Promise<string> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);
const entry = this.#rawEntryAt(this.#underResolvedParent(path));
if (entry.kind !== "symlink") throw errnoError("EINVAL", `Not a symbolic link: ${path}`);
return entry.target;
}

async replaceSymlink(path: string, target: string): Promise<void> {
this.#failIfDefined(path);
async replaceSymlink(path: string, given: string): Promise<void> {
path = this.#failIfDefined(path);
const target = memoryPath(given);
const at = this.#underResolvedParent(path);
const entry = this.#rawEntryAt(at);
if (entry.kind !== "symlink") throw errnoError("EINVAL", `Not a symbolic link: ${path}`);
this.#entries.set(at, { ...this.#newEntry({ kind: "symlink", target }), uid: entry.uid });
}

async writeAt(path: string, offset: number, bytes: Uint8Array): Promise<void> {
this.#failIfDefined(path);
path = this.#failIfDefined(path);
const entry = this.#entryAt(path);
if (entry.kind !== "file") throw errnoError("EISDIR", `Is a directory: ${path}`);
const old = fileBytes(entry);
Expand All @@ -870,18 +871,21 @@ export class MemoryFilesystem implements Filesystem {
* reach the branches that turn an unexpected filesystem failure into a typed rejection.
*/
defineFailure(path: string, code: string): void {
this.#failures.set(path, code);
this.#failures.set(memoryPath(path), code);
}

defineSymlink(path: string, target: string): void {
this.#entries.set(path, this.#newEntry({ kind: "symlink", target }));
this.#entries.set(
memoryPath(path),
this.#newEntry({ kind: "symlink", target: memoryPath(target) }),
);
}

defineAttributes(
path: string,
attributes: { readonly uid?: number; readonly mode?: number; readonly modifiedAtMs?: number },
): void {
const entry = this.#rawEntryAt(path);
const entry = this.#rawEntryAt(memoryPath(path));

if (attributes.uid !== undefined) {
entry.uid = attributes.uid;
Expand All @@ -896,11 +900,14 @@ export class MemoryFilesystem implements Filesystem {
}
}

#failIfDefined(path: string): void {
/** why: every method that takes a path and can fail enters here, so the one place that fails an injected path is also the one that reads a path in either style. */
#failIfDefined(given: string): string {
const path = memoryPath(given);
const code = this.#failures.get(path);
if (code !== undefined) {
throw errnoError(code, `Injected ${code} failure: ${path}`);
throw errnoError(code, `Injected ${code} failure: ${given}`);
}
return path;
}

#newEntry(kind: MemoryEntryKind): MemoryEntry {
Expand Down Expand Up @@ -976,6 +983,15 @@ function fileBytes(entry: { readonly contents: string; readonly bytes?: Uint8Arr
return entry.bytes ?? Buffer.from(entry.contents, "utf8");
}

/**
* why: the fake reads `D:\a\b`, `\a\b` and `/a/b` as one entry, so a test written for the host's
* path style passes on every host; production code keeps `node:path`.
*/
function memoryPath(path: string): string {
const absolute = path.replace(/^[A-Za-z]:(?=[\\/]|$)/, "");
return /^[\\/]/.test(absolute) ? absolute.replaceAll("\\", "/") : path;
}

function joinMemoryPath(parent: string, child: string): string {
return parent === "/" || parent === "" ? `/${child}` : `${parent}/${child}`;
}
Expand Down
Loading
Loading