bazel-contrib / bazel-contrib/rules_go
Information Requested regarding extraction of golang test binaries leveraging rules_go.
- Dominant language
- Go
- Stars
- 1.5k
- Forks
- 760
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 12
Description
### What version of rules_go are you using?
0.25.1
### What version of gazelle are you using?
0.22.3
### What version of Bazel are you using?
4.0.0
### Does this issue reproduce with the latest releases of all the above?
N/A
### What operating system and processor architecture are you using?
linux amd64
### Any other potentially useful information about your toolchain?
N/A
### What did you do?
Trying to build test binaries built for coverage Linux.
go test -covermode=atomic -coverpkg=‘myorg.net/projectmonorepo/project/...' -c -tags taglistitem1,taglistitem2 -o testbinaryname.
Writing code along the lines of:
main_test.go
===================================
// +build taglistitem1
// +build taglistitem2
package main
import (
"fmt"
"testing"
)
func TestRunMain(t *testing.T) {
fmt.Println("Test Invoked..... ####")
main() //main being a really long running process.
}
in a very similar fashion to
I plan to pass taglist and coverpkg params as args in following fashion:
go_binary(
name=“golangtestmainbinary”
options=[“-c”],
out= “testbinaryname”,
coverpkg=“myorg.net/projectmonorepo/project/...”,
taglist=[“taglistitem1”,”taglistitem2”],
)
* the above is a symbolic rep of what I am trying to achieve,I am currently executing a shell script of above and copying the binary to bazel-out folder.
### What did you expect to see?
N/A
### What did you see instead?
N/A
### Comments
It feels like there should be a way to do this using go_test in order to provide the tags and export the test binary out , but I'm not familiar enough with the internals of rules_go to know what that would look like. Can someone recommend a solution which allows me to extract the test binary out using rules_go?
Contributor guide
Research direction
Start by reading the rules_go go_test and go_binary entry points in the context of the requested -c, coverpkg, and build-tag behavior. Confirm whether the rules expose a supported way to produce and extract a coverage test binary; done means a reproducible Bazel target replaces the shell script and copying step.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- build-system, testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100