Skip to content

Commit 4b5f671

Browse files
eregonaycabta
authored andcommitted
Revert changes to rdoc & rubygems regarding Tempfile.open(&block)
* They likely want to support older Ruby/tempfile versions * Reverts part of e8c3872555fc85640505974e6b1c39d315572689
1 parent 7e83dff commit 4b5f671

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

test/rdoc/test_rdoc_parser.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def test_class_for_executable
106106
def test_class_for_forbidden
107107
omit 'chmod not supported' if Gem.win_platform?
108108

109-
Tempfile.open 'forbidden' do |io|
109+
tf = Tempfile.open 'forbidden' do |io|
110110
begin
111111
File.chmod 0000, io.path
112112
forbidden = @store.add_file io.path
@@ -117,7 +117,9 @@ def test_class_for_forbidden
117117
ensure
118118
File.chmod 0400, io.path
119119
end
120+
io
120121
end
122+
tf.close!
121123
end
122124

123125
def test_class_for_modeline

test/rdoc/test_rdoc_rd_block_parser.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def test_parse_include_subtree
154154
blank_line,
155155
blank_line)
156156

157-
Tempfile.open %w[parse_include .rd] do |io|
157+
tf = Tempfile.open %w[parse_include .rd] do |io|
158158
io.puts "=begin\ninclude ((*worked*))\n=end"
159159
io.flush
160160

@@ -163,7 +163,9 @@ def test_parse_include_subtree
163163
STR
164164

165165
assert_equal expected, parse(str)
166+
io
166167
end
168+
tf.close!
167169
end
168170

169171
def test_parse_heading

test/rdoc/test_rdoc_rdoc.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,16 @@ def test_parse_file_encoding
349349
@rdoc.options.encoding = Encoding::ISO_8859_1
350350
@rdoc.store = RDoc::Store.new
351351

352-
Tempfile.open 'test.txt' do |io|
352+
tf = Tempfile.open 'test.txt' do |io|
353353
io.write 'hi'
354354
io.rewind
355355

356356
top_level = @rdoc.parse_file io.path
357357

358358
assert_equal Encoding::ISO_8859_1, top_level.absolute_name.encoding
359+
io
359360
end
361+
tf.close!
360362
end
361363

362364
def test_parse_file_forbidden
@@ -365,7 +367,7 @@ def test_parse_file_forbidden
365367

366368
@rdoc.store = RDoc::Store.new
367369

368-
Tempfile.open 'test.txt' do |io|
370+
tf = Tempfile.open 'test.txt' do |io|
369371
io.write 'hi'
370372
io.rewind
371373

@@ -384,7 +386,9 @@ def test_parse_file_forbidden
384386
ensure
385387
File.chmod 0400, io.path
386388
end
389+
io
387390
end
391+
tf.close!
388392
end
389393

390394
def test_remove_unparseable
@@ -481,7 +485,7 @@ def test_setup_output_dir_exists_empty_created_rid
481485
end
482486

483487
def test_setup_output_dir_exists_file
484-
Tempfile.open 'test_rdoc_rdoc' do |tempfile|
488+
tf = Tempfile.open 'test_rdoc_rdoc' do |tempfile|
485489
path = tempfile.path
486490

487491
e = assert_raise RDoc::Error do
@@ -490,7 +494,9 @@ def test_setup_output_dir_exists_file
490494

491495
assert_match(%r%#{Regexp.escape path} exists and is not a directory%,
492496
e.message)
497+
tempfile
493498
end
499+
tf.close!
494500
end
495501

496502
def test_setup_output_dir_exists_not_rdoc

0 commit comments

Comments
 (0)