bazelbuild / bazelbuild/bazel

Data dependencies make reference to workspace

Open
#22,162 7 comments 0 reactions 2 assignees Claimed by @Wyverald View on GitHub
P2 team-Documentation team-ExternalDeps type: documentation (cleanup)
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Page link:

https://bazel.build/concepts/dependencies#data-dependencies

### Problem description (include actual vs expected text, if applicable):

The page in the link reads

> These files are available using the relative path `path/to/data/file`. In tests, you can refer to these files by joining the paths of the test's source directory and the workspace-relative path, for example, `${TEST_SRCDIR}/workspace/path/to/data/file`

The reference to `workspace` in this link would make you believe that you can make a reference to any workspace, including the workspace for any dependency.

Eg. Say you have a dependency `foo`. This dependency has a `BUILD` file at the root that reads
```
filegroup(
name = "bar",
srcs = glob(["man/**/*.txt"]),
)
```
Say that `@foo//:bar` contains 1000s of files.

Then you have a `cc_test` that you would like to use the files from `@foo//:bar`.
```
cc_test(
name = "some_test",
srcs = ["some_test.cpp"],
data = ["@foo//:bar"],
)
```

then following the doc, I would expect for `${TEST_SRCDIR}/foo/man` to be reference to the man directory in `@foo//:bar` (for completeness, say that the workspace name of `@foo` is `"foo"`).

This is not the case (and my understanding is that this is not the expected behaviour).

### Where do you see this issue? (include link to specific section of the page, if applicable)

_No response_

### Any other information you'd like to share?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.