go: Fix regression by restoring regex to match tests (#17645)

This fixes a regression that snuck in with #17108.

When running a single test with `go test` the
regex wouldn't be used anymore.

This restores the old behavior.

Release Notes:

- Fixed a regression when running Go tests. A recent change dropped the
regex used to match single test names when using `go test` in tasks to
run tests. That could lead to more or the wrong tests being run. This
restores the old behavior.
This commit is contained in:
Thorsten Ball 2024-09-10 10:22:12 -04:00 committed by GitHub
parent 929eff815c
commit bf64c0899f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -518,7 +518,13 @@ impl ContextProvider for GoContextProvider {
GO_PACKAGE_TASK_VARIABLE.template_value(),
VariableName::Symbol.template_value(),
),
command: format!("go test -run {}", VariableName::Symbol.template_value(),),
command: "go".into(),
args: vec![
"test".into(),
GO_PACKAGE_TASK_VARIABLE.template_value(),
"-run".into(),
format!("^{}\\$", VariableName::Symbol.template_value(),),
],
tags: vec!["go-test".to_owned()],
cwd: package_cwd.clone(),
..TaskTemplate::default()