Skip to content

languages: Fix command used for Go subtests#42734

Merged
dinocosta merged 1 commit intomainfrom
42347-go-subtests
Nov 14, 2025
Merged

languages: Fix command used for Go subtests#42734
dinocosta merged 1 commit intomainfrom
42347-go-subtests

Conversation

@dinocosta
Copy link
Member

The command used to run go subtests was breaking if the test contained square brackets, for example:

go test . -v -run ^TestInventoryCheckout$/^\[test\]_test_checkout$

After a bit of testing it appears that the best way to actually resolve this in a way supported by go test is to wrap this command in quotes. As such, this commit updates the command to, considering the example above:

go test . -v -run '^TestInventoryCheckout$/^\[test\]_test_checkout$'

We also tested escape the square brackets, using \\\[ instead of \[, but that would lead to a more complex change, so we opted for the simpler solution of wrapping the command in quotes.

Closes #42347

Release Notes:

  • Fixed command used to run Go subtests to ensure that escaped characters don't lead to a failure in finding tests to run

The command used to run go subtests was breaking if the test contained
square brackets, for example:

```
go test . -v -run ^TestInventoryCheckout$/^\[test\]_test_checkout$
```

After a bit of testing it appears that the best way to actually resolve
this in a way supported by `go test` is to wrap this command in quotes.
As such, this commit updates the command to, considering the example
above:

```
go test . -v -run '^TestInventoryCheckout$/^\[test\]_test_checkout$'
```

We also tested escape the square brackets, using `\\\[` instead of `\[`,
but that would lead to a more complex change, so we opted for the
simpler solution of wrapping the command in quotes.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Nov 14, 2025
@dinocosta dinocosta self-assigned this Nov 14, 2025
@dinocosta dinocosta marked this pull request as ready for review November 14, 2025 15:39
@dinocosta dinocosta merged commit aaa116d into main Nov 14, 2025
24 checks passed
@dinocosta dinocosta deleted the 42347-go-subtests branch November 14, 2025 16:04
11happy pushed a commit to 11happy/zed that referenced this pull request Dec 1, 2025
The command used to run go subtests was breaking if the test contained
square brackets, for example:

```
go test . -v -run ^TestInventoryCheckout$/^\[test\]_test_checkout$
```

After a bit of testing it appears that the best way to actually resolve
this in a way supported by `go test` is to wrap this command in quotes.
As such, this commit updates the command to, considering the example
above:

```
go test . -v -run '^TestInventoryCheckout$/^\[test\]_test_checkout$'
```

We also tested escape the square brackets, using `\\\[` instead of `\[`,
but that would lead to a more complex change, so we opted for the
simpler solution of wrapping the command in quotes.

Closes zed-industries#42347 

Release Notes:

- Fixed command used to run Go subtests to ensure that escaped
characters don't lead to a failure in finding tests to run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

go: cannot run subtests that has bracket or parentheses in name

1 participant