Project

General

Profile

Bug #3538

psych tests sometimes fail

Added by akr (Akira Tanaka) about 9 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 1.9.3dev (2010-06-30 trunk 28489) [x86_64-darwin10.3.1]
Backport:
[ruby-core:31047]

Description

=begin
psych tests sometimes fail.

% ./ruby test/runner.rb psych
Loaded suite test/runner
Started
...(snip)...
Finished in 1.003971 seconds.

1) Failure:
test_time_utc_no_z(Psych::Visitors::TestToRuby)
[/home/ruby/tcio/ruby/test/psych/visitors/test_to_ruby.rb:134]:
Expected 2010-07-05 13:21:36 UTC, not 2010-07-05 22:21:36 +0900.

2) Failure:
test_time_utc(Psych::Visitors::TestToRuby)
[/home/ruby/tcio/ruby/test/psych/visitors/test_to_ruby.rb:126]:
Expected 2010-07-05 13:21:36 UTC, not 2010-07-05 13:21:36 UTC.

3) Failure:
test_time(Psych::Visitors::TestToRuby)
[/home/ruby/tcio/ruby/test/psych/visitors/test_to_ruby.rb:118]:
Expected 2010-07-05 22:21:36 +0900, not 2010-07-05 22:21:36 +0900.

4) Failure:
test_time(Psych::Visitors::TestYAMLTree)
[/home/ruby/tcio/ruby/test/psych/visitors/test_yaml_tree.rb:57]:
Expected 2010-07-05 22:21:36 +0900, not 2010-07-05 22:21:36 +0900.

321 tests, 954 assertions, 4 failures, 0 errors, 0 skips

Test run options: --seed 25269
zsh: exit 1 ./ruby test/runner.rb psych
% ./ruby -v
ruby 1.9.3dev (2010-07-05 trunk 28542) [i686-linux]

I run psych tests 1000 times.
It seems the 6 tests can fail.

% grep 'test' log|sort|uniq -c
89 test_round_trip(Psych::TestDateTime)
[/home/ruby/tcio/ruby/test/psych/test_date_time.rb:14]:
101 test_time(Psych::Visitors::TestToRuby)
[/home/ruby/tcio/ruby/test/psych/visitors/test_to_ruby.rb:118]:
100 test_time(Psych::Visitors::TestYAMLTree)
[/home/ruby/tcio/ruby/test/psych/visitors/test_yaml_tree.rb:57]:
111 test_time_now_cycle(Psych_Unit_Tests)
[/home/ruby/tcio/ruby/test/psych/test_yaml.rb:1157]:
102 test_time_utc(Psych::Visitors::TestToRuby)
[/home/ruby/tcio/ruby/test/psych/visitors/test_to_ruby.rb:126]:
101 test_time_utc_no_z(Psych::Visitors::TestToRuby)
[/home/ruby/tcio/ruby/test/psych/visitors/test_to_ruby.rb:134]:
--
Tanaka Akira
=end

History

#1

Updated by tenderlovemaking (Aaron Patterson) about 9 years ago

  • Assignee set to tenderlovemaking (Aaron Patterson)
  • ruby -v set to ruby 1.9.3dev (2010-06-30 trunk 28489) [x86_64-darwin10.3.1]

=begin

=end

#2

Updated by tenderlovemaking (Aaron Patterson) about 9 years ago

=begin
Seems this isn't just a problem with psych. When psych fails to round trip the time, marshal seems to fail too. Apply this patch:

diff --git a/test/psych/test_yaml.rb b/test/psych/test_yaml.rb
index 45cd39d..f5c6b1c 100644
--- a/test/psych/test_yaml.rb
+++ b/test/psych/test_yaml.rb
@@ -1154,6 +1154,14 @@ EOY
t = Time.now
t = Time.at(t.tv_sec, t.tv_usec)
5.times do

  • f = Psych.load Psych.dump t
  • if f != t
  • p Psych.dump(t) => Psych.dump(f)
  • p t.to_f - f.to_f
  • p(:marshal => (t == Marshal.load(Marshal.dump(f))))
  • raise "wtf"
  • end
  • assert_equal(t, f) assert_cycle(t) end end

