bin
doc
examples
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_exit_nonzero.rb
CMDTEST_exit_status.rb
CMDTEST_exit_zero.rb
CMDTEST_file_equal.rb
CMDTEST_file_not_equal.rb
CMDTEST_ignore_file.rb
CMDTEST_import_file.rb
CMDTEST_misc.rb
CMDTEST_simple.rb
CMDTEST_stdxxx_equal.rb
selftest_utils.rb
.hgignore
COPYING.txt
README.html
README.rst
Rakefile
file1.txt
file2.txt
run-regression.rb
setup.rb
185 lines
3.6 KiB
Ruby
185 lines
3.6 KiB
Ruby
|
|
require "selftest_utils"
|
|
|
|
class CMDTEST_cmd < Cmdtest::Testcase
|
|
|
|
include SelftestUtils
|
|
|
|
#----------------------------------------
|
|
# use of "cmd"
|
|
#----------------------------------------
|
|
|
|
|
|
def test_cmd_array_argument
|
|
create_CMDTEST_foo [
|
|
"cmd ['lines.rb', 'this is an argument', 'and another'] do",
|
|
" stdout_equal [",
|
|
" 'this is an argument',",
|
|
" 'and another',",
|
|
" ]",
|
|
"end",
|
|
]
|
|
|
|
cmd_cmdtest do
|
|
stdout_equal [
|
|
'### lines.rb "this is an argument" "and another"',
|
|
]
|
|
end
|
|
end
|
|
|
|
#-----------------------------------
|
|
|
|
def test_cmd_only_some_arguments_need_quoting
|
|
create_CMDTEST_foo [
|
|
"cmd ['lines.rb', 'arg1', 'a r g 2', '<arg3>'] do",
|
|
" stdout_equal [",
|
|
" 'arg1',",
|
|
" 'a r g 2',",
|
|
" '<arg3>',",
|
|
" ]",
|
|
"end",
|
|
]
|
|
|
|
cmd_cmdtest do
|
|
stdout_equal [
|
|
'### lines.rb arg1 "a r g 2" "<arg3>"',
|
|
]
|
|
end
|
|
end
|
|
|
|
#-----------------------------------
|
|
|
|
def test_cmd_array_with_no_arguments
|
|
create_CMDTEST_foo [
|
|
"cmd ['true.rb'] do",
|
|
"end",
|
|
]
|
|
|
|
cmd_cmdtest do
|
|
stdout_equal [
|
|
"### true.rb",
|
|
]
|
|
end
|
|
end
|
|
|
|
#-----------------------------------
|
|
|
|
def test_array_with_no_arguments_II
|
|
create_CMDTEST_foo [
|
|
"cmd ['false.rb'] do",
|
|
" exit_nonzero",
|
|
"end",
|
|
]
|
|
|
|
cmd_cmdtest do
|
|
stdout_equal [
|
|
"### false.rb",
|
|
]
|
|
end
|
|
end
|
|
|
|
#-----------------------------------
|
|
|
|
def test_array_with_QQ_and_BACKSLASH_in_arguments
|
|
create_CMDTEST_foo <<'_END_'
|
|
cmd ["clines", "emb\"edded 1", "emb\\edded 2", "emb\\edd\"ed 3"] do
|
|
stdout_equal [
|
|
"emb\"edded 1",
|
|
"emb\\edded 2",
|
|
"emb\\edd\"ed 3",
|
|
]
|
|
end
|
|
_END_
|
|
|
|
cmd_cmdtest do
|
|
stdout_equal [
|
|
/### .*clines.*/,
|
|
]
|
|
end
|
|
end
|
|
|
|
#-----------------------------------
|
|
|
|
def test_array_with_DOLLAR_arguments_1
|
|
create_CMDTEST_foo <<'_END_'
|
|
cmd ["clines", "emb$edded 1", "emb$$edded 2"] do
|
|
stdout_equal [
|
|
"emb$edded 1",
|
|
"emb$$edded 2",
|
|
]
|
|
end
|
|
_END_
|
|
|
|
cmd_cmdtest do
|
|
stdout_equal [
|
|
/### .*clines.*/,
|
|
]
|
|
end
|
|
end
|
|
|
|
#-----------------------------------
|
|
|
|
def test_array_with_DOLLAR_arguments_2
|
|
#
|
|
return unless windows?
|
|
|
|
create_CMDTEST_foo <<'_END_'
|
|
cmd ["clines", "emb$edded1", "emb$$edded2"] do
|
|
stdout_equal [
|
|
"emb$edded1",
|
|
"emb$$edded2",
|
|
]
|
|
end
|
|
_END_
|
|
|
|
cmd_cmdtest do
|
|
stdout_equal [
|
|
"### clines \"emb$edded1\" \"emb$$edded2\"",
|
|
]
|
|
end
|
|
end
|
|
|
|
#-----------------------------------
|
|
|
|
def test_cmd_all_characters
|
|
# (but not backslash for now)
|
|
#
|
|
return unless ! windows?
|
|
|
|
create_CMDTEST_foo <<'_END_'
|
|
all = " !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~"
|
|
cmd ["lines.rb", all] do
|
|
stdout_equal [
|
|
" !\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~"
|
|
]
|
|
end
|
|
_END_
|
|
|
|
cmd_cmdtest do
|
|
stdout_equal <<'_END_'
|
|
### lines.rb " !\"#\$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~"
|
|
_END_
|
|
end
|
|
end
|
|
|
|
#-----------------------------------
|
|
|
|
def test_BACKSLASH_character
|
|
create_CMDTEST_foo [
|
|
"all = \" ` \"",
|
|
"cmd [\"lines.rb\", all] do",
|
|
" stdout_equal [",
|
|
" \" ` \",",
|
|
" ]",
|
|
"end",
|
|
]
|
|
|
|
cmd_cmdtest do
|
|
stdout_equal [
|
|
/### .*lines.*/,
|
|
]
|
|
end
|
|
end
|
|
|
|
end
|