Skip to content

Add variable to track bats call arguments#882

Open
soda480 wants to merge 1 commit into
bats-core:masterfrom
soda480:master
Open

Add variable to track bats call arguments#882
soda480 wants to merge 1 commit into
bats-core:masterfrom
soda480:master

Conversation

@soda480

@soda480 soda480 commented Mar 7, 2024

Copy link
Copy Markdown

Having such a variable is useful for use cases where downstream functions can call bats with the original arguments, for example I am defining a setup_suite to automatically generate a coverage report and badge, I can use this variable like:

coverage() {
    if which kcov; then
        echo "# generating coverage report using kcov" >&3
        # strip --setup-suite-file argument to prevent infinite loop condition
        kcov --include-path=$WORK_DIR $WORK_DIR/coverage bats ${BATS_ARGS%--setup-suite-file*}
        coverage_badge
    else
        echo "# unable to generate coverage report because kcov is not installed" >&3
    fi
}

@soda480
soda480 requested a review from a team as a code owner March 7, 2024 18:09
@martin-schulze-vireso

Copy link
Copy Markdown
Member

I think we have to take more care with separators. Maybe printf -v BATS_ARGS '%q ' "$@"?

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 this pull request may close these issues.

2 participants