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

Warning "can only `return' from a function or sourced script" when executing in standalone mode (in Bash shell) #158

Open
JussiPekonen opened this issue Jun 27, 2022 · 1 comment · May be fixed by #159

Comments

@JussiPekonen
Copy link

Description

When shunit2 is executed in standalone mode (in Bash shell) and there are failing test cases, there will be a warning message "can only `return' from a function or sourced script" printed out to the shell after the execution.

Steps to reproduce

  1. Test file
#!/bin/bash

testFailure() {
  assertEquals "${SHUNIT_TRUE}" "${SHUNIT_FALSE}"
}
  1. Use the latest version from the master branch
  2. Run the test in standalone mode, ./shunit2 <file>

Expected result

The command will exit with a non-zero exit code and the test report contains only details of the tests and where they failed.

Actual result

The report printout contains an unnecessary warning "can only `return' from a function or sourced script" in addition to the test results.

Notes

There is no issue when the test file (given above) sources the shunit2 file. Therefore, this issue affects only the standalone mode.

@JussiPekonen
Copy link
Author

Fix available in #159.

@williamdes williamdes linked a pull request Jun 28, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant