Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BATS_TEST_NAMES seems to not contain test names #700

@bryteise

Description

@bryteise

Describe the bug
With the change bringing in setup_file I noticed my previous mechanism for file global setup that checked the following:
"$BATS_TEST_NAME" = "${BATS_TEST_NAMES[0]}"
was no longer working.

The BATS_TEST_NAME is correct but the BATS_TEST_NAMES array has --tags as its first entry (for some reason I couldn't figure out).

To Reproduce
Steps to reproduce the behavior:

Have a single file with the following:

#!/usr/bin/env bats                                                                                                                                                                                                                           
                                                                                                                                                                                                                                              
setup() {                                                                                                                                                                                                                                     
        
        echo "${BATS_TEST_NAME}" >&3                                                                                                                                                                                                                                   
        echo "${BATS_TEST_NAMES[0]}" >&3                                                                                                                                                                                                      
                                                                                                                                                                                                                                              
}                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                              
@test "test" {                                                                                                                                                                         
                                                                                                                                                                                                                                              
      echo test >&3                                                                                                                                                                                                                             
                                                                                                                                                                                                                                              
}

Expected behavior
Outputs:
test_test
test_test
test

Instead I get:
test_test
--tags
test

Environment (please complete the following information):

  • Bats Version 1.8.2 - 1.9.0
  • OS: Linux
  • Bash version: 5.2.9

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