bazel-contrib / bazel-contrib/rules_go
go_test: could not use x_defs to stamp rlocationpath of another binary in data
- 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.44.2
### What version of gazelle are you using?
0.35.0
### What version of Bazel are you using?
7.0.2
### Does this issue reproduce with the latest releases of all the above?
yes
### What operating system and processor architecture are you using?
MacOS ARM64
### Any other potentially useful information about your toolchain?
Irrelevant
### What did you do?
Here is a minimal reproduce
https://github.com/sluongng/rules-go-test-xdefs-issue/blob/9360ec82c4f307d0e986f36580b2b90cb6760f1c/BUILD#L10-L12
### What did you expect to see?
The x_defs should detect the runfile locations of the target and add it to the Go variable
### What did you see instead?
```
ERROR: /Users/sluongng/work/misc/test-go/BUILD:6:8: in go_test rule //:a_test: label '//liba:liba' in $(location) expression is not a declared prerequisite of this rule
ERROR: /Users/sluongng/work/misc/test-go/BUILD:6:8: Analysis of target '//:a_test' failed
```
Contributor guide
Research direction
Start with the minimal reproduction linked in the issue, especially the BUILD file at lines 10–12, and reproduce the go_test analysis error with x_defs and the binary in data. Trace how go_test handles $(location) and runfile locations for x_defs; done means the target’s rlocationpath can be stamped without the declared-prerequisite error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100