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: 2 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ jobs:
HIDE_E2E_HERDR_BIN: ${{ steps.herdr.outputs.bin }}
run: |
bash scripts/verify-cargo.sh test-scoped -p hide-platform -p hide-herdr-client
# The OS contract tests quarantined on macOS, blocking here like every tracked flaky test.
bash scripts/verify-cargo.sh test-scoped -p hide-platform -- --ignored
bash scripts/verify-cargo.sh test-scoped -p hide-herdr-client --test real_herdr -- --ignored --nocapture
- name: Whole desktop suite, including tracked flaky tests
timeout-minutes: 20
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ jobs:
HIDE_E2E_TRACE: "1"
run: |
mkdir -p "$HIDE_E2E_SCREENSHOT_DIR"
bash scripts/verify-web.sh web e2e --grep @platform
# A quarantined test leaves this required step as it leaves the
# macOS one; the Linux lane's quarantine step still runs it.
bash scripts/verify-web.sh web e2e --grep @platform --grep-invert @flaky
- name: Keep the failed Windows platform run
if: failure()
uses: actions/upload-artifact@v7
Expand Down Expand Up @@ -351,10 +353,12 @@ jobs:
run: |
mkdir -p "$HIDE_E2E_SCREENSHOT_DIR"
bash scripts/verify-web.sh desktop e2e --grep-invert @flaky
- name: Quarantined end-to-end (does not block verify)
- name: Quarantined tests (does not block verify)
# A test tagged @flaky carries the issue that tracks its cause. It still
# runs here, once, so a fix shows up as a pass and a regression of the
# product it covers still shows up in the log; it cannot turn verify red.
# A Rust test quarantined on macOS (`ignore = "<issue>"` under
# `cfg_attr(target_os = "macos")`) runs here the same way.
# The build is the required step's. `--no-deps` matters: a project
# dependency runs whole whatever `--grep` says, so a `@needs-focus`
# quarantined test would otherwise bring the entire background suite
Expand All @@ -370,8 +374,11 @@ jobs:
HIDE_E2E_HERDR_BIN: ${{ steps.herdr.outputs.bin }}
HIDE_E2E_SCREENSHOT_DIR: ${{ runner.temp }}/hide-e2e
run: |
status=0
bash scripts/verify-cargo.sh test-scoped -p hide-platform -- --ignored || status=$?
mkdir -p "$HIDE_E2E_SCREENSHOT_DIR"
bash scripts/verify-web.sh desktop e2e --no-deps --grep @flaky --output=test-results-quarantine
bash scripts/verify-web.sh desktop e2e --no-deps --grep @flaky --output=test-results-quarantine || status=$?
exit "$status"
- name: Keep the e2e run's logs
if: failure() || steps.quarantine.outcome == 'failure'
uses: actions/upload-artifact@v7
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ There is no label or bypass for any of them; when a gate is wrong, change the ga
| os contract | What differs between macOS, Linux and Windows behaves the same on all three, observed from the caller: the local stream under the Herdr client, owned children and what the kernel says about a pid, private files, locks, atomic replacement, links, file identity and disk space, folder watching (a change in two seconds, no change for a read, a bounded burst that ends in an overflow), where the account's things live, and the client and the default socket against the pinned Herdr for that system (the Windows zip runs only here) | `bash scripts/verify-cargo.sh test-scoped -p hide-platform -p hide-herdr-client`, then `HIDE_E2E_HERDR_BIN=<pinned herdr> bash scripts/verify-cargo.sh test-scoped -p hide-herdr-client --test real_herdr -- --ignored` | A contract failed on one system: fix the code under it, not the test; the Linux and Windows legs are `os-contract.yml`, the macOS leg runs in `desktop-e2e`. |
| windows check | The workspace compiles for Windows, and the daemon, app unit suites and browser `@platform` smoke hold there with their existing assertions: hided's pane bootstrap and end-to-end tests, `hide connect` starting the `hided.exe` beside it and `hide stop` ending it, the install kit's Windows command shim and junction, the agent hook entries run through PowerShell, hided driving the pinned Herdr, a real listening port attributed to its working directory with native read failures exposed, and checkout cleanup excluded when its live listener starts through another path spelling, the web and desktop unit suites, and the same browser platform tests as on macOS | On Windows: `bash scripts/verify-cargo.sh check --workspace --all-targets`, `bash scripts/verify-cargo.sh test-scoped -p hided --lib pane_auth`, `bash scripts/verify-cargo.sh test-scoped -p hided --test connect_stop`, `bash scripts/verify-cargo.sh test-scoped -p hided --test handshake`, `bash scripts/verify-cargo.sh test-scoped -p hide-kit`, `bash scripts/verify-cargo.sh test-scoped -p hide-agent-hooks`, `HIDE_E2E_HERDR_BIN=<pinned herdr.exe> bash scripts/verify-cargo.sh test-scoped -p hided --test real_herdr -- --ignored`, `bash scripts/verify-cargo.sh test-scoped -p herdr-core --lib ports::tests::a_real_listener_is_found_and_attributed_to_the_directory_it_runs_in -- --exact --nocapture`, `bash scripts/verify-cargo.sh test-scoped -p herdr-core --lib ports::tests::cleanup_keeps_a_checkout_in_use_when_a_listener_starts_through_another_spelling -- --exact --nocapture`, `bash scripts/verify-web.sh web typecheck`, `bash scripts/verify-web.sh web test`, `bash scripts/verify-web.sh desktop typecheck`, `bash scripts/verify-web.sh desktop test`, `bash scripts/verify-web.sh web build`, `bash scripts/verify-web.sh web playwright-install`, `HIDE_E2E_HERDR_BIN=<pinned herdr.exe> bash scripts/verify-web.sh web e2e --grep @platform` (local path tests need Developer Mode or an administrator for links) | A Windows-only failure must be fixed under the same assertion; a spec's POSIX assumption is a portability gap, not permission to skip the flow. Browser setup and unit checks can proceed after an earlier runtime failure, which still fails the required job. The job is in `pr.yml`. |

