test that readonly directory give error
ie. when cmdtest fails to remove the "work" directory between test methods. Previously cmdtest relied on FileUtils.rm_rf, but it could fail silently, leading to weird consequences.
This commit is contained in:
33
t/CMDTEST_readonly.rb
Normal file
33
t/CMDTEST_readonly.rb
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
require "selftest_utils"
|
||||||
|
|
||||||
|
class CMDTEST_readonly < Cmdtest::Testcase
|
||||||
|
|
||||||
|
include SelftestUtils
|
||||||
|
|
||||||
|
def teardown
|
||||||
|
File.chmod(0755, 'tmp-cmdtest-2/top/work/a_subdir')
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_readonly
|
||||||
|
create_CMDTEST_foo [
|
||||||
|
"cmd 'true.rb' do",
|
||||||
|
"end",
|
||||||
|
"Dir.mkdir('a_subdir')",
|
||||||
|
"File.open('a_subdir/file1', 'w') {|f| f.puts 123}",
|
||||||
|
"File.chmod(0, 'a_subdir')",
|
||||||
|
]
|
||||||
|
|
||||||
|
cmd_cmdtest do
|
||||||
|
stdout_equal [
|
||||||
|
"### true.rb",
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
cmd_cmdtest do
|
||||||
|
stderr_equal /Directory not empty/
|
||||||
|
exit_nonzero
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Reference in New Issue
Block a user