From 5eab209a5335157986270358ecb39beaf30bdcb3 Mon Sep 17 00:00:00 2001 From: Kegsay Date: Thu, 15 Mar 2018 03:20:13 +0000 Subject: [PATCH] bugfix: Ensure 'debug test' codelens only tests the selected test. (#1561) If you have two functions `TestFoo` and `TestFooTwo`, and select 'debug test' on `TestFoo`, both tests will be executed. This happens because `go test -test.run` expects a regular expression, but we were only passing it a function name. Fixed by wrapping the function name in start/end markers. --- src/goRunTestCodelens.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/goRunTestCodelens.ts b/src/goRunTestCodelens.ts index 664efcbfd..94e1f762f 100644 --- a/src/goRunTestCodelens.ts +++ b/src/goRunTestCodelens.ts @@ -82,7 +82,7 @@ export class GoRunTestCodeLensProvider extends GoBaseCodeLensProvider { arguments: [{ functionName: func.name }] }; - const args = ['-test.run', func.name]; + const args = ['-test.run', '^' + func.name + '$']; const program = path.dirname(document.fileName); const env = Object.assign({}, this.debugConfig.env, vsConfig['testEnvVars']); const envFile = vsConfig['testEnvFile'];