bin
doc
examples
files
lib
python
src
t
bin
00-assert.rb
00-exit_nonzero.rb
00-exit_status.rb
00-exit_zero.rb
00-file_equal.rb
00-file_not_equal.rb
00-ignore_file.rb
00-import_file.rb
00-stderr_equal.rb
00-stderr_not_equal.rb
00-stdout_equal.rb
00-stdout_not_equal.rb
01-cmd.rb
01-misc.rb
01-simple.rb
CMDTEST_assert.rb
CMDTEST_chdir.rb
CMDTEST_cmd.rb
CMDTEST_crnl.rb
CMDTEST_dont_ignore_files.rb
CMDTEST_exit_nonzero.rb
CMDTEST_exit_status.rb
CMDTEST_exit_zero.rb
CMDTEST_file_encoding.rb
CMDTEST_file_equal.rb
CMDTEST_file_not_equal.rb
CMDTEST_ignore_file.rb
CMDTEST_import_directory.rb
CMDTEST_import_file.rb
CMDTEST_misc.rb
CMDTEST_options.rb
CMDTEST_output_encoding.rb
CMDTEST_raise.rb
CMDTEST_readonly.rb
CMDTEST_setenv.rb
CMDTEST_simple.rb
CMDTEST_skip_test.rb
CMDTEST_stdxxx_contain.rb
CMDTEST_stdxxx_equal.rb
CMDTEST_summary.rb
CMDTEST_teardown.rb
CMDTEST_unicode.rb
selftest_utils.rb
.gitignore
.hgignore
CMDTEST_example.yml
CMakeLists.txt
COPYING.txt
README.html
README.rst
Rakefile
cmdtest.gemspec
file1.txt
file2.txt
replace_strings.pl
run-regression.rb
setup.rb
135 lines
2.9 KiB
Ruby
135 lines
2.9 KiB
Ruby
|
|
require "selftest_utils"
|
|
|
|
class CMDTEST_ignore_file < Cmdtest::Testcase
|
|
|
|
include SelftestUtils
|
|
|
|
#----------------------------------------
|
|
# an ignored file is not counted as a created file
|
|
# even when it is actually created
|
|
|
|
def test_ignore_file_IGNORED
|
|
create_CMDTEST_foo [
|
|
"ignore_file 'bbb'",
|
|
"",
|
|
"cmd 'touch.rb aaa bbb' do",
|
|
" created_files 'aaa'",
|
|
"end",
|
|
]
|
|
|
|
cmd_cmdtest do
|
|
stdout_equal [
|
|
"### touch.rb aaa bbb",
|
|
]
|
|
end
|
|
end
|
|
|
|
#----------------------------------------
|
|
# it is ok for an ignored file to not be created
|
|
|
|
def test_ignore_file_IGNORED_NOT_CREATED
|
|
create_CMDTEST_foo [
|
|
"ignore_file 'bbb'",
|
|
"",
|
|
"cmd 'touch.rb aaa' do",
|
|
" created_files 'aaa'",
|
|
"end",
|
|
]
|
|
|
|
cmd_cmdtest do
|
|
stdout_equal [
|
|
"### touch.rb aaa",
|
|
]
|
|
end
|
|
end
|
|
|
|
#----------------------------------------
|
|
# 'created_files' is wrong if the file is mentioned,
|
|
# even when the file actually was created
|
|
|
|
def test_ignore_file_AS_IF_NOT_CREATED
|
|
create_CMDTEST_foo [
|
|
"ignore_file 'bbb'",
|
|
"",
|
|
"cmd 'touch.rb aaa bbb' do",
|
|
" created_files 'aaa', 'bbb'",
|
|
"end",
|
|
]
|
|
|
|
cmd_cmdtest do
|
|
stdout_equal [
|
|
'### touch.rb aaa bbb',
|
|
'--- ERROR: created files',
|
|
'--- actual: ["aaa"]',
|
|
'--- expect: ["aaa", "bbb"]',
|
|
]
|
|
exit_nonzero
|
|
end
|
|
end
|
|
|
|
#----------------------------------------
|
|
# the ignored file can have a directory component in the filename
|
|
|
|
def test_ignore_file_IGNORED_IN_SUBDIR
|
|
create_CMDTEST_foo [
|
|
"ignore_file 'dir/bbb'",
|
|
"dir_mkdir 'dir'",
|
|
"",
|
|
"cmd 'touch.rb aaa bbb dir/aaa dir/bbb' do",
|
|
" created_files 'aaa', 'bbb', 'dir/aaa'",
|
|
"end",
|
|
]
|
|
|
|
cmd_cmdtest do
|
|
stdout_equal [
|
|
"### touch.rb aaa bbb dir/aaa dir/bbb",
|
|
]
|
|
end
|
|
end
|
|
|
|
#----------------------------------------
|
|
# the argument to 'ignore_file' is the *path* to a file,
|
|
# not just the basename.
|
|
|
|
def test_ignore_file_PATH_MATTERS
|
|
create_CMDTEST_foo [
|
|
"ignore_file 'bbb'",
|
|
"dir_mkdir 'dir'",
|
|
"",
|
|
"cmd 'touch.rb aaa bbb dir/aaa dir/bbb' do",
|
|
" created_files 'aaa', 'dir/aaa', 'dir/bbb'",
|
|
"end",
|
|
]
|
|
|
|
cmd_cmdtest do
|
|
stdout_equal [
|
|
"### touch.rb aaa bbb dir/aaa dir/bbb",
|
|
]
|
|
end
|
|
end
|
|
|
|
#----------------------------------------
|
|
# the argument to 'ignore_file' can contain shell wildcards,
|
|
# both * and **
|
|
|
|
def test_ignore_file_SHELL_GLOB
|
|
create_CMDTEST_foo [
|
|
"ignore_file 'bbb*'",
|
|
"ignore_file '**/ccc'",
|
|
"dir_mkdir 'dir'",
|
|
"",
|
|
"cmd 'touch.rb aaa bbb1 bbb2 ccc dir/aaa dir/bbb1 dir/bbb2 dir/ccc' do",
|
|
" created_files 'aaa', 'dir/aaa', 'dir/bbb1', 'dir/bbb2'",
|
|
"end",
|
|
]
|
|
|
|
cmd_cmdtest do
|
|
stdout_equal [
|
|
"### touch.rb aaa bbb1 bbb2 ccc dir/aaa dir/bbb1 dir/bbb2 dir/ccc",
|
|
]
|
|
end
|
|
end
|
|
|
|
end
|