The `@flaky` quarantine is the only way a web or desktop e2e test leaves a required gate; [docs/TESTING.md](docs/TESTING.md#flaky-tests) owns when a test may be tagged and which lanes still run it.
The `@flaky` quarantine, and for a Rust OS contract test an `ignore` on the one system it fails on, is the only way a test leaves a required gate; [docs/TESTING.md](docs/TESTING.md#flaky-tests) owns when a test may be tagged and which lanes still run it.

A web e2e test that exercises what differs by operating system is tagged `{ tag: "@platform" }` with a comment saying what, and a pull request runs those on macOS and Windows as well as in the full Linux shards: Trash, process ownership, file watching and saving, worktree paths, disk cleanup, terminal input and echo through the platform's Herdr, and platform editing chords and browser-composed Korean input.
Every web e2e presses its chords through `web/e2e/chords.ts`, which reads them from the shell's registry for the runner's system, so the Linux shards press the Ctrl+Shift and Alt+Shift chords Windows and Linux use and the macOS run presses the ⌘ ones; a spec spells a chord itself only when it binds one in Settings or presses one the shell must not answer.
Expand Down
6 changes: 4 additions & 2 deletions docs/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,11 @@ A failure on a different SHA is not evidence of flakiness by itself, and the sam

- Record each failure in the issue that tracks the test: the run, job and attempt link, the tested SHA, the system, the failing assertion and its message, and the result of the first run and of each rerun.
Group failures by assertion signature, not by title, so two causes under one name are not read as one.
- A web or desktop e2e test that fails intermittently in CI before its cause is fixed can be quarantined, and that is the only way a test leaves a required gate.
- A web or desktop e2e test that fails intermittently in CI before its cause is fixed can be quarantined, and that, with the Rust form below, is the only way a test leaves a required gate.
Tag it `@flaky` with an `issue` annotation naming the issue that tracks the cause; the required web shards and the required desktop step skip it with `--grep-invert @flaky`, and web shard 1 and the desktop job each still run every quarantined test in a step that cannot turn `verify` red, so a fix shows up as a pass.
Pull-request quarantined web tests run only in shard 1 of the Linux lane, never in the macOS `@platform` job; nightly runs `@flaky` tests in their normal shards and blocking suites.
Pull-request quarantined web tests run only in shard 1 of the Linux lane, never in the macOS or Windows `@platform` steps; nightly runs `@flaky` tests in their normal shards and blocking suites.
- A Rust OS contract test that fails intermittently on one system is quarantined there alone with `#[cfg_attr(target_os = "<system>", ignore = "<issue URL>")]`, so the other systems keep it in their required lanes.
Today only macOS `hide-platform` tests are run back: the desktop job's quarantine step runs them with `--ignored` where they cannot turn `verify` red, and nightly's macOS OS contract step runs them blocking.
- Quarantine is for a cause under investigation, not for a test nobody means to fix; removing the tag is part of the fix.
- Quarantine does not decide the cause.
A failure that shows lost or misrouted input, a broken OS contract, or a missing tab the user asked for is a product defect candidate, and is investigated as one rather than tagged and left.
Expand Down
4 changes: 4 additions & 0 deletions hide-platform/tests/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ fn clients_that_leave_before_accept_never_hold_up_the_next_connect() {
}

#[test]
#[cfg_attr(
target_os = "macos",
ignore = "https://github.com/modakbul-gongbang/hide/issues/396"
)]
fn a_burst_of_clients_that_connect_and_leave_loses_no_connect() {
// #315 as it was seen: an accept loop running, and clients connecting and
// leaving as fast as they can (the 33rd of 50 timed out on Windows). Each
Expand Down
4 changes: 2 additions & 2 deletions web/e2e/checkout-owner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ test("A new tab in a Git checkout goes to the workspace Herdr binds to it, not t
}
});

