fix(chisel): clean up stale session cache file on rename#15797
Conversation
mablr
left a comment
There was a problem hiding this comment.
The rename behavior makes sense and the normal write-before-delete flow is correct, but the case-insensitive path collision and use of the real user cache in the regression test should be fixed before merge. Also, the documented focused command needs the module-qualified test name: repl::save_renamed_session_removes_stale_cache; as written, it runs 0 tests.
|
Addressed the review feedback in commit fd16fa0.
Validation:
The focused REPL integration test currently times out before the prompt in this macOS environment, before the rename scenario runs; the library suite and production binary compilation pass. |
|
Follow-up for the CI failure: the clippy job reported Fixed in commit Validation:
The local toolchains do not have the clippy component installed, so the repository CI is the clippy verification for this one-line lint fix. |
|
|
||
| repl.sendln(&format!("!save {first_id}")); | ||
| // The nested path makes the write fail without touching the existing cache file. | ||
| repl.sendln_raw("!save invalid/id"); |
There was a problem hiding this comment.
This failure fixture still depends on state in the real user cache: if ~/.foundry/cache/chisel/chisel-invalid/ already exists, this save succeeds instead of exercising rollback. Please build the missing parent from unique_cache_id (for example, <unique-id>/id) and assert the save error before consuming the prompt.
| repl.sendln(&format!("!save {new_id}")); | ||
|
|
||
| // On case-insensitive filesystems, both IDs resolve to the same cache path. | ||
| repl.sendln_raw(&format!("!load {new_id}")); |
There was a problem hiding this comment.
On a case-sensitive filesystem this only proves that the destination survives; it does not prove that the old lowercase cache was removed. An implementation that skips every case-only cleanup would pass while leaving both files. Please detect whether the two paths alias and, when they are distinct, also assert that loading old_id fails.
|
Addressed both follow-ups in d2aa655.
Validation:
|
Closes #15796
What
When a saved Chisel session is saved again under a different ID, the new cache file is written but the old
chisel-<id>.jsonfile remains. This makes!listshow a stale session and allows the old ID to be loaded.This change removes the previous cache file after the renamed session is successfully written. Re-saving with the same ID is unchanged, and a missing old file is treated as a no-op.
Tests
!savewith two IDs,!list,!load <old-id>, and!load latest.cargo test -p chisel --test it -- save_renamed_session_removes_stale_cache -- --exactcargo test -p chiselcargo fmt --all --checkgit diff --checkThe full package test was also run with network access for the Solc/Foundry fixtures.