Skip to content

assertNotNull not working with set -e #174

Description

@lwinkler

It seems that shunit2 does not work with the -e flag of bash in some cases (but works fine in other). In particular assertNotNull raises an error (no matter if the assert fails or not). I don't know if the -e flag of bash is compatible with shunit2 but I use it to be sure to catch all errors.

set -e : Exit immediately if a command exits with a non-zero status.

Observed with bash 5.1.16. Here is a simple script to reproduce the bug:

set -e

testSomething() {

  # this behaves correctly
  assertNotSame "Not same" "aaa" "bbb"

  # this fails with message: ASSERT:Unknown failure encountered running a test
  assertNotNull "Not null(1)" "something"
}

source shunit2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions