use ^@, ^A,... escapes in XML output + test

to avoid writing non-printable characters
to the XML file.
This commit is contained in:
Johan Holmberg
2016-12-07 21:44:46 +01:00
parent 017db356db
commit b80d52c480
2 changed files with 53 additions and 1 deletions

45
t/CMDTEST_junit.rb Normal file
View File

@ -0,0 +1,45 @@
require "selftest_utils"
class CMDTEST_junit < Cmdtest::Testcase
include SelftestUtils
def make_files(cmd="true")
create_file "CMDTEST_foo.rb", [
"class CMDTEST_foo1 < Cmdtest::Testcase",
" def setup",
" prepend_path #{BIN.inspect}",
" prepend_path #{PLATFORM_BIN.inspect}",
" end",
"",
' def test_foo1',
' cmd "%s" do' % cmd,
' end',
' end',
'',
'end',
]
end
def test_1
make_files("echo_ctrl_chars.rb 1:5 27:32")
cmd_cmdtest_verbose "--quiet --xml=tmp.xml" do
exit_nonzero
stdout_contain [
"### echo_ctrl_chars.rb 1:5 27:32",
"--- ERROR: wrong stdout",
/--- \^A --- \x01 ---/,
/--- \^B --- \x02 ---/,
]
created_files "tmp.xml"
file_equal "tmp.xml", /--- \^A --- \^A ---/
file_equal "tmp.xml", /--- \^B --- \^B ---/
file_equal "tmp.xml", /--- \^\[ --- \^\[ ---/
end
end
end