Skip to content

Commit

Permalink
Allow missing expect out and err files
Browse files Browse the repository at this point in the history
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 bedcbeb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# which project directory they reside in.
*.exe
*.app
*.out
*.so
*.dylib
*.dll
Expand Down Expand Up @@ -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/
32 changes: 24 additions & 8 deletions src/cmd/ksh93/tests/util/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]]
Expand Down

0 comments on commit bedcbeb

Please sign in to comment.