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

go: testing submodule support for runnables #12323

Closed
1 task done
anilsenay opened this issue May 26, 2024 · 2 comments
Closed
1 task done

go: testing submodule support for runnables #12323

anilsenay opened this issue May 26, 2024 · 2 comments
Labels
bug [core label] go Go programming language support language An umbrella label for all programming languages syntax behaviors tasks

Comments

@anilsenay
Copy link
Contributor

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

As we discussed in PR #12003, the way we did to run tests is not working for submodules. Because we use parent directory of test file in go test command as pattern like go test {parentDir} -run {testName}. It works for tests in current module but it won't if running a test in a different module.

for example we opened a project in Zed like this:

.
├── submodule/
│   ├── submodule.go
│   ├── submodule_test.go
│   └── go.mod
├── main.go
├── main_test.go
└── go.mod

go test . -run TestXxx will work but go test ./submodule -run TestXxx will not.
It gives error as main module (my-project) does not contain package my-project/submodule

There are some potential fixes for this:

  1. Most easily, using file path instead of relative path of parent directory in go test command: go test ./submodule/submodule_test.go -run TestXxx.

  2. Detect module directory of test file (./submodule for submodule_test.go) and setting cwd variable of TaskTemplate as this directory. So cwd = ./submodule and test command will be go test . -run TestXxx

  3. Similar to 2, cwd will be set as module directory but we will use package tree instead of file system tree. Which I mean, when we detect the module of file, we should also get module name in go.mod like github.com/xx/some-package, then the test command should be go test github.com/xx/some-package/submodule -run TestXxx.
    I think vscode-go extension doing something similar to this:
    Running tool: /usr/local/go/bin/go test -timeout 300s -run ^TestSomething$ github.com/anilsenay/zed-go-test/slice
    The reason I came with this is that it could be useful for features which require package tree like this in the future:
    resim

Environment

Zed: v0.138.0 (Zed Dev ddb551c)
OS: macOS 14.5.0
Memory: 16 GiB
Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

@anilsenay anilsenay added admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue labels May 26, 2024
@Moshyfawn Moshyfawn added language An umbrella label for all programming languages syntax behaviors go Go programming language support tasks and removed triage Maintainer needs to classify the issue labels May 27, 2024
@JosephTLyons JosephTLyons removed the admin read Pending admin review label May 28, 2024
@github-actions github-actions bot added admin read Pending admin review triage Maintainer needs to classify the issue labels Nov 5, 2024
@notpeter notpeter added the needs info / awaiting response Issue that needs more information from the user label Nov 5, 2024
@notpeter
Copy link
Member

notpeter commented Nov 5, 2024

Hi @anilsenay, can you check if this is still an issue with recent versions of Zed? There has been work to improve how we detect runnables and build tasks and I wanted to see if this issue stands or if any of the details have changed in the intervening six months. Thanks

@notpeter notpeter removed triage Maintainer needs to classify the issue admin read Pending admin review labels Nov 5, 2024
@anilsenay
Copy link
Contributor Author

anilsenay commented Nov 6, 2024

It is fixed 🚀

I tested for an old Zed(0.138.0) and latest(0.160.7) and results are:

resim

As you see, tests in a submodule did not work in old version(on the left) but they did in latest (on the right)

@notpeter notpeter removed the needs info / awaiting response Issue that needs more information from the user label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] go Go programming language support language An umbrella label for all programming languages syntax behaviors tasks
Projects
None yet
Development

No branches or pull requests

4 participants