From 969aa7219c940afb67311c89e146325585af916f Mon Sep 17 00:00:00 2001 From: oliver <54379826+ok@users.noreply.github.com> Date: Thu, 26 Nov 2026 21:55:33 +0100 Subject: [PATCH 1/2] [ci] Add nightly test jobs for macOS and Windows Runs the unit, flow and bare suites on both systems, nightly and by hand; they gate nothing yet. The bare runner now starts through Node so Windows can launch it, and text is checked out as LF everywhere. --- .claude/testing.md | 8 ++ .gitattributes | 4 + .github/workflows/test-platforms.yml | 111 +++++++++++++++++++++++++++ scripts/ci/run-flow-shard.sh | 52 +++++++++++++ test/bare-runner.mjs | 14 +++- 5 files changed, 185 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/test-platforms.yml create mode 100755 scripts/ci/run-flow-shard.sh diff --git a/.claude/testing.md b/.claude/testing.md index 9a3597f3d..e516abacb 100644 --- a/.claude/testing.md +++ b/.claude/testing.md @@ -192,6 +192,14 @@ the **user-facing outcome** at the UI layer. Don't force a flaky UI assertion. (integration, sharded 4x, `MIRALL_TEST_TIMEOUT_SCALE=3`, one process per file with a single retry of a failed file), and **flake-ledger**, which grades each suite's pass-on-retry count against its own `test/-flake-budget.json`. Green CI is required to merge. +- **CI on macOS and Windows (nightly and manual, not a gate):** + `.github/workflows/test-platforms.yml` runs `test:node:core`, the flow shards (socket and headless + slices included) and the bare shards on `macos-15` and `windows-latest`. It has no push or + pull-request trigger, so a red there blocks no merge and no release; a job becomes a gate by + moving to those triggers once it is green on its system. Typecheck, lint and knip stay Linux-only, + and these jobs are outside the flake ledger: its budgets are measured on the Linux runners. The + flow shard loop is `scripts/ci/run-flow-shard.sh`. The checkout is LF on every system + (`.gitattributes`), which the invariant tests and the shell scripts rely on. - **Local (you run it — not optional):** `npm run test:fe` is **required** for any UI-affecting change and runs fine on a dev machine (only CI can't drive the AX tree). The agent runs the scenarios covering the change itself, in background mode, without asking — for bug fixes, new diff --git a/.gitattributes b/.gitattributes index a54bf55ab..068d1d4e8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,6 @@ +# Text is LF in the index and in every checkout, on every system: the invariant tests read source +# files by line, and the shell scripts the tests and CI run do not survive a CRLF checkout. +* text=auto eol=lf + # Byte-pinned by test/invariants/backup-fixtures-frozen.test.js: never converted on checkout. test/fixtures/backup/** -text diff --git a/.github/workflows/test-platforms.yml b/.github/workflows/test-platforms.yml new file mode 100644 index 000000000..1109e30cd --- /dev/null +++ b/.github/workflows/test-platforms.yml @@ -0,0 +1,111 @@ +name: Test (macOS, Windows) + +# The suites test.yml runs on Linux, on the two other systems the app ships for. These jobs gate +# nothing: they run nightly and by hand, never on a push or a pull request, so a red here blocks no +# merge and no release. A job becomes a gate only by moving to push and pull_request triggers, and +# only once it is green on its system. Typecheck, lint and the dead-code report read the source and +# give the same answer everywhere, so they stay in test.yml. +# +# Outside the flake ledger: the budgets in test/*-flake-budget.json are measured on the Linux +# runners, and a retry here would spend them without saying anything about that suite. The reports +# are uploaded all the same, in the ledger's shape, so a budget per system can be set from them. +on: + workflow_dispatch: + schedule: + - cron: '17 2 * * *' + +permissions: + contents: read + +# Bash everywhere: on Windows the default is PowerShell, which reads none of the steps below. +defaults: + run: + shell: bash + +jobs: + # Unit, invariant and raw-mechanics tests under Node. + node: + name: node (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + os: [macos-15, windows-latest] + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: ./.github/actions/setup + - name: Tests (unit + raw) + run: npm run test:node:core + + # The two-peer flow shards, partitioned and retried exactly as in test.yml. Shards 7 and 8 re-run + # slice 1 over the worker socket and against headless workers, one transport each, per system. + flow: + name: flow (${{ matrix.os }}, ${{ matrix.shard }}, ${{ matrix.transport }}) + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + os: [macos-15, windows-latest] + shard: [1, 2, 3, 4, 5, 6] + transport: [pipe] + include: + - { os: macos-15, shard: 7, slice: 1, transport: socket } + - { os: macos-15, shard: 8, slice: 1, transport: headless } + - { os: windows-latest, shard: 7, slice: 1, transport: socket } + - { os: windows-latest, shard: 8, slice: 1, transport: headless } + env: + MIRALL_TEST_TIMEOUT_SCALE: '3' + MIRALL_TEST_IPC_TRANSPORT: ${{ matrix.transport }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: ./.github/actions/setup + - name: Flow tests (shard ${{ matrix.shard }}, ${{ matrix.transport }}) + run: >- + bash scripts/ci/run-flow-shard.sh + ${{ matrix.shard }} ${{ matrix.slice || matrix.shard }} 6 + "${{ matrix.transport }}, ${{ matrix.os }}" + - name: Upload flake report + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: flake-report-${{ matrix.os }}-${{ matrix.shard }} + path: flake-report + if-no-files-found: ignore + + # The integration shards under Bare, one process per file, as in test.yml. + bare: + name: bare (${{ matrix.os }}, ${{ matrix.shard }}) + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + os: [macos-15, windows-latest] + shard: [1, 2, 3, 4] + env: + MIRALL_TEST_TIMEOUT_SCALE: '3' + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: ./.github/actions/setup + # Through bare-runtime's Node launcher, the way test/bare-runner.mjs starts it: a missing + # prebuild for this system fails here, by name, instead of once per test file. + - name: Check the bare runtime starts + run: node node_modules/bare-runtime/bin/bare --version + - name: Integration tests (shard ${{ matrix.shard }}/4) + run: | + files="$(node test/bare-shard.mjs ${{ matrix.shard }} 4)" + # One spelling of a path on every system, so a report names a file the same way everywhere. + files="${files//\\//}" + echo "Shard ${{ matrix.shard }}/4:"; echo "$files" | tr ' ' '\n' + node test/bare-runner.mjs --jobs 2 --retries 1 \ + --report flake-report/flake-${{ matrix.shard }}.json \ + --shard-label ${{ matrix.shard }} $files + - name: Upload flake report + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: bare-flake-report-${{ matrix.os }}-${{ matrix.shard }} + path: flake-report + if-no-files-found: ignore diff --git a/scripts/ci/run-flow-shard.sh b/scripts/ci/run-flow-shard.sh new file mode 100755 index 000000000..fedf45b31 --- /dev/null +++ b/scripts/ci/run-flow-shard.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# Runs one flow shard the way CI grades it: every file in its own runner process, so one file's +# crash cannot abort the rest, then ONLY the failed files once more. A file that passes on the +# retry is a flake, recorded in flake-report/flake-.json in the shape +# scripts/ci/flake-ledger.mjs reads; a file that fails twice fails the shard. The first attempt's +# output of every failed file is kept under flake-report/logs: a flake that only reproduces in CI +# cannot be diagnosed from an annotation. +# +# The transport is not an argument: test/helpers/peer.js reads MIRALL_TEST_IPC_TRANSPORT. +# +# Usage: scripts/ci/run-flow-shard.sh <1-based slice> [name] +# a number; names the report file and the annotations +# which partition of test/flow-shard.mjs to run (differs from the label when a +# shard re-runs another shard's files over a second transport) +# [name] shown beside the label in the log and the step summary, e.g. "socket, windows" +set -euo pipefail + +cd "$(dirname "$0")/../.." + +shard="${1:?usage: run-flow-shard.sh [name]}" +slice="${2:?missing slice}" +total="${3:?missing slice total}" +name="${4:-${MIRALL_TEST_IPC_TRANSPORT:-pipe}}" + +files="$(node test/flow-shard.mjs "$slice" "$total")" +# One spelling of a path on every system: the report's file names are compared across runs, and a +# backslash is neither a path separator to bash nor a legal character in the JSON written below. +files="${files//\\//}" +echo "Shard $shard ($name):"; echo "$files" | tr ' ' '\n' +mkdir -p flake-report/logs + +failed="" +for f in $files; do + log="flake-report/logs/$(echo "$f" | tr '/' '_').log" + if node test/flow-runner.mjs "$f" >"$log" 2>&1; then rm -f "$log"; else cat "$log"; failed="$failed $f"; fi +done + +entries="" +status=0 +if [ -n "$failed" ]; then + echo "::warning title=Flow shard $shard ($name) flaked::retried$failed (a pass-on-retry is a residual flake — the failed attempt's output is in the flake-report artifact)" + for f in $failed; do + if node test/flow-runner.mjs "$f"; then passed=true; else passed=false; status=1; fi + entries="$entries{\"file\":\"$f\",\"attempts\":2,\"passedOnRetry\":$passed}," + done +fi + +printf '{"shard":%s,"files":[%s]}\n' "$shard" "${entries%,}" > "flake-report/flake-$shard.json" +if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then + { echo "### Flow shard $shard ($name)"; if [ -z "$failed" ]; then echo "No retries."; else echo "Retried:$failed"; fi; } >> "$GITHUB_STEP_SUMMARY" +fi +exit $status diff --git a/test/bare-runner.mjs b/test/bare-runner.mjs index 5ebf13922..0f824884b 100644 --- a/test/bare-runner.mjs +++ b/test/bare-runner.mjs @@ -43,9 +43,15 @@ function fail(message) { process.exit(1) } -// The bare binary lives in node_modules/.bin, which npm puts on PATH for a script it runs but which -// a direct `node test/bare-runner.mjs` does not have. brittle-bare's shebang resolves `bare` from -// PATH, so the child gets it either way. +// Both are started as scripts handed to an interpreter, never through their node_modules/.bin +// entries: those are shebang files on macOS and Linux and `.cmd` shims on Windows, and a spawn +// without a shell can run neither kind on Windows. bare-runtime's launcher is a Node script that +// starts the platform's bare binary on brittle's entry, which is the chain the shebangs resolve to. +const BARE_LAUNCHER = path.join('node_modules', 'bare-runtime', 'bin', 'bare') +const BRITTLE_ENTRY = path.join('node_modules', 'brittle', 'brittle-bare.js') + +// node_modules/.bin is on PATH for a script npm runs, but not for a direct +// `node test/bare-runner.mjs`. A test that starts `bare` by name gets it either way. function childEnv() { const bin = path.resolve('node_modules/.bin') return { ...process.env, PATH: `${bin}${path.delimiter}${process.env.PATH || ''}` } @@ -54,7 +60,7 @@ function childEnv() { function runFile(file) { return new Promise((resolve) => { const startedAt = Date.now() - const child = spawn(path.join('node_modules', '.bin', 'brittle-bare'), [file], { + const child = spawn(process.execPath, [BARE_LAUNCHER, BRITTLE_ENTRY, file], { env: childEnv(), stdio: ['ignore', 'pipe', 'pipe'], }) From 1039e2c71e8fd6f1658a0d463e9732d2ef412fa8 Mon Sep 17 00:00:00 2001 From: oliver <54379826+ok@users.noreply.github.com> Date: Fri, 27 Nov 2026 08:14:54 +0100 Subject: [PATCH 2/2] [test] Make the Node unit suite pass on Windows The suite assumed POSIX in its tests: path separators in tree scans, a bare bash, socket file paths, a Unix abort code, timer order. Each now uses the form its system gives. What exists only on POSIX (mode bits, uid) is skipped on Windows with its reason, and testing.md states the portability rules. --- .claude/testing.md | 12 +++++ test/helpers/bash.js | 16 +++++++ test/helpers/listen-address.js | 10 +++++ test/invariants/engine-boundaries.test.js | 5 ++- test/invariants/engine-license-notice.test.js | 2 +- test/invariants/main-env-reads.test.js | 2 +- test/invariants/path-field-harmonized.test.js | 2 +- test/invariants/poll-helper.test.js | 8 ++-- .../renderer-no-window-channels.test.js | 2 +- .../renderer-primitive-single-source.test.js | 2 +- test/invariants/sck-epoch-plumbing.test.js | 2 +- test/raw/update-mode.test.js | 3 +- test/unit/audit-coverage.test.js | 2 +- test/unit/bare-runner.test.js | 6 ++- test/unit/comment-hygiene-gate.test.js | 5 ++- test/unit/config-store.test.js | 6 ++- test/unit/event-taxonomy.test.js | 2 +- test/unit/fetch-verified.test.js | 9 ++-- test/unit/forge-linux-makers.test.js | 5 +-- test/unit/relay-secret.test.js | 6 ++- test/unit/reveal-host-gate.test.js | 5 +++ test/unit/window-connections.test.js | 7 ++- test/unit/worker-host.test.js | 44 +++++++++++-------- test/unit/worker-request.test.js | 6 ++- 24 files changed, 119 insertions(+), 50 deletions(-) create mode 100644 test/helpers/bash.js create mode 100644 test/helpers/listen-address.js diff --git a/.claude/testing.md b/.claude/testing.md index e516abacb..3ce557581 100644 --- a/.claude/testing.md +++ b/.claude/testing.md @@ -200,6 +200,18 @@ the **user-facing outcome** at the UI layer. Don't force a flaky UI assertion. and these jobs are outside the flake ledger: its budgets are measured on the Linux runners. The flow shard loop is `scripts/ci/run-flow-shard.sh`. The checkout is LF on every system (`.gitattributes`), which the invariant tests and the shell scripts rely on. +- **A test runs on Windows too.** Four rules keep it portable: + - A relative path that is compared, matched or printed is spelled with `/`: + `path.relative(...).split(path.sep).join('/')`. + - A file URL becomes a path with `fileURLToPath`, or is passed on as the URL. `new URL(...).pathname` + gives `/C:/…`, which resolves to a wrong path. + - A shell script is started through `test/helpers/bash.js`, never a bare `bash`: it is not on + the path on Windows, or is the WSL launcher. A path handed to the script uses `/`. + - The temp folder is inside the home folder on Windows. A test that tells "under home" from + "outside home" sets the home folder itself. + + A property that exists only on POSIX (mode bits, uid, a read-only folder) is skipped on Windows + with its reason, and the part that holds everywhere is kept in a test of its own. - **Local (you run it — not optional):** `npm run test:fe` is **required** for any UI-affecting change and runs fine on a dev machine (only CI can't drive the AX tree). The agent runs the scenarios covering the change itself, in background mode, without asking — for bug fixes, new diff --git a/test/helpers/bash.js b/test/helpers/bash.js new file mode 100644 index 000000000..33655a5af --- /dev/null +++ b/test/helpers/bash.js @@ -0,0 +1,16 @@ +// The shell the repository's scripts run under, for a test that spawns one. On Windows a bare +// `bash` can resolve to the WSL launcher, which reads no Windows path, so the bash that Git for +// Windows installs is named outright where it exists. +import { existsSync } from 'node:fs' +import path from 'node:path' + +function gitForWindowsBash() { + const exe = path.join(process.env.ProgramFiles || 'C:\\Program Files', 'Git', 'bin', 'bash.exe') + return existsSync(exe) ? exe : 'bash' +} + +export const BASH = process.platform === 'win32' ? gitForWindowsBash() : 'bash' + +// A script path as bash reads it: forward slashes on every system, since a backslash is an escape +// to the shell and to the tools a script hands the path on to. +export const shellPath = (p) => p.split(path.sep).join('/') diff --git a/test/helpers/listen-address.js b/test/helpers/listen-address.js new file mode 100644 index 000000000..2c9aad9a7 --- /dev/null +++ b/test/helpers/listen-address.js @@ -0,0 +1,10 @@ +// Where a test's stand-in for the worker listens, the way the worker itself does on this system: a +// socket file in the given directory on POSIX, a named pipe on Windows, which binds no socket to a +// file path. +import path from 'node:path' +import { randomBytes } from 'node:crypto' + +export function listenAddress(dir, name) { + if (process.platform !== 'win32') return path.join(dir, name) + return '\\\\.\\pipe\\mirall-test-' + randomBytes(16).toString('hex') +} diff --git a/test/invariants/engine-boundaries.test.js b/test/invariants/engine-boundaries.test.js index f3d0e398a..102937ade 100644 --- a/test/invariants/engine-boundaries.test.js +++ b/test/invariants/engine-boundaries.test.js @@ -32,6 +32,9 @@ function walk(dir, out = []) { return out } +// One spelling of a path on every system, the one the allowlist is written in. +const rel = (from, to) => path.relative(from, to).split(path.sep).join('/') + function engineImports() { const found = [] for (const file of [...walk(path.join(root, 'src')), ...walk(path.join(root, 'scripts'))]) { @@ -39,7 +42,7 @@ function engineImports() { for (const m of readFileSync(file, 'utf8').matchAll(/(?:from|import)\s*\(?\s*'([^']+)'/g)) { if (!m[1].startsWith('.')) continue const target = path.resolve(path.dirname(file), m[1]) - if (target.startsWith(ENGINE + path.sep)) found.push({ importer: path.relative(root, file), entry: path.relative(ENGINE, target) }) + if (target.startsWith(ENGINE + path.sep)) found.push({ importer: rel(root, file), entry: rel(ENGINE, target) }) } } return found diff --git a/test/invariants/engine-license-notice.test.js b/test/invariants/engine-license-notice.test.js index fc9624576..bf0484153 100644 --- a/test/invariants/engine-license-notice.test.js +++ b/test/invariants/engine-license-notice.test.js @@ -75,7 +75,7 @@ test('every file derived from upstream opens with its license and modification n }) test('no first-party engine file claims an upstream origin', (t) => { - const own = readdirSync(ENGINE, { recursive: true }).filter((name) => name.endsWith('.js') && !DERIVED.has(name)) + const own = readdirSync(ENGINE, { recursive: true }).map((name) => name.split(path.sep).join('/')).filter((name) => name.endsWith('.js') && !DERIVED.has(name)) t.ok(own.some((name) => name.includes('/')), 'the walk reaches the engine subfolders') t.alike(own.filter((name) => read(path.join(ENGINE, name)).includes('Derived from hyper-overlay')), []) }) diff --git a/test/invariants/main-env-reads.test.js b/test/invariants/main-env-reads.test.js index e99811da9..082288a8d 100644 --- a/test/invariants/main-env-reads.test.js +++ b/test/invariants/main-env-reads.test.js @@ -37,7 +37,7 @@ function envReads(source) { const reads = Object.fromEntries( ['src/main', 'src/preload'].flatMap((dir) => walk(path.join(ROOT, dir))) - .map((file) => [path.relative(ROOT, file), envReads(readFileSync(file, 'utf8'))]) + .map((file) => [path.relative(ROOT, file).split(path.sep).join('/'), envReads(readFileSync(file, 'utf8'))]) .filter(([, found]) => found.length > 0), ) diff --git a/test/invariants/path-field-harmonized.test.js b/test/invariants/path-field-harmonized.test.js index 8086266ae..ffc77d1f3 100644 --- a/test/invariants/path-field-harmonized.test.js +++ b/test/invariants/path-field-harmonized.test.js @@ -25,7 +25,7 @@ function sourceFiles(dir) { return out } -const files = sourceFiles(RENDERER).map((f) => ({ rel: path.relative(RENDERER, f), src: read(f) })) +const files = sourceFiles(RENDERER).map((f) => ({ rel: path.relative(RENDERER, f).split(path.sep).join('/'), src: read(f) })) const pathRow = read(path.join(RENDERER, 'components/path/PathRow.tsx')) // `FilePath` renders the path text alone. Beside an action it is the bare-text form this diff --git a/test/invariants/poll-helper.test.js b/test/invariants/poll-helper.test.js index d7c873038..a9e6738f3 100644 --- a/test/invariants/poll-helper.test.js +++ b/test/invariants/poll-helper.test.js @@ -59,9 +59,11 @@ test('until reports a timeout; waitFor throws it', async (t) => { // The extra check the three re-checking call sites relied on: a condition that only becomes true // during the final sleep still has to be seen. test('a condition that flips during the last sleep is still seen', async (t) => { - let ready = false - setTimeout(() => { ready = true }, 45) - t.is(await until(() => ready, 40, { interval: 30, scale: false }), true) + // True from the deadline on, so no check inside the loop can see it and the answer rests on the + // one made after it. Read off the clock the helper reads, not off a second timer: two timers due + // a few milliseconds apart fire in either order on a coarse system timer. + const flipsAt = Date.now() + 40 + t.is(await until(() => Date.now() >= flipsAt, 40, { interval: 30, scale: false }), true) }) test('a sync predicate is accepted', async (t) => { diff --git a/test/invariants/renderer-no-window-channels.test.js b/test/invariants/renderer-no-window-channels.test.js index 40af9cff8..c595a888c 100644 --- a/test/invariants/renderer-no-window-channels.test.js +++ b/test/invariants/renderer-no-window-channels.test.js @@ -29,7 +29,7 @@ test('no renderer action is handed over as a window event', (t) => { const files = walk(root) t.ok(files.length > 100, `walked ${files.length} renderer files`) for (const file of files) { - const rel = path.relative(root, file) + const rel = path.relative(root, file).split(path.sep).join('/') if (rel === BROADCASTER) continue t.absent(/window\.dispatchEvent\s*\(/.test(readFileSync(file, 'utf8')), `${rel}: hands an action over as a window event — give the screen navigation state instead`) diff --git a/test/invariants/renderer-primitive-single-source.test.js b/test/invariants/renderer-primitive-single-source.test.js index 51455ddeb..2e3c57edb 100644 --- a/test/invariants/renderer-primitive-single-source.test.js +++ b/test/invariants/renderer-primitive-single-source.test.js @@ -106,7 +106,7 @@ test('no renderer file hand-rolls what a primitive owns', (t) => { for (const rule of RULES) { for (const file of files) { - const rel = path.relative(root, file) + const rel = path.relative(root, file).split(path.sep).join('/') if (rel === rule.owner || rule.exempt?.includes(rel)) continue t.absent(rule.pattern.test(readFileSync(file, 'utf8')), `${rel} builds ${rule.what} itself — use ${rule.use}`) diff --git a/test/invariants/sck-epoch-plumbing.test.js b/test/invariants/sck-epoch-plumbing.test.js index 25d569097..de4fd6707 100644 --- a/test/invariants/sck-epoch-plumbing.test.js +++ b/test/invariants/sck-epoch-plumbing.test.js @@ -16,7 +16,7 @@ function walk(dir, out = []) { return out } -const rel = (p) => path.relative(root, p) +const rel = (p) => path.relative(root, p).split(path.sep).join('/') // Code only: comment lines are dropped before matching, so a doc mention is never a reader. const codeOf = (f) => readFileSync(f, 'utf8').split('\n').filter((l) => !/^\s*(\/\/|\*|\/\*)/.test(l)).join('\n') const filesMatching = (re) => walk(srcDir).filter((f) => re.test(codeOf(f))).map(rel).sort() diff --git a/test/raw/update-mode.test.js b/test/raw/update-mode.test.js index 2e3e3f6db..ca03664c7 100644 --- a/test/raw/update-mode.test.js +++ b/test/raw/update-mode.test.js @@ -22,7 +22,8 @@ const { ConfigStore } = require('../../src/main/config-store.js') // mode allows it. const host = `${process.platform}-${process.arch}` -const NAME = 'Mirall.AppImage' +// A file the updater swaps in place on this system: on Windows it applies only an .exe that way. +const NAME = process.platform === 'win32' ? 'Mirall.exe' : 'Mirall.AppImage' const PREFIX = `/by-arch/${host}/app/${NAME}` const PAYLOAD = Buffer.alloc(64 * 1024 * 16, 7) diff --git a/test/unit/audit-coverage.test.js b/test/unit/audit-coverage.test.js index ff2a12eaa..9bc5091ee 100644 --- a/test/unit/audit-coverage.test.js +++ b/test/unit/audit-coverage.test.js @@ -19,7 +19,7 @@ function walk(dir, out = []) { // Data-layer sources only: the renderer holds a mirror of the vocabulary for search labels, and // counting it as a call site would let a kind look "wired" while nothing ever records it. -const dataLayerFiles = walk(SRC).filter((f) => f.includes('/shared/') || f.includes('/worker/')) +const dataLayerFiles = walk(SRC).filter((f) => /[\\/](shared|worker)[\\/]/.test(f)) const dataLayerSource = dataLayerFiles.map((f) => readFileSync(f, 'utf8')).join('\n') // Every string literal the audit vocabulary could be spelled as. Deliberately NOT anchored to diff --git a/test/unit/bare-runner.test.js b/test/unit/bare-runner.test.js index 373e4633d..d5c54bcd6 100644 --- a/test/unit/bare-runner.test.js +++ b/test/unit/bare-runner.test.js @@ -11,6 +11,10 @@ import path from 'path' const repo = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..') const fixture = (name) => `test/fixtures/bare-runner/${name}` +// How the operating system reports a process that aborted: SIGABRT's 128 + 6 on POSIX, the +// fail-fast status code on Windows. +const ABORT_EXIT = process.platform === 'win32' ? 0xC0000409 : 134 + function runRunner(args) { const r = spawnSync(process.execPath, ['test/bare-runner.mjs', ...args], { cwd: repo, encoding: 'utf8' }) return { status: r.status, out: `${r.stdout}${r.stderr}` } @@ -20,7 +24,7 @@ test('REGRESSION (FIX-255: an aborting file is named, and takes no other file wi const { status, out } = runRunner(['--jobs', '2', fixture('aborting.test.js'), fixture('passing.test.js')]) t.ok(out.includes(`FAIL ${fixture('aborting.test.js')}`), 'the file that aborted is named') - t.ok(out.includes('exit 134'), 'with how it died') + t.ok(out.includes(`exit ${ABORT_EXIT}`), 'with how it died') t.ok(out.includes('nothing awaits this'), 'and its output is printed, not swallowed') t.ok(out.includes(`ok ${fixture('passing.test.js')}`), 'the sibling file still ran and passed') t.not(status, 0, 'the run exits non-zero') diff --git a/test/unit/comment-hygiene-gate.test.js b/test/unit/comment-hygiene-gate.test.js index cab51813d..7a07b1b9a 100644 --- a/test/unit/comment-hygiene-gate.test.js +++ b/test/unit/comment-hygiene-gate.test.js @@ -4,6 +4,7 @@ import { mkdtempSync, mkdirSync, writeFileSync, copyFileSync, rmSync } from 'nod import { tmpdir } from 'node:os' import { fileURLToPath } from 'node:url' import path from 'node:path' +import { BASH, shellPath } from '../helpers/bash.js' const here = path.dirname(fileURLToPath(import.meta.url)) const SCRIPT = path.join(here, '..', '..', 'scripts', 'ci', 'check-comment-hygiene.sh') @@ -25,8 +26,8 @@ function tree(t, files) { } function run(root, args = []) { - const r = spawnSync('bash', [path.join(root, 'scripts', 'ci', 'check-comment-hygiene.sh'), ...args], { encoding: 'utf8' }) - return { code: r.status, out: r.stdout + r.stderr } + const r = spawnSync(BASH, [shellPath(path.join(root, 'scripts', 'ci', 'check-comment-hygiene.sh')), ...args], { encoding: 'utf8' }) + return { code: r.status, out: `${r.stdout}${r.stderr}${r.error ?? ''}` } } const CLEAN = '// The rule, stated in the present tense.\nexport const x = 1\n' diff --git a/test/unit/config-store.test.js b/test/unit/config-store.test.js index 8a00eca8a..65fe7dd49 100644 --- a/test/unit/config-store.test.js +++ b/test/unit/config-store.test.js @@ -184,8 +184,10 @@ test('a config with nothing to clean is not rewritten on load', (t) => { t.is(fs.statSync(file).mtimeMs, before, 'rewriting every boot to change nothing is worse than waiting') }) -// config.json holds the feedback email and sits beside a member identity, so 0600 is right. -test('config.json is written owner-only', (t) => { +// config.json holds the feedback email and sits beside a member identity, so 0600 is right. POSIX +// only: a file carries no permission bits on Windows, where the profile folder's access list is +// what keeps it private. +test('config.json is written owner-only', { skip: process.platform === 'win32' }, (t) => { const dir = tmpDir() const store = new ConfigStore(dir).load() store.set('ui.feedbackEmail', 'a@b.c') diff --git a/test/unit/event-taxonomy.test.js b/test/unit/event-taxonomy.test.js index 40a0a6f17..301d54d1e 100644 --- a/test/unit/event-taxonomy.test.js +++ b/test/unit/event-taxonomy.test.js @@ -83,7 +83,7 @@ test('every emitted worker event is classified in the EDA taxonomy', (t) => { const emitted = new Set() const re = /emit\(\s*['"`](event:[a-z-]+)/g for (const file of walk(SRC)) { - if (!(file.includes('/worker/') || file.includes('/shared/') || file.includes('/main/'))) continue + if (!/[\\/](worker|shared|main)[\\/]/.test(file)) continue const src = readFileSync(file, 'utf8') for (let m; (m = re.exec(src));) emitted.add(m[1]) } diff --git a/test/unit/fetch-verified.test.js b/test/unit/fetch-verified.test.js index 3ca9515a2..35440c70e 100644 --- a/test/unit/fetch-verified.test.js +++ b/test/unit/fetch-verified.test.js @@ -5,6 +5,7 @@ import { tmpdir } from 'node:os' import { createHash } from 'node:crypto' import { fileURLToPath, pathToFileURL } from 'node:url' import path from 'node:path' +import { BASH, shellPath } from '../helpers/bash.js' const here = path.dirname(fileURLToPath(import.meta.url)) const HELPER = path.join(here, '..', '..', 'scripts', 'build', 'lib', 'fetch-verified.sh') @@ -21,8 +22,8 @@ function scratch(t) { // failure did not stop the calling script. function runHelper(call, args) { const script = `set -euo pipefail; source "$1"; shift; ${call} "$@"; echo CONTINUED` - const result = spawnSync('bash', ['-c', script, 'fetch-verified', HELPER, ...args], { encoding: 'utf8' }) - return { code: result.status, stdout: result.stdout, stderr: result.stderr } + const result = spawnSync(BASH, ['-c', script, 'fetch-verified', shellPath(HELPER), ...args], { encoding: 'utf8' }) + return { code: result.status, stdout: `${result.stdout}`, stderr: `${result.stderr}${result.error ?? ''}` } } function fetchFixture(t, expected, url) { @@ -30,7 +31,7 @@ function fetchFixture(t, expected, url) { const source = path.join(dir, 'asset') writeFileSync(source, BYTES) const out = path.join(dir, 'out') - return { out, ...runHelper('fetch_verified', [url ?? pathToFileURL(source).href, expected, out]) } + return { out, ...runHelper('fetch_verified', [url ?? pathToFileURL(source).href, expected, shellPath(out)]) } } test('REGRESSION (MIR-55: a build input whose hash differs from its pin stops the build)', (t) => { @@ -69,7 +70,7 @@ test('a failed download stops the build', (t) => { test('a file that drifted from its pin after download is refused and deleted', (t) => { const file = path.join(scratch(t), 'runtime') writeFileSync(file, `${BYTES}patched\n`) - const r = runHelper('verify_sha256', [file, PIN]) + const r = runHelper('verify_sha256', [shellPath(file), PIN]) t.not(r.code, 0) t.absent(r.stdout.includes('CONTINUED')) t.absent(existsSync(file)) diff --git a/test/unit/forge-linux-makers.test.js b/test/unit/forge-linux-makers.test.js index 70a9cd602..88d8699e7 100644 --- a/test/unit/forge-linux-makers.test.js +++ b/test/unit/forge-linux-makers.test.js @@ -22,12 +22,11 @@ test('the deb maker names the package, the executable and the scheme handler the t.absent(o.scripts, 'no maintainer scripts') t.absent(o.depends, 'Depends stays the installer default for the packaged Electron version') t.is(o.compression, 'xz', 'xz members: dpkg before Debian 12 cannot unpack zstd') - const iconDir = path.dirname(new URL('../../resources/linux/icons/16x16.png', import.meta.url).pathname) - const onDisk = fs.readdirSync(iconDir).filter((f) => /^\d+x\d+\.png$/.test(f)).map((f) => f.slice(0, -4)).sort() + const onDisk = fs.readdirSync(new URL('../../resources/linux/icons/', import.meta.url)).filter((f) => /^\d+x\d+\.png$/.test(f)).map((f) => f.slice(0, -4)).sort() t.alike(Object.keys(o.icon).sort(), onDisk, 'every x.png in resources/linux/icons ships, and nothing else') for (const [size, file] of Object.entries(o.icon)) { t.ok(fs.existsSync(file), `icon ${size} exists`) - t.ok(file.endsWith(`/${size}.png`), `icon ${size} is the matching source file`) + t.is(path.basename(file), `${size}.png`, `icon ${size} is the matching source file`) } }) diff --git a/test/unit/relay-secret.test.js b/test/unit/relay-secret.test.js index 2049c096b..bbea35dfa 100644 --- a/test/unit/relay-secret.test.js +++ b/test/unit/relay-secret.test.js @@ -43,7 +43,8 @@ test('the vault sits beside the store and is owner-only', (t) => { const file = seedFile(storage) t.is(path.dirname(file), path.dirname(storage), 'beside kek.enc, not inside the corestore') t.is(path.basename(file), 'relay-ticket.enc') - t.is(fs.statSync(file).mode & 0o777, 0o600) + // A file carries no permission bits on Windows: the profile folder's access list keeps it private. + if (process.platform !== 'win32') t.is(fs.statSync(file).mode & 0o777, 0o600) }) // Asserting the ciphertext would only test the fake. What matters is the boundary: the seed @@ -171,7 +172,8 @@ test('a rewrite replaces the previous seed', (t) => { // a Windows lock, EPERM, a read-only volume — still returned success. The config then stopped // naming a seed the node keeps presenting on every later boot, with nothing on screen to explain // it and no path in the app that could find or remove it.) -test('REGRESSION (FIX-5: a vault that cannot be deleted is reported, not swallowed)', (t) => { +// POSIX only: the refusal is staged with a read-only folder, which stops no delete on Windows. +test('REGRESSION (FIX-5: a vault that cannot be deleted is reported, not swallowed)', { skip: process.platform === 'win32' }, (t) => { const storage = tmpStorage() writeRelaySeedHex(storage, SEED, { safeStorage: fakeSafeStorage() }) diff --git a/test/unit/reveal-host-gate.test.js b/test/unit/reveal-host-gate.test.js index 9573d0019..a788672ad 100644 --- a/test/unit/reveal-host-gate.test.js +++ b/test/unit/reveal-host-gate.test.js @@ -28,9 +28,14 @@ function load({ workerIsLocal = (id) => id === LOCAL_WINDOW, roots = () => [] } } // Real files: main reads the disk itself rather than taking the caller's word for what is there. +// The home folder is pinned away from them for the test: on Windows the temp folder lies inside it, +// where the home jail would admit every path here before a root was asked. function diskRoot(t) { const root = fs.mkdtempSync(path.join(os.tmpdir(), 'reveal-gate-')) t.teardown(() => fs.rmSync(root, { recursive: true, force: true })) + const homedir = os.homedir + os.homedir = () => path.join(root, 'home') + t.teardown(() => { os.homedir = homedir }) return fs.realpathSync(root) } diff --git a/test/unit/window-connections.test.js b/test/unit/window-connections.test.js index 6ecc02bdf..50e106872 100644 --- a/test/unit/window-connections.test.js +++ b/test/unit/window-connections.test.js @@ -141,7 +141,8 @@ test('a window that loses its worker while connecting is not left with a connect t.ok(sockets[0].destroyed) }) -test('main talks only to a socket in a directory private to this user', (t) => { +// POSIX only: the check reads the directory's owner and permission bits, which Windows has none of. +test('main talks only to a socket in a directory private to this user', { skip: process.platform === 'win32' }, (t) => { const dir = tmpDir('wc', t) const run = path.join(dir, 'run') fs.mkdirSync(run, { mode: 0o700 }) @@ -155,8 +156,10 @@ test('main talks only to a socket in a directory private to this user', (t) => { const link = path.join(dir, 'link') fs.symlinkSync(target, link) t.exception(() => assertPrivateSocketDir(path.join(link, 'daemon.sock'), 'darwin'), 'a symlink is not the directory') +}) - t.execution(() => assertPrivateSocketDir('\\\\.\\pipe\\mirall-x', 'win32'), 'a named pipe has no directory to check') +test('a named pipe has no directory to check', (t) => { + t.execution(() => assertPrivateSocketDir('\\\\.\\pipe\\mirall-x', 'win32')) }) test('a socket closed under its window is reported to the owner of the worker, before the grace', async (t) => { diff --git a/test/unit/worker-host.test.js b/test/unit/worker-host.test.js index 04491dee5..6fd157ddc 100644 --- a/test/unit/worker-host.test.js +++ b/test/unit/worker-host.test.js @@ -12,6 +12,7 @@ import net from 'net' import { EventEmitter } from 'events' import { fileURLToPath } from 'url' import { tmpPath } from '../helpers/tmp.js' +import { listenAddress } from '../helpers/listen-address.js' import { createRequire } from 'module' // Each load() installs its own process-exit backstop, as each real spawn path does. @@ -21,6 +22,7 @@ const KEK = 'ab'.repeat(32) const requireCjs = createRequire(import.meta.url) const APP_VERSION = JSON.parse(fs.readFileSync(new URL('../../package.json', import.meta.url), 'utf8')).version const SEED = 'ef'.repeat(32) +const { canAttach } = requireCjs('../../src/main/backend-discovery.js') const REPO = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '..') preloadEntrypoints(REPO) @@ -589,7 +591,7 @@ function socketServer(t, { unlock: answer = () => ({ data: { ok: true } }), hold fs.mkdirSync(dir, { mode: 0o700 }) t.teardown(() => fs.rmSync(path.dirname(dir), { recursive: true, force: true })) } - const socketPath = path.join(dir, given ? 'daemon.sock' : 's.sock') + const socketPath = listenAddress(dir, given ? 'daemon.sock' : 's.sock') const peers = [] const unlocks = [] const hellos = [] @@ -714,6 +716,10 @@ async function runningBackend(t, { mode = 0o700, withRecord = true, record = {}, return { ...backend, storage: path.join(dataDir, 'app-storage'), recordFile, writeRecord, dataDir } } +// Using a back end main did not start rests on verifying who owns its socket. Where this build +// cannot (canAttach), every start spawns, and none of these cases has anything to observe. +const attachTest = (name, fn) => test(name, { skip: !canAttach() }, fn) + function spawnCounter() { const spawned = [] return { spawned, spawn: () => { const w = stubWorker(); spawned.push(w); return w } } @@ -721,7 +727,7 @@ function spawnCounter() { const exits = (sender) => sender.sent.filter(([c]) => c.startsWith('pear:worker:exit:')).map(([, code]) => code) -test('a running back end of this user’s at this version is used: no spawn, no bootstrap, the key only because it waits', async (t) => { +attachTest('a running back end of this user’s at this version is used: no spawn, no bootstrap, the key only because it waits', async (t) => { const backend = await runningBackend(t, { status: AWAITING }) const { spawned, spawn } = spawnCounter() const { host, electron } = load({ flags: { identityKEK: KEK }, storage: backend.storage, spawn }) @@ -745,7 +751,7 @@ test('a running back end of this user’s at this version is used: no spawn, no t.is(backend.unlocks.length, 2) }) -test('a running back end whose identity is already open is sent nothing', async (t) => { +attachTest('a running back end whose identity is already open is sent nothing', async (t) => { const backend = await runningBackend(t, { status: OPEN }) const { spawned, spawn } = spawnCounter() const { host, electron } = load({ flags: { identityKEK: KEK }, storage: backend.storage, spawn }) @@ -756,7 +762,7 @@ test('a running back end whose identity is already open is sent nothing', async t.is(backend.unlocks.length, 0) }) -test('a running back end locked by another key is handed this app’s key, as "try again" would', async (t) => { +attachTest('a running back end locked by another key is handed this app’s key, as "try again" would', async (t) => { const backend = await runningBackend(t, { status: LOCKED_STATUS, unlock: () => ({ error: 'identity unlock failed', code: 'IDENTITY_UNLOCK_FAILED' }) }) const { spawned, spawn } = spawnCounter() const { host, electron } = load({ flags: { identityKEK: KEK }, storage: backend.storage, spawn }) @@ -766,7 +772,7 @@ test('a running back end locked by another key is handed this app’s key, as "t t.is(spawned.length, 0) }) -test('a running back end of another version is neither used nor replaced: the window hears "already running"', async (t) => { +attachTest('a running back end of another version is neither used nor replaced: the window hears "already running"', async (t) => { const backend = await runningBackend(t, { status: AWAITING, appVersion: '0.0.1-beta.1' }) const { spawned, spawn } = spawnCounter() const { host, electron } = load({ flags: { identityKEK: KEK }, storage: backend.storage, spawn }) @@ -779,7 +785,7 @@ test('a running back end of another version is neither used nor replaced: the wi t.absent(host.workerIsLocal(sender.id), 'and it is not the back end in use') }) -test('a record main cannot trust, or whose socket does not answer, is no back end: the start spawns as without one', async (t) => { +attachTest('a record main cannot trust, or whose socket does not answer, is no back end: the start spawns as without one', async (t) => { const cases = { 'a run folder others can read': { mode: 0o755 }, 'a record naming a socket that is gone': { record: { socket: '/nonexistent/run/daemon.sock' } }, @@ -799,7 +805,7 @@ test('a record main cannot trust, or whose socket does not answer, is no back en } }) -test('a stale record — a socket file nobody listens on — is no back end', async (t) => { +attachTest('a stale record — a socket file nobody listens on — is no back end', async (t) => { const backend = await runningBackend(t, { status: AWAITING }) await backend.close() fs.closeSync(fs.openSync(backend.socketPath, 'w')) @@ -822,7 +828,7 @@ test('with no record at all the spawn happens in the same turn as the request', spawned[0].emit('exit', 0) }) -test('a spawn that exits as already running is followed by a look for the holder, which is then used', async (t) => { +attachTest('a spawn that exits as already running is followed by a look for the holder, which is then used', async (t) => { const backend = await runningBackend(t, { status: AWAITING, withRecord: false }) const { spawned, spawn } = spawnCounter() const { host, electron } = load({ flags: { identityKEK: KEK }, storage: backend.storage, spawn }) @@ -850,7 +856,7 @@ test('a spawn that exits as already running with no holder to find still says so t.is(spawned.length, 1) }) -test('quitting lets go of a back end it did not start: no shutdown, no signal, its windows disconnected', async (t) => { +attachTest('quitting lets go of a back end it did not start: no shutdown, no signal, its windows disconnected', async (t) => { const backend = await runningBackend(t, { status: OPEN }) const { spawned, spawn } = spawnCounter() const { host, electron } = load({ flags: { identityKEK: KEK }, storage: backend.storage, spawn }) @@ -868,7 +874,7 @@ test('quitting lets go of a back end it did not start: no shutdown, no signal, i t.alike(exits(sender), [], 'and the window is not told it exited') }) -test('a restart is refused for a back end it did not start, with a code, and the back end is untouched', async (t) => { +attachTest('a restart is refused for a back end it did not start, with a code, and the back end is untouched', async (t) => { const backend = await runningBackend(t, { status: OPEN }) const { spawned, spawn } = spawnCounter() const { host, electron } = load({ flags: { identityKEK: KEK }, storage: backend.storage, spawn }) @@ -883,7 +889,7 @@ test('a restart is refused for a back end it did not start, with a code, and the t.alike(exits(sender), []) }) -test('a back end it did not start that goes away: the window hears exit 0, and its next start looks afresh', async (t) => { +attachTest('a back end it did not start that goes away: the window hears exit 0, and its next start looks afresh', async (t) => { const backend = await runningBackend(t, { status: OPEN }) const { spawned, spawn } = spawnCounter() const { host, electron } = load({ flags: { identityKEK: KEK }, storage: backend.storage, spawn }) @@ -904,7 +910,7 @@ test('a back end it did not start that goes away: the window hears exit 0, and i await again.catch(() => {}) }) -test('a reveal is authorized against the roots the back end it did not start answers with', async (t) => { +attachTest('a reveal is authorized against the roots the back end it did not start answers with', async (t) => { const backend = await runningBackend(t, { status: OPEN, roots: ['/Volumes/Data/dl', '', 7] }) const { host, electron } = load({ flags: { identityKEK: KEK }, storage: backend.storage }) host.registerWorkerHost() @@ -921,7 +927,7 @@ async function restartedOn(t, backend) { return socketServer(t, { dir: path.dirname(backend.socketPath), dataDir: fs.realpathSync.native(backend.dataDir), status: AWAITING }) } -test('REGRESSION (FIX-ATTACH-1: a closed window left a dead or replaced back end cached): a start with no window connected looks for the back end afresh and opens it', async (t) => { +attachTest('REGRESSION (FIX-ATTACH-1: a closed window left a dead or replaced back end cached): a start with no window connected looks for the back end afresh and opens it', async (t) => { const backend = await runningBackend(t, { status: OPEN }) const { spawned, spawn } = spawnCounter() const { host, electron } = load({ flags: { identityKEK: KEK }, storage: backend.storage, spawn }) @@ -936,7 +942,7 @@ test('REGRESSION (FIX-ATTACH-1: a closed window left a dead or replaced back end t.is(spawned.length, 0) }) -test('REGRESSION (FIX-ATTACH-1: a failed connect to an attached back end kept it cached): it is forgotten, and the next start looks again', async (t) => { +attachTest('REGRESSION (FIX-ATTACH-1: a failed connect to an attached back end kept it cached): it is forgotten, and the next start looks again', async (t) => { const backend = await runningBackend(t, { status: OPEN }) const { spawned, spawn } = spawnCounter() const { host, electron } = load({ flags: { identityKEK: KEK }, storage: backend.storage, spawn }) @@ -958,7 +964,7 @@ test('REGRESSION (FIX-ATTACH-1: a failed connect to an attached back end kept it await third.catch(() => {}) }) -test('REGRESSION (FIX-ATTACH-3: the app took the lock from an owner restarting the back end): after losing it, the next start waits for its return and uses it', async (t) => { +attachTest('REGRESSION (FIX-ATTACH-3: the app took the lock from an owner restarting the back end): after losing it, the next start waits for its return and uses it', async (t) => { const backend = await runningBackend(t, { status: OPEN }) const { spawned, spawn } = spawnCounter() const { host, electron } = load({ flags: { identityKEK: KEK }, storage: backend.storage, spawn, returnLooksMs: [0, 30, 30, 30] }) @@ -979,7 +985,7 @@ test('REGRESSION (FIX-ATTACH-3: the app took the lock from an owner restarting t t.alike(back.requests, ['identity:status', 'identity:unlock']) }) -test('REGRESSION (FIX-ATTACH-6: a window destroyed during the start was claimed and connected): it is neither claimed nor connected', async (t) => { +attachTest('REGRESSION (FIX-ATTACH-6: a window destroyed during the start was claimed and connected): it is neither claimed nor connected', async (t) => { const backend = await runningBackend(t, { status: OPEN, holdUnlock: false }) const { host, electron } = load({ flags: { identityKEK: KEK }, storage: backend.storage }) host.registerWorkerHost() @@ -993,7 +999,7 @@ test('REGRESSION (FIX-ATTACH-6: a window destroyed during the start was claimed t.absent(host.workerIsLocal(sender.id)) }) -test('REGRESSION (FIX-ATTACH-8: a quit during the look still spawned or handed a key): nothing is spawned or handed over once the app is quitting', async (t) => { +attachTest('REGRESSION (FIX-ATTACH-8: a quit during the look still spawned or handed a key): nothing is spawned or handed over once the app is quitting', async (t) => { const backend = await runningBackend(t, { status: AWAITING }) const { spawned, spawn } = spawnCounter() // A quit-state of this test's own: the flag has no way back, and later tests load the host afresh. @@ -1010,7 +1016,7 @@ test('REGRESSION (FIX-ATTACH-8: a quit during the look still spawned or handed a t.is(backend.unlocks.length, 0, 'no key went out') }) -test('REGRESSION (FIX-ATTACH-5: a busy holder was taken for stale and a second back end spawned): it is reported as already running, and nothing spawns', async (t) => { +attachTest('REGRESSION (FIX-ATTACH-5: a busy holder was taken for stale and a second back end spawned): it is reported as already running, and nothing spawns', async (t) => { const backend = await runningBackend(t, { status: AWAITING, silent: true }) const { spawned, spawn } = spawnCounter() const { host, electron } = load({ flags: { identityKEK: KEK }, storage: backend.storage, spawn, busyAnswerMs: 30 }) @@ -1021,7 +1027,7 @@ test('REGRESSION (FIX-ATTACH-5: a busy holder was taken for stale and a second b t.is(spawned.length, 0) }) -test('REGRESSION (FIX-ATTACH-9: an action stopped halfway when its restart was refused): main says, before any step, whether this window’s back end is its to restart', async (t) => { +attachTest('REGRESSION (FIX-ATTACH-9: an action stopped halfway when its restart was refused): main says, before any step, whether this window’s back end is its to restart', async (t) => { const backend = await runningBackend(t, { status: OPEN }) const { host, electron } = load({ flags: { identityKEK: KEK }, storage: backend.storage }) host.registerWorkerHost() diff --git a/test/unit/worker-request.test.js b/test/unit/worker-request.test.js index cd7aec4ec..6bc472ea5 100644 --- a/test/unit/worker-request.test.js +++ b/test/unit/worker-request.test.js @@ -5,6 +5,7 @@ import fs from 'fs' import path from 'path' import { createRequire } from 'module' import { tmpDir } from '../helpers/tmp.js' +import { listenAddress } from '../helpers/listen-address.js' import { IPC_PROTOCOL_VERSION, IPC_PROTOCOL_MIN_SUPPORTED, CLIENT_KINDS } from '../../src/shared/contract/ipc-frames.js' const require = createRequire(import.meta.url) @@ -142,7 +143,8 @@ test('a directory that is not private is refused before any connection is made', t.absent(connected) }) -test('the default directory check is the one a window\'s connection applies', async (t) => { +// POSIX only: a named pipe has no directory, so on Windows there is nothing for the check to refuse. +test('the default directory check is the one a window\'s connection applies', { skip: process.platform === 'win32' }, async (t) => { const dir = tmpDir('wr', t) const open = path.join(dir, 'open') fs.mkdirSync(open) @@ -169,7 +171,7 @@ test('over a real socket, the request reaches a worker and its answer comes back }) sock.on('error', () => {}) }) - const socketPath = path.join(dir, 's.sock') + const socketPath = listenAddress(dir, 's.sock') await new Promise((resolve) => server.listen(socketPath, resolve)) t.teardown(() => new Promise((resolve) => server.close(resolve))) t.alike(await requestOverSocket(socketPath, 'identity:unlock', { kek: KEK }), { ok: true })