shunit2_misc_test.sh is tested with the shell that set in the environment variable $SHELL.
e.g.
# Note: the test script is prefixed with '#' chars so that shUnit2 does not
# incorrectly interpret the embedded functions as real functions.
testUnboundVariable() {
unittestF="${SHUNIT_TMPDIR}/unittest"
sed 's/^#//' >"${unittestF}" <<EOF
## Treat unset variables as an error when performing parameter expansion.
#set -u
#
#boom() { x=\$1; } # This function goes boom if no parameters are passed!
#test_boom() {
# assertEquals 1 1
# boom # No parameter given
# assertEquals 0 \$?
#}
#SHUNIT_COLOR='none'
#. ${TH_SHUNIT}
EOF
( exec "${SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" )
assertFalse 'expected a non-zero exit value' $?
grep '^ASSERT:unknown failure' "${stdoutF}" >/dev/null
assertTrue 'assert message was not generated' $?
However $SHELL is not the current running shell, but the shell when login.
test_runner tries to test all installed shells, but it test only login shell (probably bash only).
I did a quick hack to test, then the current (ba130d6 and v2.1.7) test failed.
(note: $SHUNIT_SHELL was used instead of $SHELL on v2.1.7)
$ git diff
diff --git a/test_runner b/test_runner
index a9871e3..60fde40 100755
--- a/test_runner
+++ b/test_runner
@@ -129,6 +129,7 @@ EOF
# Check for existence of shell.
shell_bin=${shell}
+ export SHELL=${shell} # or SHUNIT_SHELL=${shell} on v2.1.7
shell_name=''
shell_present=${RUNNER_FALSE}
case ${shell} in
Result of ./test_runner
$ ./test_runner
#------------------------------------------------------------------------------
# System data.
#
$ uname -mprsv
Linux 5.0.0-25-generic #26-Ubuntu SMP Thu Aug 1 12:04:58 UTC 2019 x86_64 x86_64
OS Name: Linux
OS Version: Ubuntu 19.04
### Test run info.
shells: /bin/sh ash /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh
tests: shunit2_args_test.sh shunit2_asserts_test.sh shunit2_failures_test.sh shunit2_macros_test.sh shunit2_misc_test.sh shunit2_standalone_test.sh
#------------------------------------------------------------------------------
# Running the test suite with /bin/sh.
#
shell name: sh
shell version: unknown
--- Executing the 'shunit2_args' test suite. ---
non_default_test
test_non_default_ran
Ran 2 tests.
OK
--- Executing the 'shunit2_asserts' test suite. ---
testAssertEquals
testAssertNotEquals
testAssertSame
testAssertNotSame
testAssertContains
testAssertNotContains
testAssertNull
testAssertNotNull
testAssertTrue
testAssertFalse
Ran 10 tests.
OK
--- Executing the 'shunit2_failures' test suite. ---
testFail
testFailNotEquals
testFailSame
Ran 3 tests.
OK
--- Executing the 'shunit2_macros' test suite. ---
testAssertEquals
testAssertNotEquals
testSame
testNotSame
testNull
testNotNull
testAssertTrue
testAssertFalse
testFail
testFailNotEquals
testFailSame
testFailNotSame
Ran 12 tests.
OK (skipped=24)
--- Executing the 'shunit2_misc' test suite. ---
testUnboundVariable
testIssue7
testIssue29
testIssue69
testIssue77
testIssue84
ASSERT:failure message for assertFalse was not generated
shunit2:ERROR testIssue84() returned non-zero return code.
testPrepForSourcing
testEscapeCharInStr
testEscapeCharInStr_specialChars
testExtractTestFunctions
testIssue54
testColors
testColorsWitoutTERM
Ran 13 tests.
FAILED (failures=2)
--- Executing the 'shunit2_standalone' test suite. ---
#------------------------------------------------------------------------------
# Running the test suite with ash.
#
shell name: ash
shell version: 1.27.2
--- Executing the 'shunit2_args' test suite. ---
non_default_test
test_non_default_ran
Ran 2 tests.
OK
--- Executing the 'shunit2_asserts' test suite. ---
testAssertEquals
testAssertNotEquals
testAssertSame
testAssertNotSame
testAssertContains
testAssertNotContains
testAssertNull
testAssertNotNull
testAssertTrue
testAssertFalse
Ran 10 tests.
OK
--- Executing the 'shunit2_failures' test suite. ---
testFail
testFailNotEquals
testFailSame
Ran 3 tests.
OK
--- Executing the 'shunit2_macros' test suite. ---
testAssertEquals
testAssertNotEquals
testSame
testNotSame
testNull
testNotNull
testAssertTrue
testAssertFalse
testFail
testFailNotEquals
testFailSame
testFailNotSame
Ran 12 tests.
OK (skipped=24)
--- Executing the 'shunit2_misc' test suite. ---
testUnboundVariable
testIssue7
testIssue29
testIssue69
testIssue77
testIssue84
ASSERT:failure message for assertFalse was not generated
shunit2:ERROR testIssue84() returned non-zero return code.
testPrepForSourcing
testEscapeCharInStr
testEscapeCharInStr_specialChars
testExtractTestFunctions
testIssue54
testColors
testColorsWitoutTERM
Ran 13 tests.
FAILED (failures=2)
--- Executing the 'shunit2_standalone' test suite. ---
#------------------------------------------------------------------------------
# Running the test suite with /bin/bash.
#
shell name: bash
shell version: 5.0.3(1)-release
--- Executing the 'shunit2_args' test suite. ---
non_default_test
test_non_default_ran
Ran 2 tests.
OK
--- Executing the 'shunit2_asserts' test suite. ---
testAssertEquals
testAssertNotEquals
testAssertSame
testAssertNotSame
testAssertContains
testAssertNotContains
testAssertNull
testAssertNotNull
testAssertTrue
testAssertFalse
Ran 10 tests.
OK
--- Executing the 'shunit2_failures' test suite. ---
testFail
testFailNotEquals
testFailSame
Ran 3 tests.
OK
--- Executing the 'shunit2_macros' test suite. ---
testAssertEquals
testAssertNotEquals
testSame
testNotSame
testNull
testNotNull
testAssertTrue
testAssertFalse
testFail
testFailNotEquals
testFailSame
testFailNotSame
Ran 12 tests.
OK
--- Executing the 'shunit2_misc' test suite. ---
testUnboundVariable
testIssue7
testIssue29
testIssue69
testIssue77
testIssue84
testPrepForSourcing
testEscapeCharInStr
testEscapeCharInStr_specialChars
testExtractTestFunctions
testIssue54
testColors
testColorsWitoutTERM
Ran 13 tests.
OK
--- Executing the 'shunit2_standalone' test suite. ---
#------------------------------------------------------------------------------
# Running the test suite with /bin/dash.
#
shell name: dash
shell version: 0.5.10.2-4ubuntu1
--- Executing the 'shunit2_args' test suite. ---
non_default_test
test_non_default_ran
Ran 2 tests.
OK
--- Executing the 'shunit2_asserts' test suite. ---
testAssertEquals
testAssertNotEquals
testAssertSame
testAssertNotSame
testAssertContains
testAssertNotContains
testAssertNull
testAssertNotNull
testAssertTrue
testAssertFalse
Ran 10 tests.
OK
--- Executing the 'shunit2_failures' test suite. ---
testFail
testFailNotEquals
testFailSame
Ran 3 tests.
OK
--- Executing the 'shunit2_macros' test suite. ---
testAssertEquals
testAssertNotEquals
testSame
testNotSame
testNull
testNotNull
testAssertTrue
testAssertFalse
testFail
testFailNotEquals
testFailSame
testFailNotSame
Ran 12 tests.
OK (skipped=24)
--- Executing the 'shunit2_misc' test suite. ---
testUnboundVariable
testIssue7
testIssue29
testIssue69
testIssue77
testIssue84
ASSERT:failure message for assertFalse was not generated
shunit2:ERROR testIssue84() returned non-zero return code.
testPrepForSourcing
testEscapeCharInStr
testEscapeCharInStr_specialChars
testExtractTestFunctions
testIssue54
testColors
testColorsWitoutTERM
Ran 13 tests.
FAILED (failures=2)
--- Executing the 'shunit2_standalone' test suite. ---
#------------------------------------------------------------------------------
# Running the test suite with /bin/ksh.
#
shell name: ksh
shell version: AJM-93u+-2012-08-01-$
--- Executing the 'shunit2_args' test suite. ---
non_default_test
test_non_default_ran
Ran 2 tests.
OK
--- Executing the 'shunit2_asserts' test suite. ---
testAssertEquals
testAssertNotEquals
testAssertSame
testAssertNotSame
testAssertContains
testAssertNotContains
testAssertNull
testAssertNotNull
testAssertTrue
testAssertFalse
Ran 10 tests.
OK
--- Executing the 'shunit2_failures' test suite. ---
testFail
testFailNotEquals
testFailSame
Ran 3 tests.
OK
--- Executing the 'shunit2_macros' test suite. ---
testAssertEquals
testAssertNotEquals
testSame
testNotSame
testNull
testNotNull
testAssertTrue
testAssertFalse
testFail
testFailNotEquals
testFailSame
testFailNotSame
Ran 12 tests.
OK
--- Executing the 'shunit2_misc' test suite. ---
testUnboundVariable
ASSERT:expected a non-zero exit value
ASSERT:assert message was not generated
ASSERT:failure message was not generated
shunit2:ERROR testUnboundVariable() returned non-zero return code.
testIssue7
testIssue29
testIssue69
testIssue77
testIssue84
ASSERT:failure message for assertFalse was not generated
shunit2:ERROR testIssue84() returned non-zero return code.
testPrepForSourcing
testEscapeCharInStr
testEscapeCharInStr_specialChars
testExtractTestFunctions
testIssue54
testColors
testColorsWitoutTERM
Ran 13 tests.
FAILED (failures=6)
--- Executing the 'shunit2_standalone' test suite. ---
#------------------------------------------------------------------------------
# Running the test suite with /bin/pdksh.
#
runner:WARN unable to run tests with the pdksh shell
#------------------------------------------------------------------------------
# Running the test suite with /bin/zsh.
#
shell name: zsh
shell version: 5.5.1
--- Executing the 'shunit2_args' test suite. ---
non_default_test
test_non_default_ran
Ran 2 tests.
OK
--- Executing the 'shunit2_asserts' test suite. ---
testAssertEquals
testAssertNotEquals
testAssertSame
testAssertNotSame
testAssertContains
testAssertNotContains
testAssertNull
testAssertNotNull
testAssertTrue
testAssertFalse
Ran 10 tests.
OK
--- Executing the 'shunit2_failures' test suite. ---
testFail
testFailNotEquals
testFailSame
Ran 3 tests.
OK
--- Executing the 'shunit2_macros' test suite. ---
testAssertEquals
testAssertNotEquals
testSame
testNotSame
testNull
testNotNull
testAssertTrue
testAssertFalse
testFail
testFailNotEquals
testFailSame
testFailNotSame
Ran 12 tests.
OK
--- Executing the 'shunit2_misc' test suite. ---
testUnboundVariable
ASSERT:assert message was not generated
ASSERT:test count message was not generated
ASSERT:failure message was not generated
shunit2:ERROR testUnboundVariable() returned non-zero return code.
testIssue7
testIssue29
ASSERT:expected:<0> but was:<1>
testIssue69
ASSERT:failure message for assertEquals was not generated
ASSERT:failure message for assertNotEquals was not generated
ASSERT:failure message for assertNull was not generated
ASSERT:failure message for assertNotNull was not generated
ASSERT:failure message for assertSame was not generated
ASSERT:failure message for assertNotSame was not generated
ASSERT:failure message for assertTrue was not generated
ASSERT:failure message for assertFalse was not generated
shunit2:ERROR testIssue69() returned non-zero return code.
testIssue77
ASSERT:failure of oneTimeSetUp() did not end test
ASSERT:failure of setUp() did not end test
ASSERT:failure of tearDown() did not end test
ASSERT:failure of oneTimeTearDown() did not end test
shunit2:ERROR testIssue77() returned non-zero return code.
testIssue84
ASSERT:failure message for assertFalse was not generated
shunit2:ERROR testIssue84() returned non-zero return code.
testPrepForSourcing
testEscapeCharInStr
testEscapeCharInStr_specialChars
testExtractTestFunctions
testIssue54
testColors
testColorsWitoutTERM
Ran 13 tests.
FAILED (failures=21)
--- Executing the 'shunit2_standalone' test suite. ---
shunit2_misc_test.shis tested with the shell that set in the environment variable$SHELL.e.g.
However
$SHELLis not the current running shell, but the shell when login.test_runnertries to test all installed shells, but it test only login shell (probably bash only).I did a quick hack to test, then the current (ba130d6 and v2.1.7) test failed.
(note:
$SHUNIT_SHELLwas used instead of$SHELLon v2.1.7)Result of ./test_runner