Reputation: 65
When I use a cc_test like:
cc_test(
name = "xxx_test",
srcs = glob([
'xxx.cpp',
]),
linkopts = [
"-L/usr/local/lib",
"-lcppunit",
"-ldl",
"-lz",
"-ltbb",
"-llz4",
"-lzstd"
],
deps = [
":feature_generator"
],
)
I need to run this cmd:
./bazel test @xxx//xxx:xxx_test --test_output=errors --test_env=LD_LIBRARY_PATH=/usr/local/lib
How can I omit it "--test_env=LD_LIBRARY_PATH=/usr/local/lib".
Does cc_test has env_path option?
I want to do like this
cc_test(
***
***
test_env = ['/usr/local/lib']
)
and I can test in this cmd:./bazel test @xxx//xxx:xxx_test --test_output=errors
I dont want to write "--test_env=LD_LIBRARY_PATH=/usr/local/lib"
when I want to test
now if I run this cmd:./bazel test @xxx//xxx:xxx_test --test_output=errors
will get this error:
/home/alex.sh/.cache/bazel/_bazel_alex.sh/c973fcd5ba7eef8db46b22b84af3a149/bazel-sandbox/3561058496653596424/execroot/__main__/bazel-out/local-fastbuild/bin/external/feature_generator/featur\
e_generator/gbdt_test.runfiles/__main__/external/feature_generator/feature_generator/gbdt_test: error while loading shared libraries: libzstd.so.1: cannot open shared object file: No such fi\
le or directory
Upvotes: 1
Views: 1836
Reputation: 2370
So you can add the flag to your ~/.bazelrc file, e.g.:
test --test_env=LD_LIBRARY_PATH=/usr/local/lib
However, the fact that test action cannot find LD_LIBRARY_PATH while build action can sounds like a bug to me, you should file an issue on https://github.com/bazelbuild/bazel/issues/new
Upvotes: 1