[Bug]: `absl/time` tests fail in Bazel when Abseil is an external dep
Describe the issue
If you include Abseil as a dependency in your Bazel WORKSPACE and attempt to run its tests, you will get failures in the following:
@com_google_absl//absl/time:time_test
@com_google_absl//absl/time/internal/cctz:time_zone_format_test
@com_google_absl//absl/time/internal/cctz:time_zone_lookup_test
The root cause is that the build targets for these tests specify,
env = {"TZDIR": "absl/time/internal/cctz/testdata/zoneinfo"}
E.g., see here for time_test. If I remove this line from the BUILD file, the test passes. The problem seems to be that absl/time/internal/cctz/testdata/zoneinfo is a relative path, and only correct if it's interpreted as relative to the abseil repository root.
See also discussion at https://github.com/bazelembedded/rules_cc_toolchain/pull/45#issuecomment-1413028774 and following.
Steps to reproduce the problem
See description.
What version of Abseil are you using?
Abseil LTS 20230125
What operating system and version are you using?
Debian GNU/Linux rodete
What compiler and version are you using?
Debian clang version 14.0.6 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10 Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11 Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12 Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12 Candidate multilib: .;@m64 Candidate multilib: 32;@m32 Candidate multilib: x32;@mx32 Selected multilib: .;@m64
What build system are you using?
bazel 6.0.0
Additional context
No response
A suggested fix (from https://github.com/bazelembedded/rules_cc_toolchain/pull/45#issuecomment-1414169360) was to set,
env = {"TZDIR": "$(rootpath //absl/time/internal/cctz:zoneinfo)"},
But this doesn't quite work because the filegroup includes many files, and we want the directory containing them all:
ERROR: [snip]/external/com_google_absl/absl/time/BUILD.bazel:74:8: in cc_test rule @com_google_absl//absl/time:time_test: label '@com_google_absl//absl/time/internal/cctz:zoneinfo' in $(location) expression expands to more than one file, please use $(locations @com_google_absl//absl/time/internal/cctz:zoneinfo) instead. Files (at most 5 shown) are: [external/com_google_absl/absl/time/internal/cctz/testdata/zoneinfo/Africa/Abidjan, external/com_google_absl/absl/time/internal/cctz/testdata/zoneinfo/Africa/Accra, external/com_google_absl/absl/time/internal/cctz/testdata/zoneinfo/Africa/Addis_Ababa, external/com_google_absl/absl/time/internal/cctz/testdata/zoneinfo/Africa/Algiers, external/com_google_absl/absl/time/internal/cctz/testdata/zoneinfo/Africa/Asmara