Fixed test environment for escaped test output.
- test-lib uses 'read -r' to parse the test session input literally, without interpretation of backslashes. - FIX: Use quoting to maintain original whitespace (tabs and multiple spaces) from the test session input (instead of condensing into a single space). - Using Bash instead of POSIX shell for t1340-listescapes.sh, so that the interpretation of escape sequences is not dependent on the POSIX shell being used. - Changed Makefile so that the shell selected by the shebang line is actually used when invoking tests, not the POSIX shell. - Above changes obsolete the multiple escaping of the test session data; now, the test session can actually be pasted as-is into a test script, even when it contains backslashes. (I.e. works as expected now.)
This commit is contained in:
2
Makefile
2
Makefile
@@ -42,7 +42,7 @@ test-pre-clean:
|
|||||||
aggregate-results: $(TESTS)
|
aggregate-results: $(TESTS)
|
||||||
|
|
||||||
$(TESTS): test-pre-clean
|
$(TESTS): test-pre-clean
|
||||||
-cd tests && sh $(notdir $@) $(TEST_OPTIONS)
|
-cd tests && ./$(notdir $@) $(TEST_OPTIONS)
|
||||||
|
|
||||||
test: aggregate-results
|
test: aggregate-results
|
||||||
tests/aggregate-results.sh tests/test-results/t*-*
|
tests/aggregate-results.sh tests/test-results/t*-*
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
|
|
||||||
test_description='list with escape sequences
|
test_description='list with escape sequences
|
||||||
@@ -7,10 +7,6 @@ This test checks listing of tasks that have embedded escape sequences in them.
|
|||||||
'
|
'
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
# Note: The quadrupled escaped backslashes (even 8-fold for the escape color
|
|
||||||
# code) in the expected output are necessary due to (superfluous?!)
|
|
||||||
# interpretation of the expected output in the test library itself.
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# check aborted list output on \c escape sequence
|
# check aborted list output on \c escape sequence
|
||||||
#
|
#
|
||||||
@@ -23,13 +19,13 @@ EOF
|
|||||||
test_todo_session 'aborted list output on backslash-c' <<'EOF'
|
test_todo_session 'aborted list output on backslash-c' <<'EOF'
|
||||||
>>> todo.sh ls
|
>>> todo.sh ls
|
||||||
1 first todo
|
1 first todo
|
||||||
2 second todo run C:\\\\WINDOWS\\\\sysnative\\\\cscript.exe
|
2 second todo run C:\WINDOWS\sysnative\cscript.exe
|
||||||
3 third todo
|
3 third todo
|
||||||
--
|
--
|
||||||
TODO: 3 of 3 tasks shown
|
TODO: 3 of 3 tasks shown
|
||||||
|
|
||||||
>>> todo.sh ls 2
|
>>> todo.sh ls 2
|
||||||
2 second todo run C:\\\\WINDOWS\\\\sysnative\\\\cscript.exe
|
2 second todo run C:\WINDOWS\sysnative\cscript.exe
|
||||||
--
|
--
|
||||||
TODO: 1 of 3 tasks shown
|
TODO: 1 of 3 tasks shown
|
||||||
EOF
|
EOF
|
||||||
@@ -45,9 +41,9 @@ EOF
|
|||||||
|
|
||||||
test_todo_session 'various escape sequences' <<'EOF'
|
test_todo_session 'various escape sequences' <<'EOF'
|
||||||
>>> todo.sh ls
|
>>> todo.sh ls
|
||||||
1 first todo with \\\\\\\\, \\\\a and \\\\t
|
1 first todo with \\, \a and \t
|
||||||
2 second todo with \\\\r\\\\n line break
|
2 second todo with \r\n line break
|
||||||
3 third todo with \\\\x42\\\\x55\\\\x47 and \\\\\\\\033[0;31m color codes \\\\\\\\033[0;30m
|
3 third todo with \x42\x55\x47 and \033[0;31m color codes \033[0;30m
|
||||||
--
|
--
|
||||||
TODO: 3 of 3 tasks shown
|
TODO: 3 of 3 tasks shown
|
||||||
EOF
|
EOF
|
||||||
|
|||||||
@@ -527,7 +527,7 @@ test_todo_session () {
|
|||||||
cmd=""
|
cmd=""
|
||||||
status=0
|
status=0
|
||||||
> expect
|
> expect
|
||||||
while read line
|
while read -r line
|
||||||
do
|
do
|
||||||
case $line in
|
case $line in
|
||||||
">>> "*)
|
">>> "*)
|
||||||
@@ -552,7 +552,7 @@ test_todo_session () {
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo $line >> expect
|
echo "$line" >> expect
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user