Skip to content

shunit2 test does not fail if one of the subtests fails #21

@wififreedom

Description

@wififreedom

The shunit2 test is broken, does not fail if one of the subtests fails.

To reproduce:

  • sabotage tests/shunit2/tests.d/020_get, function test_get_option() and change val in the assertEquals statement to badval.
  • run scripts/devel_build.sh

Broken output:

Running tests...
/usr/bin/ctest --force-new-ctest-process 
Test project /home/user/repos/uci/build
    Start 1: cram
1/2 Test #1: cram .............................   Passed    5.82 sec
    Start 2: shunit2
2/2 Test #2: shunit2 ..........................   Passed   52.70 sec

100% tests passed, 0 tests failed out of 2

In tests/shunit2/tests.sh:

/bin/sh ${FULL_SUITE}

rm -rf ${TESTS_DIR}

should be:

/bin/sh ${FULL_SUITE}
EXITCODE=$?

rm -rf ${TESTS_DIR}

exit ${EXITCODE}

Correct output with the above fix:

Running tests...
/usr/bin/ctest --force-new-ctest-process 
Test project /home/user/repos/uci/build
    Start 1: cram
1/2 Test #1: cram .............................   Passed    5.99 sec
    Start 2: shunit2
2/2 Test #2: shunit2 ..........................***Failed   53.68 sec
#
# Performing tests
#
test_import
test_export
test_get_parsing
test_get_section_index_parsing
test_get_option
ASSERT:expected:<badval> but was:<val>
test_get_option_multiline
test_get_section
test_set_parsing
test_set_named_section
test_set_nonexisting_option
test_set_nonexisting_option_multiline
test_set_existing_option
test_set_existing_option_multiline
test_add_section
test_get_parsing
test_get_parsing_multiline_package
test_get_parsing_multiline_section
test_get_parsing_multiline_option
test_batch_set
test_batch_comments
test_revert_section
test_revert_option
test_revert_option_multiline
test_revert_option_long
test_add_list_config
test_add_list_get
test_add_list_show
test_add_list_changes
test_del_list
test_del_list_multiline
test_add_delta
test_changes_tailing_parts
test_changes_missing_value

#
# Test report
#
tests passed:   111  99%
tests failed:     1   1%
tests skipped:    0   0%
tests total:    112 100%


50% tests passed, 1 tests failed out of 2

Total Test time (real) =  59.67 sec

The following tests FAILED:
	  2 - shunit2 (Failed)
Errors while running CTest
make: *** [Makefile:74: test] Error 8
make: Leaving directory '/home/user/repos/uci/build'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions