require file argument to 'import_file' + test
This commit is contained in:
parent
3baa2c5133
commit
393a92ae33
@ -26,6 +26,7 @@ require "stringio"
|
||||
module Cmdtest
|
||||
|
||||
class AssertFailed < RuntimeError ; end
|
||||
class UsageError < RuntimeError ; end
|
||||
|
||||
# Base class for testcases.
|
||||
# Some attributes and methods are prefixed with an "_" to avoid
|
||||
@ -88,7 +89,11 @@ module Cmdtest
|
||||
src_path = File.expand_path(src, @_runner.test_files_top)
|
||||
tgt_path = _cwd_path(tgt)
|
||||
FileUtils.mkdir_p(File.dirname(tgt_path))
|
||||
FileUtils.cp(src_path, tgt_path)
|
||||
if File.file?(src_path)
|
||||
FileUtils.cp(src_path, tgt_path)
|
||||
else
|
||||
raise UsageError, "'import_file' argument not a file: '#{src}'"
|
||||
end
|
||||
end
|
||||
|
||||
#------------------------------
|
||||
|
@ -9,6 +9,22 @@ class CMDTEST_import_file < Cmdtest::Testcase
|
||||
# import_file
|
||||
#----------------------------------------
|
||||
|
||||
def test_import_file_ERROR
|
||||
create_file "file1.dir/empty.txt", ""
|
||||
|
||||
create_CMDTEST_foo [
|
||||
"import_file 'file1.dir', 'qwerty1.dir'",
|
||||
]
|
||||
|
||||
cmd_cmdtest do
|
||||
stdout_equal /CAUGHT EXCEPTION:/
|
||||
stdout_equal /'import_file' argument not a file: 'file1.dir'/
|
||||
exit_nonzero
|
||||
end
|
||||
end
|
||||
|
||||
#----------------------------------------
|
||||
|
||||
def test_import_file_DIFFERENT_DIRS
|
||||
create_file "file1.txt", "This is file1.txt\n"
|
||||
create_file "file2.txt", "This is file2.txt\n"
|
||||
|
Loading…
x
Reference in New Issue
Block a user