Skip to content

test: strip absolute repo root from expect snapshots#37

Merged
mizchi merged 5 commits into
mainfrom
fix/test-hardcoded-repo-paths
May 26, 2026
Merged

test: strip absolute repo root from expect snapshots#37
mizchi merged 5 commits into
mainfrom
fix/test-hardcoded-repo-paths

Conversation

@mizchi
Copy link
Copy Markdown
Owner

@mizchi mizchi commented May 26, 2026

PR #36 が無事 merge されたものの、 main の CI で 14 件のテストが失敗。 原因は `executor_test.mbt` / `lib_test.mbt` / `compat_docs_test.mbt` の `debug_inspect` の expect 文字列に開発者のローカル絶対パスがハードコードされていたこと。

```diff
-"/Users/mz/ghq/github.com/mizchi/actrun/_build/test-workspaces/..."
+"/home/runner/work/actrun/actrun/_build/test-workspaces/..."
```

修正内容

  • `executor_test_strip_repo_root(s)` helper を追加: `$PWD` prefix を placeholder `` に置換
  • 17 箇所の `debug_inspect` の第一引数を helper でラップ
  • 該当する expect content を `/_build/...` に書き換え

影響範囲

  • `src/executor_test.mbt`: 10 箇所
  • `src/lib_test.mbt`: 5 箇所
  • `src/compat_docs_test.mbt`: 2 箇所

残課題 (本 PR の scope 外)

  • `nix-build` / `compat-wasi-gha` も fail していた; rate-limit でログ取れず、 同じ path 問題なのか別問題かは未確認。 この PR の CI で同じパターンか別かが判明する想定。

🤖 Generated with Claude Code

mizchi and others added 5 commits May 26, 2026 14:17
The previous PR (#36) merge landed but 14 of 861 tests fail on CI
because expect snapshots in executor_test.mbt / lib_test.mbt /
compat_docs_test.mbt baked in the developer's local absolute path
(`/Users/mz/ghq/github.com/mizchi/actrun/_build/...`). On the CI
runner the path is `/home/runner/work/actrun/actrun/_build/...` or
`/Users/runner/work/actrun/actrun/_build/...`, so the diff is
verbatim:

  -"/Users/mz/ghq/github.com/mizchi/actrun/_build/test-workspaces/..."
  +"/home/runner/work/actrun/actrun/_build/test-workspaces/..."

Fix: add `executor_test_strip_repo_root(s)` that replaces the `$PWD`
prefix with the placeholder `<repo>`, and wrap every affected
`debug_inspect`'s first arg with it (17 call sites across 3 files).
Expect content updated to use `<repo>/_build/...`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two pre-existing failures uncovered alongside the path-strip fix in
this PR — neither related to the test snapshots, but both need to go
in for the branch to be CI-green:

1. nix-build (`flake.nix` / `package.nix` reference
   `./moon.mod.json`, which the MoonBit fmt-driven migration in
   7405811 deleted in favor of `moon.mod`). moonbit-overlay's
   `buildMoonPackage.nix` still reads `moonModJson` via
   `builtins.readFile`, so it errors with
   `Path 'moon.mod.json' does not exist`.

   Fix: restore `moon.mod.json` (kept in sync with the current
   `moon.mod`). Dual-maintenance is the cheapest path until the
   overlay supports the new TOML format. Tracked there:
   https://github.com/moonbit-community/moonbit-overlay

2. compat-wasi-gha — sidecar `dist/index.js` uses CommonJS
   (`require("node:fs")`), but the root `package.json` has
   `"type": "module"`, so Node treats every `.js` under the repo
   as ESM and throws
   `ReferenceError: require is not defined in ES module scope`.

   Fix: a one-line local `package.json` in
   `.github/actions/wasi-node-sidecar/dist/` with
   `"type": "commonjs"`. Scopes the CJS interpretation to this
   prebuilt artifact without touching the root project's ESM
   policy.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop a local `package.json` with `"type": "commonjs"` next to the
sidecar's `dist/index.js` so it's interpreted as CJS regardless of
the root project's `"type": "module"`. Needed because the
prebuilt sidecar uses `require("node:fs")`, and without this scope
override compat-wasi-gha fails with
`ReferenceError: require is not defined in ES module scope`.

`-f` because `dist/` is gitignored but the sidecar's compiled
artifacts are tracked the same way (existing index.js / index.wasm
are also under the same exemption).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The pinned moonbit-overlay (50118f5 / 2026-03-31) shipped a moonc
that rejects the type-inference-friendly `with fn output(self,
logger)` syntax produced by the current `moon fmt`:

  Error: Missing type annotation for the parameter self.
  Error: Missing type annotation for the parameter logger.

Local moonc accepts it; nix-build doesn't because the toolchain
is older. Bumping the overlay to d7386ba (2026-05-26) pulls in a
moonc that matches the local one and the build goes green.

Verified locally with `nix build .#actrun` — succeeds end-to-end
(only the standard uncommitted-changes warning, no errors).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mizchi mizchi merged commit 0d2705d into main May 26, 2026
7 checks passed
@mizchi mizchi deleted the fix/test-hardcoded-repo-paths branch May 26, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant