mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fix usages of Tempfile.open(&block) that expected the file to still be there after the block
This commit is contained in:
parent
e8c3872555
commit
3beecafc2c
2 changed files with 19 additions and 16 deletions
|
@ -2079,12 +2079,14 @@ class Reline::LineEditor
|
||||||
end
|
end
|
||||||
|
|
||||||
private def vi_histedit(key)
|
private def vi_histedit(key)
|
||||||
path = Tempfile.open { |fp|
|
Tempfile.open { |fp|
|
||||||
fp.write @line
|
fp.write @line
|
||||||
fp.path
|
path = fp.path
|
||||||
|
fp.close
|
||||||
|
|
||||||
|
system("#{ENV['EDITOR']} #{path}")
|
||||||
|
@line = File.read(path)
|
||||||
}
|
}
|
||||||
system("#{ENV['EDITOR']} #{path}")
|
|
||||||
@line = File.read(path)
|
|
||||||
finish
|
finish
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -33,20 +33,21 @@ class OpenSSL::TestX509Store < OpenSSL::TestCase
|
||||||
]
|
]
|
||||||
cert1 = issue_cert(@ca1, @rsa1024, 1, ca_exts, nil, nil)
|
cert1 = issue_cert(@ca1, @rsa1024, 1, ca_exts, nil, nil)
|
||||||
cert2 = issue_cert(@ca2, @rsa2048, 1, ca_exts, nil, nil)
|
cert2 = issue_cert(@ca2, @rsa2048, 1, ca_exts, nil, nil)
|
||||||
tmpfile = Tempfile.open { |f| f << cert1.to_pem << cert2.to_pem; f }
|
Tempfile.open { |tmpfile|
|
||||||
|
tmpfile << cert1.to_pem << cert2.to_pem
|
||||||
|
tmpfile.close
|
||||||
|
|
||||||
store = OpenSSL::X509::Store.new
|
store = OpenSSL::X509::Store.new
|
||||||
assert_equal false, store.verify(cert1)
|
assert_equal false, store.verify(cert1)
|
||||||
assert_equal false, store.verify(cert2)
|
assert_equal false, store.verify(cert2)
|
||||||
store.add_file(tmpfile.path)
|
store.add_file(tmpfile.path)
|
||||||
assert_equal true, store.verify(cert1)
|
assert_equal true, store.verify(cert1)
|
||||||
assert_equal true, store.verify(cert2)
|
assert_equal true, store.verify(cert2)
|
||||||
|
|
||||||
# OpenSSL < 1.1.1 leaks an error on a duplicate certificate
|
# OpenSSL < 1.1.1 leaks an error on a duplicate certificate
|
||||||
assert_nothing_raised { store.add_file(tmpfile.path) }
|
assert_nothing_raised { store.add_file(tmpfile.path) }
|
||||||
assert_equal [], OpenSSL.errors
|
assert_equal [], OpenSSL.errors
|
||||||
ensure
|
}
|
||||||
tmpfile and tmpfile.close!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_verify
|
def test_verify
|
||||||
|
|
Loading…
Add table
Reference in a new issue