[vscode-go] extension/src: change sub test input paramter from slice type to type

4 views
Skip to first unread message

Hongxiang Jiang (Gerrit)

unread,
Nov 5, 2025, 2:58:38 PM (6 days ago) Nov 5
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Hongxiang Jiang has uploaded the change for review

Commit message

extension/src: change sub test input paramter from slice type to type

The vscode.executeCommand api accepts a slice of any as input
parameters. But vscode will flatten the slice into individual
arguments before actually calling the receiver.

E.g. a command with arg ["foo", 0, true] should have a corresponding
command signature of func(string, number, boolean).

Fix golang/vscode-go#3908
Change-Id: I0320cb52652e96bb7804ccfac66ddecc09593e3f

Change diff

diff --git a/CHANGELOG.md b/CHANGELOG.md
index ae37c81..3eb4108 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -75,6 +75,9 @@
* Resolved a problem where `staticcheck` was being installed automatically even
when it was not in use (golang/vscode-go#3898).

+* Fix issue where sub test codelens runs sub test based on the cursor instead of
+the codelen's position (golang/vscode-go#3908).
+
## v0.51.1 (prerelease)

Date: 2025-10-27
diff --git a/extension/src/goTest.ts b/extension/src/goTest.ts
index 22c972e..4d65db4 100644
--- a/extension/src/goTest.ts
+++ b/extension/src/goTest.ts
@@ -181,7 +181,7 @@
* @param args
*/
export function testAtCursor(cmd: TestAtCursorCmd): CommandFactory {
- return (ctx, goCtx) => (args: any) => {
+ return (_, goCtx) => (args: any) => {
const goConfig = getGoConfig();
return _testAtCursor(goCtx, goConfig, cmd, args).catch((err) => {
if (err instanceof NotFoundError) {
@@ -261,7 +261,10 @@
}

/**
- * Executes the sub unit test at the primary cursor.
+ * Executes the sub unit.
+ *
+ * If the `args` is provided, run the subtest based on the test info provided in
+ * the args. Otherwise, infer the test info from the cursor.
*
* @param cmd Whether the command is test or debug.
*/
@@ -273,10 +276,10 @@
* codelens provided by {@link GoRunTestCodeLensProvider}, args
* specifies the function and subtest names.
*/
- args?: [SubTestAtCursorArgs]
+ args?: SubTestAtCursorArgs
) => {
try {
- return await _subTestAtCursor(goCtx, getGoConfig(), cmd, args?.[0]);
+ return await _subTestAtCursor(goCtx, getGoConfig(), cmd, args);
} catch (err) {
if (err instanceof NotFoundError) {
vscode.window.showInformationMessage(err.message);

Change information

Files:
  • M CHANGELOG.md
  • M extension/src/goTest.ts
Change size: S
Delta: 2 files changed, 10 insertions(+), 4 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: I0320cb52652e96bb7804ccfac66ddecc09593e3f
Gerrit-Change-Number: 718200
Gerrit-PatchSet: 1
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
unsatisfied_requirement
satisfied_requirement
open
diffy

Hongxiang Jiang (Gerrit)

unread,
Nov 5, 2025, 2:59:58 PM (6 days ago) Nov 5
to goph...@pubsubhelper.golang.org, Ethan Reesor, Madeline Kalil, golang-co...@googlegroups.com
Attention needed from Ethan Reesor and Madeline Kalil

Hongxiang Jiang voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Ethan Reesor
  • Madeline Kalil
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: I0320cb52652e96bb7804ccfac66ddecc09593e3f
Gerrit-Change-Number: 718200
Gerrit-PatchSet: 1
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Ethan Reesor <ethan....@gmail.com>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
Gerrit-Attention: Madeline Kalil <mka...@google.com>
Gerrit-Attention: Ethan Reesor <ethan....@gmail.com>
Gerrit-Comment-Date: Wed, 05 Nov 2025 19:59:55 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Hongxiang Jiang (Gerrit)

unread,
Nov 5, 2025, 3:01:26 PM (6 days ago) Nov 5
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Ethan Reesor and Madeline Kalil

Hongxiang Jiang uploaded new patchset

Hongxiang Jiang uploaded patch set #2 to this change.
Open in Gerrit

Related details

Attention is currently required from:
  • Ethan Reesor
  • Madeline Kalil
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: I0320cb52652e96bb7804ccfac66ddecc09593e3f
Gerrit-Change-Number: 718200
Gerrit-PatchSet: 2
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Ethan Reesor <ethan....@gmail.com>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Madeline Kalil (Gerrit)

unread,
Nov 5, 2025, 3:59:43 PM (6 days ago) Nov 5
to Hongxiang Jiang, goph...@pubsubhelper.golang.org, Go LUCI, Ethan Reesor, golang-co...@googlegroups.com
Attention needed from Ethan Reesor and Hongxiang Jiang

Madeline Kalil voted and added 2 comments

Votes added by Madeline Kalil

Code-Review+2

2 comments

File CHANGELOG.md
Line 79, Patchset 2 (Latest):the codelen's position (golang/vscode-go#3908).
Madeline Kalil . unresolved

nit: delete whitespace
"instead of the codelens' position"

File extension/src/goTest.ts
Line 264, Patchset 2 (Latest): * Executes the sub unit.
Madeline Kalil . unresolved

sub unit test?

Open in Gerrit

Related details

Attention is currently required from:
  • Ethan Reesor
  • Hongxiang Jiang
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: I0320cb52652e96bb7804ccfac66ddecc09593e3f
Gerrit-Change-Number: 718200
Gerrit-PatchSet: 2
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Ethan Reesor <ethan....@gmail.com>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
Gerrit-Attention: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Attention: Ethan Reesor <ethan....@gmail.com>
Gerrit-Comment-Date: Wed, 05 Nov 2025 20:59:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Ethan Reesor (Gerrit)

unread,
Nov 5, 2025, 9:37:49 PM (5 days ago) Nov 5
to Hongxiang Jiang, goph...@pubsubhelper.golang.org, Madeline Kalil, Go LUCI, golang-co...@googlegroups.com
Attention needed from Hongxiang Jiang

Ethan Reesor added 2 comments

Commit Message
Line 7, Patchset 2 (Latest):extension/src: change sub test input paramter from slice type to type
Ethan Reesor . unresolved

```suggestion
extension/src: change sub test input parameter from slice type to type
```

File extension/src/goTest.ts
Line 282, Patchset 2 (Latest): return await _subTestAtCursor(goCtx, getGoConfig(), cmd, args);
Ethan Reesor . unresolved

I made this change specifically to fix a bug (CL 657395, golang/vscode-go#3718). I tested it then so I guess something changed? I just launched the debugger and `args` is in fact an object not an array. And the code lens code hasn't changed in 3 years. I guess vscode changed...

Open in Gerrit

Related details

Attention is currently required from:
  • Hongxiang Jiang
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: I0320cb52652e96bb7804ccfac66ddecc09593e3f
Gerrit-Change-Number: 718200
Gerrit-PatchSet: 2
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Ethan Reesor <ethan....@gmail.com>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
Gerrit-Attention: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Comment-Date: Thu, 06 Nov 2025 02:37:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Hongxiang Jiang (Gerrit)

unread,
Nov 6, 2025, 1:53:53 PM (5 days ago) Nov 6
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Hongxiang Jiang

Hongxiang Jiang uploaded new patchset

Hongxiang Jiang uploaded patch set #3 to this change.
Open in Gerrit

Related details

Attention is currently required from:
  • Hongxiang Jiang
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement satisfiedReview-Enforcement
  • requirement satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: I0320cb52652e96bb7804ccfac66ddecc09593e3f
Gerrit-Change-Number: 718200
Gerrit-PatchSet: 3
satisfied_requirement
unsatisfied_requirement
open
diffy

Hongxiang Jiang (Gerrit)

unread,
Nov 6, 2025, 1:59:56 PM (5 days ago) Nov 6
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Hongxiang Jiang

Hongxiang Jiang uploaded new patchset

Hongxiang Jiang uploaded patch set #4 to this change.
Following approvals got outdated and were removed:
  • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit

Related details

Attention is currently required from:
  • Hongxiang Jiang
Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: vscode-go
    Gerrit-Branch: master
    Gerrit-Change-Id: I0320cb52652e96bb7804ccfac66ddecc09593e3f
    Gerrit-Change-Number: 718200
    Gerrit-PatchSet: 4
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Hongxiang Jiang (Gerrit)

    unread,
    Nov 6, 2025, 2:00:45 PM (5 days ago) Nov 6
    to goph...@pubsubhelper.golang.org, Madeline Kalil, Go LUCI, Ethan Reesor, golang-co...@googlegroups.com
    Attention needed from Ethan Reesor

    Hongxiang Jiang voted and added 4 comments

    Votes added by Hongxiang Jiang

    Auto-Submit+1
    Commit-Queue+1

    4 comments

    Commit Message
    Line 7, Patchset 2:extension/src: change sub test input paramter from slice type to type
    Ethan Reesor . resolved

    ```suggestion
    extension/src: change sub test input parameter from slice type to type
    ```

    Hongxiang Jiang

    Done

    File CHANGELOG.md
    Line 79, Patchset 2:the codelen's position (golang/vscode-go#3908).
    Madeline Kalil . resolved

    nit: delete whitespace
    "instead of the codelens' position"

    Hongxiang Jiang

    Done

    File extension/src/goTest.ts
    Line 264, Patchset 2: * Executes the sub unit.
    Madeline Kalil . resolved

    sub unit test?

    Hongxiang Jiang

    Done

    Line 282, Patchset 2: return await _subTestAtCursor(goCtx, getGoConfig(), cmd, args);
    Ethan Reesor . resolved

    I made this change specifically to fix a bug (CL 657395, golang/vscode-go#3718). I tested it then so I guess something changed? I just launched the debugger and `args` is in fact an object not an array. And the code lens code hasn't changed in 3 years. I guess vscode changed...

    Hongxiang Jiang

    I'm not sure whether VSCode have changed since. I did bump the vscode api a few times recently. It could be the api bump or vscode change or it was never working correctly.

    Lesson learned, vscode is calling our commands with flattened arguments.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Ethan Reesor
    Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: vscode-go
    Gerrit-Branch: master
    Gerrit-Change-Id: I0320cb52652e96bb7804ccfac66ddecc09593e3f
    Gerrit-Change-Number: 718200
    Gerrit-PatchSet: 4
    Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
    Gerrit-Reviewer: Ethan Reesor <ethan....@gmail.com>
    Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
    Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
    Gerrit-Attention: Ethan Reesor <ethan....@gmail.com>
    Gerrit-Comment-Date: Thu, 06 Nov 2025 19:00:40 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Madeline Kalil <mka...@google.com>
    Comment-In-Reply-To: Ethan Reesor <ethan....@gmail.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Gopher Robot (Gerrit)

    unread,
    Nov 6, 2025, 2:20:47 PM (5 days ago) Nov 6
    to Hongxiang Jiang, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Madeline Kalil, Ethan Reesor, golang-co...@googlegroups.com

    Gopher Robot submitted the change with unreviewed changes

    Unreviewed changes

    2 is the latest approved patch-set.
    The change was submitted with unreviewed changes in the following files:

    ```
    The name of the file: CHANGELOG.md
    Insertions: 2, Deletions: 2.

    @@ -15,7 +15,7 @@
    minimum Go version remains Go 1.23. A new notification will now be sent to help
    users running older versions upgrade to Go 1.23+.

    -### Changse
    +### Changes

    * **Tool Management Refactoring**: The extension now correctly uses the tools
    specified in the `"go.lintTool"` and `"go.formatTool"` settings.
    @@ -76,7 +76,7 @@

    when it was not in use (golang/vscode-go#3898).

     * Fix issue where sub test codelens runs sub test based on the cursor instead of
    -the codelen's position (golang/vscode-go#3908). 
    +the codelens' position (golang/vscode-go#3908).

    ## v0.51.1 (prerelease)

    ```
    ```
    The name of the file: extension/src/goTest.ts
    Insertions: 1, Deletions: 1.

    @@ -261,7 +261,7 @@
    }

    /**
    - * Executes the sub unit.
    + * Executes the sub unit test.
    *

    * If the `args` is provided, run the subtest based on the test info provided in
      * the args. Otherwise, infer the test info from the cursor.
    ```

    Change information

    Commit message:
    extension/src: change sub test input parameter from slice type to type

    The vscode.executeCommand api accepts a slice of any as input
    parameters. But vscode will expand the slice into individual

    arguments before actually calling the receiver.

    E.g. a command with arg ["foo", 0, true] of type []any should have a

    corresponding command signature of func(string, number, boolean).

    a command with arg ["foo"] of type []any should have a corresponding
    command signature of func(string).

    Fix golang/vscode-go#3908
    Change-Id: I0320cb52652e96bb7804ccfac66ddecc09593e3f
    Auto-Submit: Hongxiang Jiang <hxj...@golang.org>
    Reviewed-by: Madeline Kalil <mka...@google.com>
    Files:
    • M CHANGELOG.md
    • M extension/src/goTest.ts
    Change size: S
    Delta: 2 files changed, 11 insertions(+), 5 deletions(-)
    Branch: refs/heads/master
    Submit Requirements:
    • requirement satisfiedCode-Review: +2 by Madeline Kalil
    • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
    Open in Gerrit
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: merged
    Gerrit-Project: vscode-go
    Gerrit-Branch: master
    Gerrit-Change-Id: I0320cb52652e96bb7804ccfac66ddecc09593e3f
    Gerrit-Change-Number: 718200
    Gerrit-PatchSet: 5
    Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
    Gerrit-Reviewer: Ethan Reesor <ethan....@gmail.com>
    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
    open
    diffy
    satisfied_requirement
    Reply all
    Reply to author
    Forward
    0 new messages