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

Improving Marshal specs

Aperta
#1,355 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
38/100
Tipo di issue
Refactoring
Chiarezza
Da chiarire
Stato di attività
Tranquilla
Stack tecnologico
ruby
Ambito
testing-qa

Direzione di ricerca

Inizia leggendo spec/ruby/core/marshal/dump_spec.rb e l’uso esistente delle fixture DATA e DATA_19, quindi riproduci i fallimenti di dump di Range segnalati. Confronta la struttura attuale delle spec di dump e load e determina come le fixture dovrebbero coprire entrambe le direzioni, incluso il caso ricorsivo di Set di jruby/jruby#9405. Il lavoro è completo quando le spec di Marshal usano un approccio chiaro e manutenibile e includono la copertura necessaria di Set senza accumulare blocchi personalizzati.

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

Descrizione

We recently received a bug report about improper linking during recursive Set dumping and loading (jruby/jruby#9405). The fix is simple, but attempting to add a spec for it brought to my attention how messy the existing Marshal specs are.

Many classes have custom spec blocks when they could be using the DATA or DATA_19 fixtures. Those fixtures currently appear to only be used for verifying loads; when I tried to use them to also verify the output of dumps, several of them fail:

1)
Marshal.dump 1..2 returns the expected output FAILED
Expected 
"\x04\bo:
Range\b:\texclF:
begini\x06:\bendi\a" == 
"\x04\bo:
Range\b:
begini\x06:\texclF:\bendi\a"
to be truthy but was false
/Users/headius/work/jruby/spec/ruby/core/marshal/dump_spec.rb:1011:in 'block (3 levels) in <top (required)>'
/Users/headius/work/jruby/spec/ruby/core/marshal/dump_spec.rb:6:in '<top (required)>'

2)
Marshal.dump 1...2 returns the expected output FAILED
Expected 
"\x04\bo:
Range\b:\texclT:
begini\x06:\bendi\a" == 
"\x04\bo:
Range\b:
begini\x06:\texclT:\bendi\a"
to be truthy but was false
/Users/headius/work/jruby/spec/ruby/core/marshal/dump_spec.rb:1011:in 'block (3 levels) in <top (required)>'
/Users/headius/work/jruby/spec/ruby/core/marshal/dump_spec.rb:6:in '<top (required)>'

...more

Both the load and dump specs have also gotten very large, making maintenance difficult. They contain logic specific to various other core types, and frequently hardcode marshal output strings that appear to have changed slightly over time.

I file this because I'm not sure the best course of action to clean this up. The specs I need for jruby/jruby#9405 would be small (and also the first Set-related Marshal specs), but I'm reluctant to just add another custom spec block for such simple cases. It would be nice to figure out the "right" way to handle Marshal dump and load specs so this doesn't continue to compound.

A few thoughts here:

  • Perhaps the marshal logic for each core class should live in that class's spec directory? There could be some common fixture code to make it trivial, but even if they don't all override dump and load logic, they all have unique Marshal formats.
  • Alternatively, could we clean up the canned DATA and DATA_19 hashes so that they fully pass for those cases, and only use custom specs when such canned cases can't be easily automated (such as recursive collections)?
Lingua principale
Ruby
Stelle
622
Fork
402
Merge medio
14h 51m
PR unite (30g)
6

Guida per i contributori

Apri la guida per i contributori

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 ruby/spec

Tutte le issue di ruby/spec

Issue simili

Altre issue su Ruby

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.