Permalink
Browse files

Allow missing expect out and err files

It's annoying to have to create empty stdout and stderr files for
expect based unit tests. So make them optional.
  • Loading branch information...
krader1961 committed Aug 16, 2018
1 parent c52c149 commit bedcbebf7812e2d95499ef9abf81815d2785476e
Showing with 30 additions and 9 deletions.
  1. +6 −1 .gitignore
  2. +24 −8 src/cmd/ksh93/tests/util/run_test.sh
View
@@ -7,7 +7,6 @@
# which project directory they reside in.
*.exe
*.app
*.out
*.so
*.dylib
*.dll
@@ -35,5 +34,11 @@
._*
Desktop.ini
# This is a special suffix. There is exactly one directory where we expect
# files with a `.out` extension: the ksh93 unit tests. So exclude it
# everywhere then allow it in the ksh93 unit test directory.
*.out
!src/cmd/ksh93/tests/*.out
# Artifacts of the build and test process that should not be committed.
build/
@@ -115,18 +115,34 @@ function run_interactive {
>$test_name.out 2>$test_name.err
exit_status=$?
if ! diff -q $TEST_SRC_DIR/$test_name.out $test_name.out >/dev/null
if [[ -e $TEST_SRC_DIR/$test_name.out ]]
then
log_error "Stdout for $test_name had unexpected differences:"
diff -U3 $TEST_SRC_DIR/$test_name.out $test_name.out >&2
exit_status=1
if ! diff -q $TEST_SRC_DIR/$test_name.out $test_name.out >/dev/null
then
log_error "Stdout for $test_name had unexpected differences:"
diff -U3 $TEST_SRC_DIR/$test_name.out $test_name.out >&2
exit_status=1
fi
elif [[ -s $test_name.out ]]
then
log_error "Stdout for $test_name should have been empty:"
cat $test_name.out >&2
exit_status=1
fi
if ! diff -q $TEST_SRC_DIR/$test_name.err $test_name.err >/dev/null
if [[ -e $TEST_SRC_DIR/$test_name.err ]]
then
if ! diff -q $TEST_SRC_DIR/$test_name.err $test_name.err >/dev/null
then
log_error "Stderr for $test_name had unexpected differences:"
diff -U3 $TEST_SRC_DIR/$test_name.err $test_name.err >&2
exit_status=1
fi
elif [[ -s $test_name.err ]]
then
log_error "Stderr for $test_name had unexpected differences:"
diff -U3 $TEST_SRC_DIR/$test_name.err $test_name.err >&2
exit_status=1
log_error "Stderr for $test_name should have been empty:"
cat $test_name.err >&2
exit_status=1
fi
if [[ $exit_status -eq 0 ]]

0 comments on commit bedcbeb

Please sign in to comment.