go_unittest cannot depend on non go_library() target
See original GitHub issueI am trying to build a golang unittest that depends on a non go_library
target. I need the side effects of the target to run. I see the error:
BUILD FAILED: //:generated_asset (needed for //:main#compile,darwin_amd64) is not an instance of go_library!
Is this just a missing feature of the golang support in buck? Is there another way to create a manual dependency between a golang targets and something else that does not imply the golang target should link the targeted thing as if it were a go library?
Note, I have create a sample project demonstrating the issue: https://github.com/lloyd/buckissue
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Unable to test Go program that involves ... - GitHub
Within a Bazel workspace with dependencies managed by Gazelle, and a program that depends upon the google.golang.org/grpc Go module at version " ...
Read more >Go unit test not finding required file - Stack Overflow
The problem that I am having is that when I run the test the package of the test is the root directory which...
Read more >testing - Go Packages
When TestMain is called, flag.Parse has not been run. If TestMain depends on command-line flags, including those of the testing package, it should...
Read more >Building a Go project using Bazel - Tweag
The target's name is blockchain , and it builds a library from the Go sources listed. The import path tells us how another...
Read more >Outsmarting Go Dependencies in Testing Code
But tests in the sql package cannot depend on the server package because that creates a circular dependency. This problem is not specific...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It can but only for go_test. Buck will symlink the output to current directory while running buck test, for example:
so the asset can be referenced within current directory. However this is only during buck test execution, so if you try to run:
it won’t find the file.
Let’s say we add “resources” to go_binary then we could mimic the go_test behavior with:
which would change the working directory
Legit 😃