test("With no workspace bound, Herdr binds the unbound one already at the checkout, and Hide leaves its name", async ({ page }) => {
test("With no workspace bound, Herdr binds the unbound one already at the checkout, and Hide leaves its name", { tag: "@flaky", annotation: { type: "issue", description: "https://github.com/modakbul-gongbang/hide/issues/400" } }, async ({ page }) => {
test.setTimeout(120_000);
const herdr = await startHerdr({ agents: false });
let daemon: Daemon | null = null;
Expand Down Expand Up @@ -160,7 +160,7 @@ test("A new tab in a linked worktree with no workspace opens one bound to it, na
}
});

test("A new tab in a plain folder opens one marked workspace and the next tab reuses it", async ({ page }) => {
test("A new tab in a plain folder opens one marked workspace and the next tab reuses it", { tag: "@flaky", annotation: { type: "issue", description: "https://github.com/modakbul-gongbang/hide/issues/400" } }, async ({ page }) => {
test.setTimeout(120_000);
const herdr = await startHerdr({ agents: false });
let daemon: Daemon | null = null;
Expand Down
23 changes: 17 additions & 6 deletions web/e2e/herdr-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import crypto from "node:crypto";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { ownUntilWorkerExit } from "./worker-owned";
import { compileFixtureC, fixtureExecutable, fixtureHomeEnv, fixtureToolPath, inheritedFixtureEnv } from "./platform-fixture";
import { afterCleanup, ownUntilWorkerExit } from "./worker-owned";
import { compileFixtureC, endWindowsProcesses, fixtureExecutable, fixtureHomeEnv, fixtureToolPath, inheritedFixtureEnv, windowsProcessTree, type WindowsProcess } from "./platform-fixture";

export type HerdrFixture = {
bin: string;
Expand Down Expand Up @@ -529,8 +529,7 @@ export async function startHerdr({ agents = true }: { agents?: boolean } = {}):
// Keep host-installed providers out while retaining system tools.
fixturePath = fixtureToolPath(path.join(root, "bin"));
} catch (error) {
fs.rmSync(root, { recursive: true, force: true });
throw error;
throw afterCleanup(error, () => fs.rmSync(root, { recursive: true, force: true }));
}
// Workspaces created later inherit the server's PATH, not hided's PATH.
// Keep every pane on the same fake agent binary, including new workspaces.
Expand All @@ -542,8 +541,20 @@ export async function startHerdr({ agents = true }: { agents?: boolean } = {}):
let spawnFailed: Error | null = null;
server.once("error", (error) => { spawnFailed = error; });
const { stop } = ownUntilWorkerExit(() => {
// On Windows a pane's processes can outlive the server and keep the
// root locked. Listed while the server still runs (so its pid is its
// own), ended after it stops; a failure here keeps the root and is
// thrown after the logs are copied.
let failure: unknown;
let owned: WindowsProcess[] = [];
if (process.platform === "win32" && server.pid && server.exitCode === null && server.signalCode === null) {
try { owned = windowsProcessTree(server.pid); } catch (error) { failure = error; }
}
spawnSync(bin, ["server", "stop"], { env, timeout: 10_000 });
if (server.exitCode === null) server.kill("SIGKILL");
if (process.platform === "win32") {
try { endWindowsProcesses(owned, root); } catch (error) { failure = failure === undefined ? error : afterCleanup(failure, () => { throw error; }); }
}
for (const file of [socket, socket.replace(/\.sock$/, "-client.sock")]) {
fs.rmSync(file, { force: true });
}
Expand All @@ -565,6 +576,7 @@ export async function startHerdr({ agents = true }: { agents?: boolean } = {}):
}
}
}
if (failure !== undefined) throw failure;
fs.rmSync(root, { recursive: true, force: true });
});
try {
Expand Down Expand Up @@ -690,8 +702,7 @@ export async function startHerdr({ agents = true }: { agents?: boolean } = {}):
stop,
};
} catch (error) {
stop();
throw error;
throw afterCleanup(error, stop);
}
}

Expand Down
2 changes: 1 addition & 1 deletion web/e2e/pane-focus-ordering.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function observeFocusFrames(page: Page) {
}

// Both cases exercise real terminal input/focus through the platform's Herdr.
test("rapid pane clicks coalesce behind one request and leave keys on the last pane", { tag: "@platform" }, async ({ page }) => {
test("rapid pane clicks coalesce behind one request and leave keys on the last pane", { tag: ["@platform", "@flaky"], annotation: { type: "issue", description: "https://github.com/modakbul-gongbang/hide/issues/397" } }, async ({ page }) => {
const herdr = await startHerdr();
const focusFrames = observeFocusFrames(page);
// Two fixed bursts produce at most 32 stage records, with no input contents.
Expand Down
63 changes: 63 additions & 0 deletions web/e2e/platform-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,66 @@ export function fixtureOpenCommand(root?: string, privateRoot?: string): string
if (!fs.existsSync(command)) throw new Error(`Windows fixture opener is missing: ${command}`);
return command;
}

/** A Windows process, named by its id and creation time so a reused id is never taken for it. */
export type WindowsProcess = { id: number; created: string };

const powershell = (script: string, env: NodeJS.ProcessEnv = {}): string =>
execFileSync("powershell.exe", ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", `$ErrorActionPreference = 'Stop'\n${script}`], {
env: { ...process.env, ...env },
encoding: "utf8",
timeout: 30_000,
maxBuffer: 1024 * 1024,
windowsHide: true,
});

/**
* `pid` and its live descendants. Windows keeps a running executable and a
* process's working folder locked, and a pane's processes can outlive the
* Herdr server that started them, so a fixture lists its tree before it
* stops the server and ends what is left with `endWindowsProcesses`.
*/
export function windowsProcessTree(pid: number): WindowsProcess[] {
const listed = powershell(`
$all = @(Get-CimInstance Win32_Process -Property ProcessId,ParentProcessId,CreationDate)
$owned = @($all | Where-Object { $_.ProcessId -eq ${pid} })
$frontier = $owned
while ($frontier.Count -gt 0) {
if ($owned.Count -gt 256) { throw 'fixture process tree exceeded 256 processes' }
$ids = @($owned | ForEach-Object { $_.ProcessId })
$frontier = @($all | Where-Object { $child = $_; $ids -notcontains $child.ProcessId -and @($frontier | Where-Object { $_.ProcessId -eq $child.ParentProcessId -and $child.CreationDate -ge $_.CreationDate }).Count -gt 0 })
$owned += $frontier
}
ConvertTo-Json -Compress -InputObject @($owned | ForEach-Object { @{ id = $_.ProcessId; created = $_.CreationDate.ToFileTimeUtc().ToString() } })
`);
return JSON.parse(listed) as WindowsProcess[];
}

/**
* Ends `owned` and every process started from an executable under `root`
* (the fixture's shims, which hided also runs), and returns once none is
* left, so the caller can delete `root`. Throws naming the survivors after
* five seconds.
*/
export function endWindowsProcesses(owned: WindowsProcess[], root: string): void {
powershell(`
$owned = @($env:FIXTURE_OWNED | ConvertFrom-Json | ForEach-Object { $_ })
$prefix = $env:FIXTURE_ROOT.TrimEnd('\\') + '\\'
$live = {
$all = @(Get-CimInstance Win32_Process -Property ProcessId,CreationDate,ExecutablePath)
@($all | Where-Object {
$process = $_
($process.ExecutablePath -and $process.ExecutablePath.StartsWith($prefix, [StringComparison]::OrdinalIgnoreCase)) -or
@($owned | Where-Object { $_.id -eq $process.ProcessId -and $_.created -eq $process.CreationDate.ToFileTimeUtc().ToString() }).Count -gt 0
})
}
foreach ($process in & $live) { Stop-Process -Id $process.ProcessId -Force -ErrorAction SilentlyContinue }
$until = [DateTime]::UtcNow.AddSeconds(5)
do {
$remaining = @(& $live)
if ($remaining.Count -eq 0) { exit 0 }
Start-Sleep -Milliseconds 100
} while ([DateTime]::UtcNow -lt $until)
throw "fixture processes still running after 5 s: $(($remaining | ForEach-Object { "$($_.ProcessId) $($_.ExecutablePath)" }) -join ', ')"
`, { FIXTURE_OWNED: JSON.stringify(owned), FIXTURE_ROOT: root });
}
21 changes: 21 additions & 0 deletions web/e2e/worker-owned.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,24 @@ export function ownUntilWorkerExit(stop: () => void): { stop: () => void; disown
running.add(owned);
return { stop: owned, disown: () => void running.delete(owned) };
}

/**
* Runs `cleanup` after `primary` failed and returns `primary` for the caller
* to throw. A cleanup that also fails is appended to its message: Playwright
* prints the message and the stack frames, so the original failure keeps its
* text and location and the cleanup failure is reported under it.
*/
export function afterCleanup(primary: unknown, cleanup: () => void): unknown {
try {
cleanup();
} catch (secondary) {
const detail = `cleanup after it also failed: ${secondary instanceof Error ? secondary.message : String(secondary)}`;
if (!(primary instanceof Error)) return new Error(`${String(primary)}\n\n${detail}`, { cause: secondary });
try {
primary.message = `${primary.message}\n\n${detail}`;
} catch {
return new Error(`${primary.message}\n\n${detail}`, { cause: primary });
}
}
return primary;
}
Loading