Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail fails to fail the test immediately #154

Open
gqqnbig opened this issue Nov 30, 2021 · 4 comments
Open

fail fails to fail the test immediately #154

gqqnbig opened this issue Nov 30, 2021 · 4 comments
Labels

Comments

@gqqnbig
Copy link

gqqnbig commented Nov 30, 2021

blob/master/README.md says

fail [message]
Fails the test immediately.

I thus tried the following code.

$ cat t.sh
#!/bin/bash

testA() {
    fail "A"
    fail "B"

}

source shunit2

$ ./t.sh
testA
ASSERT:A
ASSERT:B
shunit2:ERROR testA() returned non-zero return code.

Ran 1 test.

FAILED (failures=2)

Because I was told fail fails the test immediately, I expect to only see ASSERT:A. However, I see ASSERT:A and ASSERT:B.

I don't know if it's a documentation bug or code bug. Please fix.

My version is 2.1.9pre.

@JohannesRudolph
Copy link

I'm using this trick to fail a test fast ls /x || return $SHUNIT_FALSE

I think the documentation could be clearer about the fact that any "normal" methods to exit a shell script early on an error such as set -e or set -o errexit seems to have no effect with shunit2

@williamdes
Copy link
Collaborator

Can you test the current dev version by copy pasting shunit2 from this repository ?
Ref: #164 - some fixes where made for set -e

@gqqnbig
Copy link
Author

gqqnbig commented Dec 22, 2022

@williamdes

I don't know what the current dev version is, but I tested https://github.com/kward/shunit2/blob/master/shunit2 again. The output is the same as what I posted one year ago. The problem is not fixed.

@williamdes
Copy link
Collaborator

Thank you, this is what I expected you to test
Now we are sure some more fixing should be done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants