Skip to content

unbound errors if setup_suite is present and SHELLOPTS="" ist set #640

@jkroepke

Description

@jkroepke

Describe the bug
Hi,

i'm running some coverage test with bats and bashcov. By default, bashcov sets the SHELLOPTS environment variable to xtrace. This implicit enables nounset on the whole bats run, too. All errors are reproducible by having an empty SHELLOPTS variables defined. Thats the reason, why I'm report many unbound error in history.

Since I'm trying to integrate the setup_suite method on my current tests, I'm getting a unbound error

core/lib/bats-core/tracing.bash: line 19: BATS_TEST_NAME: unbound variable

by adding an empty setup_suite function on setup_suite.bash. In case, setup_suite.bash contains syntax errors, I'm getting

core/libexec/bats-core/bats-exec-suite: line 275: BATS_SETUP_SUITE_COMPLETED: unbound variable

On MacOS, there is always an additional error:

core/libexec/bats-core/bats-exec-suite: line 283: stack_trace[@]: unbound variable

To Reproduce
Steps to reproduce the behavior:

  1. Create a load.bash file inside test directory
  2. Create a setup_suite.bash inside the test directory:
    setup_suite() {
      true
    }
  3. Run test suite with --tap and env SHELLOPTS="", e.g. env SHELLOPTS="" bats --tap -r tests
  4. See error
    1..1
    /work/tests/bats/core/lib/bats-core/tracing.bash: line 19: BATS_TEST_NAME: unbound variable
    not ok 1 setup_suite
    

Expected behavior
A clear and concise description of what you expected to happen.

Environment (please complete the following information):

  • Bats Version [e.g. 1.4.0 or commit hash] c97b3a1
  • OS: [e.g. Linux, FreeBSD, MacOS] Linux / MacOS
  • Bash version: [e.g. 5.1] 5.0.17(1)-release / 3.2.57(1)-release

Additional context
All error only appears, if a setup_suite.bash with a setup_suite function exists and SHELLOPTS is set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: Bash CodeEverything regarding the bash codePriority: CriticalBroken behavior in nearly all environments, e.g. wrong test results, internal bats errorStatus: ConfirmedThe reproducer worked as describedType: Bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions