fix(test): recreate tmpDir per test in onboard-session.test.ts (#1284)#1562
Conversation
The previous setup created tmpDir once at module load and shared it across all tests in the file. Lock files left behind by releaseOnboardLock() (or any future test that crashes mid-flight) leak into the next test, making lock-related cases order-dependent. Recreate tmpDir in beforeEach and remove it in afterEach so every test starts from a guaranteed-clean directory. Closes NVIDIA#1284
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe test file now creates and destroys a fresh temporary directory for each test case in Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
✨ Thanks for submitting this fix, which proposes a way to improve test reliability by ensuring a clean temporary directory for each test case. |
Summary
Closes #1284.
The lock-related tests in
src/lib/onboard-session.test.tsshare a singletmpDircreated once at module load.releaseOnboardLock()(and any future test that crashes mid-flight) can leave lock artifacts behind that the existingbeforeEachdoes not clean up — it only clears the module cache and session file. That makes lock cases order-dependent.Fix
Recreate
tmpDirinbeforeEachandfs.rmSyncit inafterEach, so every test starts from a guaranteed-clean directory.No production code changes; this is purely test isolation.
Test plan
vitest run src/lib/onboard-session.test.ts— 13 lock/session tests still pass.mode & 0o777 === 0o600) is a Windows-only POSIX-permissions limitation that exists onmainwith or without this change. Confirmed by stashing the patch and re-running on the same checkout.Summary by CodeRabbit