Skip to content

Commit

Permalink
Fix subprocess tests requires
Browse files Browse the repository at this point in the history
Using `-rtempfile` requires the tempfile built into Ruby, not the
currently developed one, so the tests aren't testing this tempfile.
  • Loading branch information
peterzhu2118 committed Aug 20, 2024
1 parent 4ad02f0 commit ea2dec6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions test/test_tempfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def test_close_bang_does_not_unlink_if_already_unlinked
end unless /mswin|mingw/ =~ RUBY_PLATFORM

def test_finalizer_removes_file
assert_in_out_err(["-r#{LIB_TEMPFILE_RB_PATH}"], <<~RUBY) do |(filename,*), (error,*)|
assert_in_out_err("-r#{LIB_TEMPFILE_RB_PATH}", <<~RUBY) do |(filename,*), (error,*)|
file = Tempfile.new("foo")
puts file.path
RUBY
Expand All @@ -185,7 +185,7 @@ def test_finalizer_removes_file
end

def test_finalizer_removes_file_when_dup
assert_in_out_err(["-r#{LIB_TEMPFILE_RB_PATH}"], <<~RUBY) do |(filename,*), (error,*)|
assert_in_out_err("-r#{LIB_TEMPFILE_RB_PATH}", <<~RUBY) do |(filename,*), (error,*)|
file = Tempfile.new("foo")
file.dup
puts file.path
Expand All @@ -196,7 +196,7 @@ def test_finalizer_removes_file_when_dup
end

def test_finalizer_removes_file_when_clone
assert_in_out_err(["-r#{LIB_TEMPFILE_RB_PATH}"], <<~RUBY) do |(filename,*), (error,*)|
assert_in_out_err("-r#{LIB_TEMPFILE_RB_PATH}", <<~RUBY) do |(filename,*), (error,*)|
file = Tempfile.new("foo")
file.clone
puts file.path
Expand All @@ -207,7 +207,7 @@ def test_finalizer_removes_file_when_clone
end

def test_finalizer_does_not_unlink_if_already_unlinked
assert_in_out_err('-rtempfile', <<-'EOS') do |(filename,*), (error,*)|
assert_in_out_err("-r#{LIB_TEMPFILE_RB_PATH}", <<-'EOS') do |(filename,*), (error,*)|
file = Tempfile.new('foo')
path = file.path
puts path
Expand All @@ -219,7 +219,7 @@ def test_finalizer_does_not_unlink_if_already_unlinked
assert_nil error
end

assert_in_out_err('-rtempfile', <<-'EOS') do |(filename,*), (error,*)|
assert_in_out_err("-r#{LIB_TEMPFILE_RB_PATH}", <<-'EOS') do |(filename,*), (error,*)|
file = Tempfile.new('foo')
path = file.path
file.unlink
Expand Down Expand Up @@ -249,7 +249,7 @@ def test_close_flushes_buffer
end

def test_tempfile_is_unlinked_when_ruby_exits
assert_in_out_err('-rtempfile', <<-'EOS') do |(filename), (error)|
assert_in_out_err("-r#{LIB_TEMPFILE_RB_PATH}", <<-'EOS') do |(filename), (error)|
puts Tempfile.new('foo').path
EOS
assert_file.for("tempfile must not be exist after GC.").not_exist?(filename)
Expand All @@ -259,7 +259,7 @@ def test_tempfile_is_unlinked_when_ruby_exits

def test_tempfile_finalizer_does_not_run_if_unlinked
bug8768 = '[ruby-core:56521] [Bug #8768]'
assert_in_out_err(%w(-rtempfile), <<-'EOS') do |(filename), (error)|
assert_in_out_err("-r#{LIB_TEMPFILE_RB_PATH}", <<-'EOS') do |(filename), (error)|
tmp = Tempfile.new('foo')
puts tmp.path
tmp.close
Expand Down

0 comments on commit ea2dec6

Please sign in to comment.