Files
bin
doc
examples
lib
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_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
cmdtest/t/CMDTEST_stdxxx_equal.rb
Johan Holmberg 21411e4a87 Renamed "echo-stdout.rb" and "echo-stderr.rb"
to get automatic addition of "ruby -S" on Windows.
2011-11-04 23:12:48 +01:00

356 lines
9.0 KiB
Ruby

require "selftest_utils"
class CMDTEST_stdxxx_equal < Cmdtest::Testcase
include SelftestUtils
#========================================
# Using "define_method" to avoid duplicating definitions of
# stderr/stdout methods. The follwing section tests:
#
# stderr_equal
# stderr_not_equal
# stdout_equal
# stdout_not_equal
#
def self._define_stdxxx_methods(stdxxx)
#----------------------------------------
# stdxxx_equal
#----------------------------------------
## methods: test_stdout_equal_CORRECT_EMPTY test_stderr_equal_CORRECT_EMPTY
define_method("test_#{stdxxx}_equal_CORRECT_EMPTY") do
create_CMDTEST_foo [
"cmd 'true.rb' do",
" #{stdxxx}_equal ''",
"end",
]
cmd_cmdtest do
stdout_equal [
"### true.rb",
]
end
end
#----------------------------------------
## methods: test_stdout_equal_INCORRECT_EMPTY test_stderr_equal_INCORRECT_EMPTY
define_method("test_#{stdxxx}_equal_INCORRECT_EMPTY") do
create_CMDTEST_foo [
"cmd 'echo_#{stdxxx}.rb hello world' do",
" #{stdxxx}_equal ''",
"end",
]
cmd_cmdtest do
stdout_equal [
"### echo_#{stdxxx}.rb hello world",
"--- ERROR: wrong #{stdxxx}",
"--- actual: hello world",
"--- expect: [[empty]]",
]
exit_nonzero
end
end
#----------------------------------------
## methods: test_stdout_equal_CORRECT_NO_LINES test_stderr_equal_CORRECT_NO_LINES
define_method("test_#{stdxxx}_equal_CORRECT_NO_LINES") do
create_CMDTEST_foo [
"cmd 'true.rb' do",
" #{stdxxx}_equal []",
"end",
]
cmd_cmdtest do
stdout_equal [
"### true.rb",
]
end
end
#----------------------------------------
## methods: test_stdout_equal_INCORRECT_NO_LINES test_stderr_equal_INCORRECT_NO_LINES
define_method("test_#{stdxxx}_equal_INCORRECT_NO_LINES") do
create_CMDTEST_foo [
"cmd 'echo_#{stdxxx}.rb hello world' do",
" #{stdxxx}_equal []",
"end",
]
cmd_cmdtest do
stdout_equal [
"### echo_#{stdxxx}.rb hello world",
"--- ERROR: wrong #{stdxxx}",
"--- actual: hello world",
"--- expect: [[empty]]",
]
exit_nonzero
end
end
#----------------------------------------
## methods: test_stdout_equal_CORRECT_1_LINE test_stderr_equal_CORRECT_1_LINE
define_method("test_#{stdxxx}_equal_CORRECT_1_LINE") do
create_CMDTEST_foo [
"cmd 'echo_#{stdxxx}.rb hello world' do",
" #{stdxxx}_equal [ 'hello world' ]",
"end",
]
cmd_cmdtest do
stdout_equal [
"### echo_#{stdxxx}.rb hello world",
]
end
end
#----------------------------------------
## methods: test_stdout_equal_INCORRECT_1_LINE test_stderr_equal_INCORRECT_1_LINE
define_method("test_#{stdxxx}_equal_INCORRECT_1_LINE") do
create_CMDTEST_foo [
"cmd 'true.rb' do",
" #{stdxxx}_equal [ 'hello world' ]",
"end",
]
cmd_cmdtest do
stdout_equal [
"### true.rb",
"--- ERROR: wrong #{stdxxx}",
"--- actual: [[empty]]",
"--- expect: hello world",
]
exit_nonzero
end
end
#----------------------------------------
## methods: test_stdout_equal_CORRECT_2_LINES test_stderr_equal_CORRECT_2_LINES
define_method("test_#{stdxxx}_equal_CORRECT_2_LINES") do
create_CMDTEST_foo [
"cmd 'echo_#{stdxxx}.rb hello && echo_#{stdxxx}.rb world' do",
" #{stdxxx}_equal [ 'hello', 'world' ]",
"end",
]
cmd_cmdtest do
stdout_equal [
"### echo_#{stdxxx}.rb hello && echo_#{stdxxx}.rb world",
]
end
end
#----------------------------------------
## methods: test_stdout_equal_INCORRECT_2_LINES test_stderr_equal_INCORRECT_2_LINES
define_method("test_#{stdxxx}_equal_INCORRECT_2_LINES") do
create_CMDTEST_foo [
"cmd 'true.rb' do",
" #{stdxxx}_equal [ 'hello', 'world' ]",
"end",
]
cmd_cmdtest do
stdout_equal [
"### true.rb",
"--- ERROR: wrong #{stdxxx}",
"--- actual: [[empty]]",
"--- expect: hello",
"--- world",
]
exit_nonzero
end
end
#----------------------------------------
# stdxxx_not_equal
#----------------------------------------
## methods: test_stdout_not_equal_CORRECT_EMPTY test_stderr_not_equal_CORRECT_EMPTY
define_method("test_#{stdxxx}_not_equal_CORRECT_EMPTY") do
create_CMDTEST_foo [
"cmd 'echo_#{stdxxx}.rb hello' do",
" #{stdxxx}_not_equal ''",
"end",
]
cmd_cmdtest do
stdout_equal [
"### echo_#{stdxxx}.rb hello",
]
end
end
#----------------------------------------
## methods: test_stdout_not_equal_INCORRECT_EMPTY test_stderr_not_equal_INCORRECT_EMPTY
define_method("test_#{stdxxx}_not_equal_INCORRECT_EMPTY") do
create_CMDTEST_foo [
"cmd 'true.rb' do",
" #{stdxxx}_not_equal ''",
"end",
]
cmd_cmdtest do
stdout_equal [
"### true.rb",
"--- ERROR: wrong #{stdxxx}",
"--- actual: [[empty]]",
"--- expect: [[empty]]",
]
exit_nonzero
end
end
#----------------------------------------
## methods: test_stdout_not_equal_CORRECT_NO_LINES test_stderr_not_equal_CORRECT_NO_LINES
define_method("test_#{stdxxx}_not_equal_CORRECT_NO_LINES") do
create_CMDTEST_foo [
"cmd 'echo_#{stdxxx}.rb hello' do",
" #{stdxxx}_not_equal []",
"end",
]
cmd_cmdtest do
stdout_equal [
"### echo_#{stdxxx}.rb hello",
]
end
end
#----------------------------------------
## methods: test_stdout_not_equal_INCORRECT_NO_LINES test_stderr_not_equal_INCORRECT_NO_LINES
define_method("test_#{stdxxx}_not_equal_INCORRECT_NO_LINES") do
create_CMDTEST_foo [
"cmd 'true.rb' do",
" #{stdxxx}_not_equal []",
"end",
]
cmd_cmdtest do
stdout_equal [
"### true.rb",
"--- ERROR: wrong #{stdxxx}",
"--- actual: [[empty]]",
"--- expect: [[empty]]",
]
exit_nonzero
end
end
#----------------------------------------
## methods: test_stdout_not_equal_CORRECT_1_LINE test_stderr_not_equal_CORRECT_1_LINE
define_method("test_#{stdxxx}_not_equal_CORRECT_1_LINE") do
create_CMDTEST_foo [
"cmd 'echo_#{stdxxx}.rb not hello world' do",
" #{stdxxx}_not_equal [ 'hello world' ]",
"end",
]
cmd_cmdtest do
stdout_equal [
"### echo_#{stdxxx}.rb not hello world",
]
end
end
#----------------------------------------
## methods: test_stdout_not_equal_INCORRECT_1_LINE test_stderr_not_equal_INCORRECT_1_LINE
define_method("test_#{stdxxx}_not_equal_INCORRECT_1_LINE") do
create_CMDTEST_foo [
"cmd 'echo_#{stdxxx}.rb hello world' do",
" #{stdxxx}_not_equal [ 'hello world' ]",
"end",
]
cmd_cmdtest do
stdout_equal [
"### echo_#{stdxxx}.rb hello world",
"--- ERROR: wrong #{stdxxx}",
"--- actual: hello world",
"--- expect: hello world",
]
exit_nonzero
end
end
#----------------------------------------
## methods: test_stdout_not_equal_CORRECT_2_LINES test_stderr_not_equal_CORRECT_2_LINES
define_method("test_#{stdxxx}_not_equal_CORRECT_2_LINES") do
create_CMDTEST_foo [
"cmd 'echo_#{stdxxx}.rb hello world' do",
" #{stdxxx}_not_equal [ 'hello', 'world' ]",
"end",
]
cmd_cmdtest do
stdout_equal [
"### echo_#{stdxxx}.rb hello world",
]
end
end
#----------------------------------------
## methods: test_stdout_not_equal_INCORRECT_2_LINES test_stderr_not_equal_INCORRECT_2_LINES
define_method("test_#{stdxxx}_not_equal_INCORRECT_2_LINES") do
create_CMDTEST_foo [
"cmd 'echo_#{stdxxx}.rb hello && echo_#{stdxxx}.rb world' do",
" #{stdxxx}_not_equal [ 'hello', 'world' ]",
"end",
]
cmd_cmdtest do
stdout_equal [
"### echo_#{stdxxx}.rb hello && echo_#{stdxxx}.rb world",
"--- ERROR: wrong #{stdxxx}",
"--- actual: hello",
"--- world",
"--- expect: hello",
"--- world",
]
exit_nonzero
end
end
end # _define_stdxxx_methods
#----------------------------------------
for stdxxx in ["stderr", "stdout"]
_define_stdxxx_methods(stdxxx)
end
end