GTest root directory is inconsistent
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Page link:
https://bazel.build/rules/lib/builtins/runfiles
### Problem description (include actual vs expected text, if applicable):
If I have a directory with this structure
```
opencv_hello
testdata
starrry_night.jpg
```
then in gtest I can get the file with this
```
Mat mat1 =
cv::imread(runfiles->Rlocation("opencv_hello/testdata/starry_night.jpg");
```
Given the fact that I add "//testdata" into "data" in BUILD
However, if I had a testdata one level below root:
```
testdata
starrry_night.jpg
```
Then I need to have "_main":
```
Mat mat1 =
cv::imread(runfiles->Rlocation("_main/testdata/starry_night.jpg");
```
This seems inconsistent. In one case I need an upper level of directory or "_main"
### Where do you see this issue? (include link to specific section of the page, if applicable)
Every time I have directory that is directly below the root as I mentioned earlier.
### Any other information you'd like to share?
Maybe it needs an update in documentation since I don't remember seeing "_main". Ideally it would be nice to just have "testdata/file.jpg" rather than "_main" or whatever is above that.
Contributor guide
Research direction
Start with the runfiles documentation at https://bazel.build/rules/lib/builtins/runfiles and reproduce both directory layouts using the BUILD data entry and the shown GTest/C++ lookup. Compare the documented path rules with the observed need for _main, then update the page to explain the root-directory behavior and the expected testdata path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system, testing
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100