Skip to content

Commit

Permalink
[GR-20446] Skip failing ObjectSpace.dump/.dump_all specs on Ruby 2.7
Browse files Browse the repository at this point in the history
PullRequest: truffleruby/3705
  • Loading branch information
eregon committed Mar 14, 2023
2 parents f319111 + 4c079d5 commit 5e81941
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 32 deletions.
10 changes: 6 additions & 4 deletions spec/ruby/library/objectspace/dump_all_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@
stdout.should == "File\ntrue\n"
end

it "dumps Ruby heap to a temporary file when passed output: :nil" do
stdout = ruby_exe(<<~RUBY, options: "-robjspace")
ruby_version_is "3.0" do
it "dumps Ruby heap to a temporary file when passed output: :nil" do
stdout = ruby_exe(<<~RUBY, options: "-robjspace")
string = "abc"
file = ObjectSpace.dump_all(output: nil)
Expand All @@ -71,9 +72,10 @@
file.close
File.unlink file.path
end
RUBY
RUBY

stdout.should == "File\ntrue\n"
stdout.should == "File\ntrue\n"
end
end

it "dumps Ruby heap to stdout when passed output: :stdout" do
Expand Down
60 changes: 32 additions & 28 deletions spec/ruby/library/objectspace/dump_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,49 @@
string.should include('"value":"abc"')
end

it "dumps to a temporary file when passed output: :file" do
file = ObjectSpace.dump("abc", output: :file)
file.should be_kind_of(File)
ruby_version_is "3.0" do
it "dumps to a temporary file when passed output: :file" do
file = ObjectSpace.dump("abc", output: :file)
file.should be_kind_of(File)

file.rewind
content = file.read
content.should include('"value":"abc"')
ensure
file.close
File.unlink file.path
end
file.rewind
content = file.read
content.should include('"value":"abc"')
ensure
file.close
File.unlink file.path
end

it "dumps to a temporary file when passed output: :nil" do
file = ObjectSpace.dump("abc", output: nil)
file.should be_kind_of(File)
it "dumps to a temporary file when passed output: :nil" do
file = ObjectSpace.dump("abc", output: nil)
file.should be_kind_of(File)

file.rewind
file.read.should include('"value":"abc"')
ensure
file.close
File.unlink file.path
file.rewind
file.read.should include('"value":"abc"')
ensure
file.close
File.unlink file.path
end
end

it "dumps to stdout when passed output: :stdout" do
stdout = ruby_exe('ObjectSpace.dump("abc", output: :stdout)', options: "-robjspace").chomp
stdout.should include('"value":"abc"')
end

it "dumps to provided IO when passed output: IO" do
filename = tmp("io_read.txt")
io = File.open(filename, "w+")
result = ObjectSpace.dump("abc", output: io)
result.should.equal? io
ruby_version_is "3.0" do
it "dumps to provided IO when passed output: IO" do
filename = tmp("io_read.txt")
io = File.open(filename, "w+")
result = ObjectSpace.dump("abc", output: io)
result.should.equal? io

io.rewind
io.read.should include('"value":"abc"')
ensure
io.close
rm_r filename
io.rewind
io.read.should include('"value":"abc"')
ensure
io.close
rm_r filename
end
end

it "raises ArgumentError when passed not supported :output value" do
Expand Down

0 comments on commit 5e81941

Please sign in to comment.