Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

in_memory_filesystem_shim test fails on Windows: in-memory keys are stored with / and looked up with \

Aperta Adatta ai principianti
#817 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust

Direzione di ricerca

Inizia in src/shim_filesystem.rs con add_in_memory_file, get_in_memory_key e il test in_memory_filesystem_shim. Esegui cargo test --release --lib 'shim_filesystem::tests::in_memory_filesystem_shim' -- --exact su Windows e verifica come sono scritti i percorsi inseriti e cercati. Il lavoro è completato quando la ricerca in memoria usa una rappresentazione coerente della chiave e il test passa su Windows senza modificare il comportamento della feature zip.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Rust
Stelle
114
Fork
85
Merge medio
1g 11h
PR unite (30g)
74

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di daisy/MathCAT

Tutte le issue di daisy/MathCAT

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.