1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/fileutils] Fix test_cp_r_dev on Windows or other systems without character/block device in /dev

Previously this would give an error such as:

TestFileUtils#test_cp_r_dev [c:/fileutils/test/fileutils/test_fileutils.rb:455]:
[RuntimeError] exception expected, not.
Class: <TypeError>
Message: <"no implicit conversion of nil into String">

https://github.com/ruby/fileutils/commit/0ce0fefbeb
This commit is contained in:
Jeremy Evans 2019-08-23 14:50:34 -07:00 committed by Hiroshi SHIBATA
parent 9494ef8b2d
commit 9792c9d183
No known key found for this signature in database
GPG key ID: F9CF13417264FAC2

View file

@ -450,11 +450,11 @@ class TestFileUtils < Test::Unit::TestCase
def test_cp_r_dev
devs = Dir['/dev/*']
chardev = Dir['/dev/*'].find{|f| File.chardev?(f)}
blockdev = Dir['/dev/*'].find{|f| File.blockdev?(f)}
chardev = devs.find{|f| File.chardev?(f)}
blockdev = devs.find{|f| File.blockdev?(f)}
Dir.mkdir('tmp/cpr_dest')
assert_raise(RuntimeError) { cp_r chardev, 'tmp/cpr_dest/cd' }
assert_raise(RuntimeError) { cp_r blockdev, 'tmp/cpr_dest/bd' }
assert_raise(RuntimeError) { cp_r chardev, 'tmp/cpr_dest/cd' } if chardev
assert_raise(RuntimeError) { cp_r blockdev, 'tmp/cpr_dest/bd' } if blockdev
end
begin