Skip to content

Filter not working with test_ prefix #299

@Chemaclass

Description

@Chemaclass
Q A
OS macOS / Linux / Windows
Shell sh / bash / ...
bashunit version 0.14

Current behavior

The filter is not working when using full test name (with test_ prefix)

Screenshot 2024-07-17 at 09 23 29

How to reproduce

./bashunit tests/unit/state_test.sh -f test_calculate_total_assertions

Expected behavior

./bashunit tests/unit/state_test.sh -f calculate_total_assertions
# should work as
./bashunit tests/unit/state_test.sh -f test_calculate_total_assertions

HINT

  1. A test:
# tests/unit/helpers_test.sh

# below: test_get_functions_to_run_with_filter_should_return_matching_functions

function test_get_functions_to_run_with_filter_but_complete_function_name() {
  local functions=("prefix_function1" "prefix_function2" "other_function" "prefix_function3")

  assert_equals "prefix_function2" "$(helper::get_functions_to_run "prefix" "prefix_function2" "${functions[*]}")"
}
  1. The code:
    Inside helper::get_functions_to_run:61 add an OR condition to check that the fn is equal to the filter regex only without the prefix. E.g.:
# src/helpers.sh

|| $fn == ${filter}* 

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions