Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Improving Marshal specs

オープン
#1,355 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
リファクタリング
明瞭さ
説明が足りない
活発さ
静か
技術スタック
ruby
領域
testing-qa

調査の方向性

まず spec/ruby/core/marshal/dump_spec.rb と、既存の DATA および DATA_19 の fixture の使用方法を読み、報告されている Range の dump 失敗を再現します。現在の dump と load の spec 構造を比較し、jruby/jruby#9405 の再帰的な Set のケースを含め、fixture で両方向をどのようにカバーすべきかを判断します。Marshal の spec が明確で保守しやすいアプローチを使用し、カスタムブロックを増やすことなく必要な Set のカバレッジが含まれていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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)?
主要言語
Ruby
スター
622
フォーク
402
平均マージ
14時間 51分
マージ済み PR(30日)
6

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ruby/spec のほかの issue

ruby/spec の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。