bazel cc_test test_env 选项

bazel cc_test test_env options

当我使用 cc_test 时:

cc_test(
    name = "xxx_test",
    srcs = glob([
        'xxx.cpp',
    ]),
    linkopts = [
        "-L/usr/local/lib",
        "-lcppunit",
        "-ldl",
        "-lz",
        "-ltbb",
        "-llz4",
        "-lzstd"
    ],
    deps = [
        ":feature_generator"
    ],
)

我需要 运行 这个命令:

./bazel test @xxx//xxx:xxx_test --test_output=errors --test_env=LD_LIBRARY_PATH=/usr/local/lib

怎么能省略呢"--test_env=LD_LIBRARY_PATH=/usr/local/lib".

cc_test 有 env_path 选项吗?

我想这样做

cc_test( 
*** 
*** 
test_env = ['/usr/local/lib'] 
) 

我可以在这个cmd中测试:./bazel test @xxx//xxx:xxx_test --test_output=errors我不想写"--test_env=LD_LIBRARY_PATH=/usr/local/lib"当我想测试

现在如果我 运行 这个 cmd:./bazel test @xxx//xxx:xxx_test --test_output=errors 会得到这个错误:

/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

因此您可以将标志添加到您的 ~/.bazelrc file,例如:

test --test_env=LD_LIBRARY_PATH=/usr/local/lib

但是,测试操作找不到 LD_LIBRARY_PATH 而构建操作对我来说听起来像是一个错误,您应该在 https://github.com/bazelbuild/bazel/issues/new

上提出问题