in_memory_filesystem_shim test fails on Windows: in-memory keys are stored with / and looked up with \
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- operating-systems
Research direction
Start in src/shim_filesystem.rs with add_in_memory_file, get_in_memory_key, and the in_memory_filesystem_shim test. Run cargo test --release --lib 'shim_filesystem::tests::in_memory_filesystem_shim' -- --exact on Windows and inspect how inserted and looked-up paths are spelled. Done means the in-memory lookup uses a consistent key representation and the test passes on Windows without changing the zip feature behavior.
Written by the indexing model from the issue text.
Description
On Windows, shim_filesystem::tests::in_memory_filesystem_shim fails on main (0.7.6-rc.4) at the first assertion:
thread 'shim_filesystem::tests::in_memory_filesystem_shim' panicked at src\shim_filesystem.rs:549:9:
assertion failed: is_file_shim(file_path)
Reproduce with cargo test --release --lib 'shim_filesystem::tests::in_memory_filesystem_shim' -- --exact. It fails in isolation, so it is not interference from another test. It does not show up under --features include-zip, because the test module is gated on not(any(target_family = "wasm", feature = "include-zip")).
Cause
The in-memory map is written with one key spelling and read with another.
add_in_memory_file inserts the path exactly as the caller wrote it:
files.get_or_insert_with(HashMap::new).insert(path.to_string(), content.to_string());
Every lookup goes through get_in_memory_key, which runs the path through canonicalize_shim. That function rebuilds the path component by component with PathBuf::push, and on Windows push joins with a backslash:
inserted: virtual/rules/Languages/en/test_Rules.yaml
looked up: virtual\rules\Languages\en\test_Rules.yaml
match: false
So the key never matches and is_file_shim falls through to path.is_file(), which is false for a path that only exists in the map.
On Linux and macOS push joins with /, the two strings are equal, and the test passes. That is presumably why CI has not caught it.
Suggested fix
Have add_in_memory_file store get_in_memory_key(Path::new(path)) rather than the raw string, so writes and reads agree on one spelling. The zip-backed branch already solves the same problem with canonicalize_path_separators, so normalising to / in get_in_memory_key would work too and would keep the two branches consistent.
Happy to send a patch if you would like one. Found while working on #816.
- Dominant language
- Rust
- Stars
- 114
- Forks
- 85
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 66
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from daisy/MathCAT
-
bug rules
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
discussion
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
discussion translation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement good first issue rules rust
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
discussion rules
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
bug core
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
JIT-compiled number -> Decimal conversion silently overflows instead of raising DECIMAL_OVERFLOW Openfuzz
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ClickHouse/ClickHouse#122114 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
linebender/vello_svg#90 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
state:needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
zed-industries/zed#64742 · 1 comment ·