Then run the tests like this:

$ make test-all TESTS='psych/test_yaml.rb -n test_time_now_cycle'

I'm still investigating, but this is strange.
=end

#3

Updated by akr (Akira Tanaka) about 9 years ago

=begin
2010/7/6 Aaron Patterson redmine@ruby-lang.org:

Seems this isn't just a problem with psych. When psych fails to round trip the time, marshal seems to fail too. Apply this patch:

Then run the tests like this:

$ make test-all TESTS='psych/test_yaml.rb -n test_time_now_cycle'

% make test-all TESTS='psych/test_yaml.rb -n test_time_now_cycle'
./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb
./tool/runruby.rb --extout=.ext -- "./test/runner.rb"
psych/test_yaml.rb -n test_time_now_cycle
Loaded suite ./test/runner
Started
{"--- 2010-07-06 06:03:22.26126000 +09:00\n"=>"--- 2010-07-06
06:03:22.261260000 +09:00\n"}
-0.23513388633728027
{:marshal=>false}
E
Finished in 0.077630 seconds.

1) Error:
test_time_now_cycle(Psych_Unit_Tests):
RuntimeError: wtf
/home/ruby/tcio/ruby/test/psych/test_yaml.rb:1162:in block in
test_time_now_cycle'
/home/ruby/tcio/ruby/test/psych/test_yaml.rb:1156:in
times'
/home/ruby/tcio/ruby/test/psych/test_yaml.rb:1156:in `test_time_now_cycle'

1 tests, 0 assertions, 0 failures, 1 errors, 0 skips

Test run options: --seed 46970 --name "test_time_now_cycle"
--
Tanaka Akira

=end

#4

Updated by tenderlovemaking (Aaron Patterson) about 9 years ago

=begin
On Tue, Jul 06, 2010 at 06:13:50AM +0900, Tanaka Akira wrote:

2010/7/6 Aaron Patterson redmine@ruby-lang.org:

Seems this isn't just a problem with psych. When psych fails to round trip the time, marshal seems to fail too. Apply this patch:

Then run the tests like this:

$ make test-all TESTS='psych/test_yaml.rb -n test_time_now_cycle'

% make test-all TESTS='psych/test_yaml.rb -n test_time_now_cycle'
./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb
./tool/runruby.rb --extout=.ext -- "./test/runner.rb"
psych/test_yaml.rb -n test_time_now_cycle
Loaded suite ./test/runner
Started
{"--- 2010-07-06 06:03:22.26126000 +09:00\n"=>"--- 2010-07-06
06:03:22.261260000 +09:00\n"}
-0.23513388633728027
{:marshal=>false}

It's interesting that marshal won't round trip in this case too.

--
Aaron Patterson
http://tenderlovemaking.com/

Attachment: (unnamed)
=end

#5

Updated by akr (Akira Tanaka) about 9 years ago

=begin
2010/7/6 Aaron Patterson aaron@tenderlovemaking.com:

It's interesting that marshal won't round trip in this case too.

Your patch compare t and Marshal.load(Marshal.dump(f)).

When t and f is different, they are different.
It doesn't mean Marshal doesn't round trip.
--
Tanaka Akira

=end

#6

Updated by tenderlovemaking (Aaron Patterson) about 9 years ago

=begin
On Tue, Jul 06, 2010 at 07:25:35AM +0900, Tanaka Akira wrote:

2010/7/6 Aaron Patterson aaron@tenderlovemaking.com:

It's interesting that marshal won't round trip in this case too.

Your patch compare t and Marshal.load(Marshal.dump(f)).

When t and f is different, they are different.
It doesn't mean Marshal doesn't round trip.

You're right. My mistake.

--
Aaron Patterson
http://tenderlovemaking.com/

Attachment: (unnamed)
=end

#7

Updated by Anonymous about 9 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r28551.
Akira, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Also available in: Atom PDF