Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sub-tests): supports subtests with an identifier #82

Merged

Conversation

florentcigolotti
Copy link
Contributor

@florentcigolotti florentcigolotti commented Apr 26, 2024

The :lua require('dap-go').debug_test() function is not working for all sub tests. That is because right now, the TreeSitter subtests_query is written with just a func_literal in the arguments's call_expression.
It is often the case to use it with a literal, see example below:

package test

import (
	"testing"
)

func TestWithSubTests(t *testing.T) {
	t.Run("subtest with function literal (is already working)", func(t *testing.T) {})
	myFunc := func(t *testing.T) {}
	t.Run("subtest with identifier", myFunc)
}

Previously, running :lua require('dap-go').debug_test() with the cursor on the line with t.Run("subtest with identifier", myFunc) was running the parent test TestWithSubTests which is running all subtests.
WIth this pull request, now running the debug_test() is going to run the test subtest with identifier only.

Copy link
Owner

@leoluz leoluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this improvement. I'll give this a local test and merge if it works as expected.

@leoluz leoluz merged commit 51f8dae into leoluz:main Apr 29, 2024
2 checks passed
@florentcigolotti
Copy link
Contributor Author

Would first say thank you for cooking this plugin 👍 Works great and I am very happy to share back to the community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants