Skip to content

fix(pstack): make the statechart tests pass when TMPDIR is a symlink or LD_PRELOAD is unavailable - #924

Open
oesni wants to merge 1 commit into
cursor:mainfrom
oesni:fix/statechart-test-tmpdir
Open

oesni wants to merge 1 commit into
cursor:mainfrom
oesni:fix/statechart-test-tmpdir

Conversation

@oesni

@oesni oesni commented Oct 26, 2026 •

Copy link
Copy Markdown

Fixes #923.

Two assumptions in statechart.test.mjs break the suite outside a plain Linux /tmp. Only the test file changes. The statechart scripts are unchanged.

  • The tests build expected paths from tmpdir(), while the script sees its cwd with symlinks resolved. When TMPDIR goes through a symlink, which is the default on macOS (/var -> /private/var), path comparisons and rel() output no longer match. The test file now defines tmpdir as realpathSync(os.tmpdir()), so every temp folder the tests make is already resolved. The 119 call sites stay as they are.
  • The rename tests load a preload library with LD_PRELOAD, which only the Linux dynamic loader honors. They skipped only when the library failed to compile, so on macOS they ran and failed. The preload is now built only on Linux, and elsewhere these tests skip with "needs LD_PRELOAD on Linux, or cannot compile a rename preload". That covers five tests. Four of them failed on macOS. The fifth, "a run on a filesystem that cannot rename copies its files into place", expects exit 0, so it passed there only because rename was never made to fail.

Validation, full statechart.test.mjs (150 tests) with TLC 1.7.4:

Setup main This PR
Linux node:22-bookworm, default /tmp 0 failed, 5 skipped 0 failed, 5 skipped
Linux, TMPDIR set to a symlink 13 failed 0 failed, 5 skipped
macOS, default TMPDIR 18 failed, 4 skipped 0 failed, 9 skipped

On Linux the rename tests still run and pass. The five skips there are the same tests as on main; they need mise, extra fonts or a PID namespace, which the container lacks. On macOS the nine skips are the original four plus the five rename tests.

node scripts/generate-pstack-harness-trees.mjs updated the Claude Code copy, and --check, node scripts/validate-plugins.mjs and git diff --check pass.


Note

Low Risk
Test-only changes with no production statechart script modifications.

Overview
Fixes statechart integration tests that assumed a canonical /tmp path and that LD_PRELOAD rename injection always works.

Test temp directories now use realpathSync(os.tmpdir()) via a local tmpdir() helper, so paths match what the statechart CLI resolves when TMPDIR is symlinked (e.g. macOS /var → /private/var). Existing join(tmpdir(), …) call sites are unchanged.

The rename-failure preload shim is only built on Linux; on other platforms failingRenames is null and the five LD_PRELOAD-dependent tests skip with an updated message instead of running and failing.

Reviewed by Cursor Bugbot for commit d78323d. Bugbot is set up for automated code reviews on this repo. Configure here.

@deanrie

deanrie commented Oct 29, 2026

Copy link
Copy Markdown

Hey @oesni, #977 replaced the .mjs statechart with the TypeScript compiler and deleted test/statechart.test.mjs, so this branch now conflicts on a file that no longer exists on main. The two assumptions you fixed carried over into the new suite: the symlinked TMPDIR case is what @VDrozd-Cyclis's #997 fixes in test/cli.test.ts (confirmed on macOS: 125/1 on main, 126/0 with #997), and #1017's new tool-paths.test.ts has the same os.tmpdir()-without-realpathSync shape. #923 is still the open issue for it. Unless you want to port the LD_PRELOAD/rename half to the TypeScript tests, this PR can close in favour of #997.

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.

statechart: tests fail when TMPDIR goes through a symlink (the macOS default) or where LD_PRELOAD is unavailable

2 participants