From 5accadac014e0cfe08691a6e23735af2ec6c3550 Mon Sep 17 00:00:00 2001 From: Thomas Kosiewski Date: Thu, 29 Oct 2026 23:03:55 +0000 Subject: [PATCH] test: skip the mouse-safety suite when the addon does not load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gate it with nativeSupport() like test/terminal.test.ts and test/workers.test.ts, so npm test without a built addon exits 0. Update the README notes that said the suite fails without the addon. Signed-off-by: Thomas Kosiewski --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `medium`_ Change-Id: I4f0c73de4ee08eea111ef47e10792334768a301d --- native/README.md | 2 +- src/README.md | 2 +- test/mouse-safety.test.ts | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/native/README.md b/native/README.md index 5236fa9..e444411 100644 --- a/native/README.md +++ b/native/README.md @@ -76,5 +76,5 @@ C++ declarations: - Run (after `npm ci`): `npm run build:libghostty && npm run build:native && npm test` - Every native test skips when the addon does not load (`test/native-support.ts:nativeSupport`), so check the test output for skips. - `mise run ci-ubsan` builds the addon with UBSan (Linux, GCC), then runs the tests and smoke. Undefined behavior aborts the run. The task also fails when the addon's object files contain no UBSan checks, which means the flags did not reach g++ (`mise.toml:tasks.ci-ubsan`). -- `test/workers.test.ts` checks the per-environment state in child processes with `worker_threads`. `test/terminal.test.ts` covers `feed`, `snapshot`, `resize`, `dispose`, the `RangeError` cases of the `createTerminal` checks in the addon, the `encodeMouse` bytes of each mouse format, `cursorVisible`, and the cell style fields. `test/mouse-safety.test.ts` runs the `encodeMouse` limits and the getter re-entry cases against both the package API and the raw addon object. It does not skip when the addon is missing. Its child-process cases load `src/` through `tsx`, so they need no `dist/` build. No vitest test covers `formatPlain`, `formatHtml`, `includeScrollback`, or the typed-array errors. +- `test/workers.test.ts` checks the per-environment state in child processes with `worker_threads`. `test/terminal.test.ts` covers `feed`, `snapshot`, `resize`, `dispose`, the `RangeError` cases of the `createTerminal` checks in the addon, the `encodeMouse` bytes of each mouse format, `cursorVisible`, and the cell style fields. `test/mouse-safety.test.ts` runs the `encodeMouse` limits and the getter re-entry cases against both the package API and the raw addon object. It skips when the addon is missing, like the other native suites. Its child-process cases load `src/` through `tsx`, so they need no `dist/` build. No vitest test covers `formatPlain`, `formatHtml`, `includeScrollback`, or the typed-array errors. - For changes to `TerminalWrap` or `InitAll`, also run the TLA+ lifecycle model: [`.agents/skills/verify-native-lifecycle/SKILL.md`](https://github.com/coder/libghostty-vt-node/blob/main/.agents/skills/verify-native-lifecycle/SKILL.md). diff --git a/src/README.md b/src/README.md index 5bc3498..db864aa 100644 --- a/src/README.md +++ b/src/README.md @@ -62,4 +62,4 @@ Internal (not exported by the package): ## Verification - Run (after `npm ci`): `npm run typecheck && npm test` -- Without a built addon, only the `createTerminal validation` suite in `test/terminal.test.ts` runs, and `test/load.test.ts` accepts the load error instead. The native suite in `test/terminal.test.ts` and all of `test/workers.test.ts` skip (`test/native-support.ts:nativeSupport`). `test/mouse-safety.test.ts` does not skip: it fails without a built addon. Its child-process cases load `src/` through `tsx`, so they need no `dist/` build. `test/workers.test.ts` loads the addon directly, so it tests `native/`, not `src/`. To run the native suite, build the addon first: `npm run build:libghostty && npm run build:native`. +- Without a built addon, only the `createTerminal validation` suite in `test/terminal.test.ts` runs, and `test/load.test.ts` accepts the load error instead. The native suite in `test/terminal.test.ts`, all of `test/workers.test.ts`, and all of `test/mouse-safety.test.ts` skip (`test/native-support.ts:nativeSupport`). The child-process cases in `test/mouse-safety.test.ts` load `src/` through `tsx`, so they need no `dist/` build. `test/workers.test.ts` loads the addon directly, so it tests `native/`, not `src/`. To run the native suite, build the addon first: `npm run build:libghostty && npm run build:native`. diff --git a/test/mouse-safety.test.ts b/test/mouse-safety.test.ts index 05d4760..63ae3e5 100644 --- a/test/mouse-safety.test.ts +++ b/test/mouse-safety.test.ts @@ -2,6 +2,10 @@ import { describe, expect, it } from "vitest"; import { spawnSync } from "node:child_process"; import { createTerminal } from "../src/index.js"; import { loadNative } from "../src/loader.js"; +import { nativeSupport } from "./native-support.js"; + +const support = nativeSupport(); +const describeIfNative = support.available ? describe : describe.skip; const geometry = { screenWidth: 80, screenHeight: 24, cellWidth: 1, cellHeight: 1, @@ -12,7 +16,7 @@ const geometry = { const childArgs = ["--import", "tsx", "--input-type=module", "-e"]; // Exercise the C++ boundary independently of the public TypeScript normalizer. -describe.each([ +describeIfNative.each([ ["public", createTerminal], ["native", (options: { cols: number; rows: number }) => loadNative().createTerminal(options)], ] as const)("%s mouse safety", (_name, create) => {