Better testing for finalization
まだ誰も着手していません。
評価
調査の方向性
この issue で提案されている finalizer 仕様から始め、jruby/jruby#7267 に記載されている動作を確認します。suite で GC によってトリガーされるファイナライズをどのように実行し、警告出力を分離できるかを判断します。1 つの finalizer で発生した例外が次の finalizer に影響しない場合と、最終的なファイナライズの両方をカバーできれば完了です。
索引モデルが issue の本文から書いたものです。
説明
While attempting to write a spec for jruby/jruby#7267 I ran into various issues and questions...
- There are no specs testing that GC eventually finalizes objects. This is obviously difficult to predict, but it is behavior I believe we should be testing one way or another.
- I was testing that exceptions in one finalizer are not seen by the next finalizer, but could not figure out a way to eliminate the warning output from Ruby indicating that a finalizer raised an exception.
The spec I attempted is below, but only makes a best attempt at forcing GC-oriented finalization and still does not suppress the error output.
it "hides raised exceptions from one finalizer to the next" do
def scoped(result)
Proc.new { result << "ok" if $!.nil?; raise }
end
def test(result)
obj = "Test"
# finalizer order may vary so both handlers check $! and raise an error
ObjectSpace.define_finalizer(obj, scoped(result))
ObjectSpace.define_finalizer(obj, scoped(result))
end
result = []
begin
old_verbose, $VERBOSE = $VERBOSE, false
test(result)
ensure
$VERBOSE = old_verbose
end
100.times { GC.start; break if result.size == 2 }
result.should == ["ok", "ok"]
end
I don't want to leave the fix for jruby/jruby#7267 untested, but I'm unsure how we should move forward to improve the GC-triggered finalization specs.
- 主要言語
- Ruby
- スター
- 622
- フォーク
- 402
- 平均マージ
- 14時間 51分
- マージ済み PR(30日)
- 6
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ruby/spec のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 38/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
TheOdinProject/curriculum#31417 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
glossarist/glossarist-ruby#238 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
palladius/rails8-app-on-gcp#145 ·