Repository navigation
fix(sync-workspace): isolate test lock dir + fix test 27 init guard - #2026
qingyun-wu merged 2 commits into
Conversation
Two independent root causes for CI failures in tests/sync-workspace.test.sh:
1. Lock contention (tests 8, 9, 10): the default lock dir
`/tmp/sync-workspace.lock.d` was shared between test invocations and
the live `sync-workspace` cron. When the cron fired mid-test it
grabbed the lock and subsequent tests exited with "another instance
is running, skipping." Fix: `LOCK_DIR="${SUTANDO_SYNC_LOCK_DIR:-…}"`
in the script + `SUTANDO_SYNC_LOCK_DIR="$TEST_ROOT/sync.lock.d"` in
the test COMMON_ENV.
2. Test 27 init guard (exit via set -e): test 27 creates a pre-wsId
workspace (flat `host/mighost` branch) without the `.git/info/exclude`
marker that `_assert_sync_initialized()` requires. The script exits 1,
`set -euo pipefail` in the test aborts silently without printing FAIL,
and tests 27-28 never run. Fix: write the "Generated by
sync-workspace.sh" marker during test 27 setup to simulate a
legitimately-initialized-but-old workspace (which would have had it).
All 88 assertions now pass on the first try locally.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EL2XBcV3RsWhevzTPtW4jw
Coverage Gate✅ No Python changes — nothing to gate (bar: 95% on changed lines). |
|
Related: PR #1997 ( The lock contention fix ( Suggested merge order: #1997 first, then this PR — or drop the test-27 exclude-marker hunk from this PR if #1997 lands first (the lock contention fix stands on its own). |
qingyun-wu
left a comment
There was a problem hiding this comment.
Reviewed — LGTM. Parameterizing LOCK_DIR (default unchanged) is the minimal correct fix for test cross-talk, and the test-27 change is right: a legitimately-initialized pre-wsId workspace would carry the "Generated by sync-workspace.sh" marker in .git/info/exclude, so writing it in the fixture is simulating reality, not dodging the guard. CI green.
|
@cla-assistant check |
Closes
Resolves the remaining entry in
shell-ci-known-failures.txt(tracked in PR #1948).Summary
Two independent root causes for CI failures in
tests/sync-workspace.test.sh:1. Lock contention (tests 8, 9, 10)
The default lock dir
/tmp/sync-workspace.lock.dis shared between test invocations and the livesync-workspacecron. When the cron fires mid-test it steals the lock; subsequent test calls exit immediately with "another instance is running, skipping" causing assertion failures.Fix: add
SUTANDO_SYNC_LOCK_DIRenv hook tosync-workspace.sh(same pattern asSUTANDO_WS_ID_OVERRIDE,SUTANDO_TEST_MODE) and set it to a temp-dir-scoped path in the testCOMMON_ENV.2. Test 27 init guard (silent set-e abort)
Test 27 creates a pre-wsId workspace (flat
host/mighostbranch) to test the migration path. But it doesn't write the.git/info/excludemarker that_assert_sync_initialized()requires. The script exits 1,set -euo pipefailin the test aborts silently (no FAIL printed), and tests 27–28 never run — so the test exits withfail=1from this abort.Fix: write
# Generated by sync-workspace.sh — do not edit by hand.to.git/info/excludein the test 27 setup subshell. A real pre-wsId workspace would have this marker since sync-workspace.sh has always written it.Checklist
upstream/mainbefore fixTest plan
Run several times to confirm no timing-dependent failures (lock isolation eliminates the race).