Skip to content

test: cozytest.sh rewrites a lone closing brace inside a heredoc into return 0 #4667

Open

Description

hack/cozytest.sh turns every line that is exactly } into return 0 when it rewrites a bats file into shell functions. It does this without knowing whether the line sits inside a heredoc, so a test that writes a JSON or JS fixture through a heredoc ending a block with a bare } gets return 0 in the middle of its fixture: the fixture is corrupted and the test returns early, green. Found while writing hack/pr-labeler-contract.bats in #4666, which had to avoid the shape. Fix shape: skip the rewrite inside heredocs (track <<WORD until the terminator), or rewrite only the brace that closes a @test block, and add a bats case with a heredoc fixture that contains a bare } line. Related to #4620 and the move to vanilla Bats in #3849.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/testingIssues or PRs related to testing (e2e, bats, unit tests)kind/bugCategorizes issue or PR as related to a bugtriage/acceptedIndicates an issue is ready to be actively worked on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions