たまに、rubyspec が以下のように失敗することがあります。

http://www.rubyist.net/~akr/chkbuild/debian/ruby-trunk/log/20091008T160610.log.txt.gz :

| 53)
| Prime#each when an instance created via Prime.new infinitely iterates the given block passing a prime FAILED
| Expected Timeout::Error
| but got SpecExpectationNotMetError (Expected false to be true)
| /home/akr/chkbuild/tmp/build/ruby-trunk/20091008T160610/rubyspec/library/prime/each_spec.rb:41:in `block (2 levels) in <top (required)>'
| /home/akr/chkbuild/tmp/build/ruby-trunk/20091008T160610/rubyspec/library/prime/each_spec.rb:17:in `<top (required)>'

記録を調べると今年は 15回ほど失敗しています。

% zgrep 'Prime#each infinitely iterates the given block passing a prime FAILED' 2009*log*
20090501T201000.log.txt.gz:Prime#each infinitely iterates the given block passing a prime FAILED
20090817T235403.log.txt.gz:Prime#each infinitely iterates the given block passing a prime FAILED
20090820T061900.log.txt.gz:Prime#each infinitely iterates the given block passing a prime FAILED
20090820T225200.log.txt.gz:Prime#each infinitely iterates the given block passing a prime FAILED
20090822T121606.log.txt.gz:Prime#each infinitely iterates the given block passing a prime FAILED
20090825T035002.log.txt.gz:Prime#each infinitely iterates the given block passing a prime FAILED
20090906T105301.log.txt.gz:Prime#each infinitely iterates the given block passing a prime FAILED
20090911T115004.log.txt.gz:Prime#each infinitely iterates the given block passing a prime FAILED
20090918T210300.log.txt.gz:Prime#each infinitely iterates the given block passing a prime FAILED
20090919T041101.log.txt.gz:Prime#each infinitely iterates the given block passing a prime FAILED
20090923T213200.log.txt.gz:Prime#each infinitely iterates the given block passing a prime FAILED
20090929T153305.log.txt.gz:Prime#each infinitely iterates the given block passing a prime FAILED
20090930T023500.log.txt.gz:Prime#each infinitely iterates the given block passing a prime FAILED
20090930T090400.log.txt.gz:Prime#each infinitely iterates the given block passing a prime FAILED
20091008T160610.log.txt.gz:Prime#each infinitely iterates the given block passing a prime FAILED

てきとうに調べてみると、どうも prime が timeout で中断される
と、それ以降に変な (素数でない) 値が生成されることがあるよう
です。

% ./ruby -rtimeout -rprime -ve '
e = Prime.instance
begin
  timeout(0.01) {
    e.each {|v| p v if (2..Math.sqrt(v)).any?{|n| v%n == 0 } }
  }
rescue Timeout::Error
  retry
end
'
ruby 1.9.2dev (2009-10-11 trunk 25297) [i686-linux]
1369
1369
1517
1591
1369
1517
1517
1369
...

このスクリプトは Prime.instance.each が素数でない値を生成し
たときにその値を表示します。たとえば、1369 は 37*37 なので素
数ではありません。

タイミングが関係するようなので、何も表示されなかったら中断し
て繰り返し試してみてください。

まぁ、timeout のやりかたが癌なのも確かですが、影響が後をひく
prime のつくりもよろしくないんじゃないでしょうか。
-- 
[田中 哲][たなか あきら][Tanaka Akira]