【发布时间】:2021-01-24 21:55:42
【问题描述】:
我对 Bazel 和 Gtest 非常陌生,并且一直在尝试在名为“species_test”.cpp 的 cpp 文件上运行测试。这是我不断收到的主要错误:
Wills-iMac:species Will$ bazel test species_test --test_output=all
ERROR: Skipping 'species_test': no such target '//species:species_test': target 'species_test' not declared in package 'species' defined by /Users/Will/git/orville-regularwills/species/BUILD.bazel
ERROR: no such target '//species:species_test': target 'species_test' not declared in package 'species' defined by /Users/Will/git/orville-regularwills/species/BUILD.bazel
INFO: Elapsed time: 0.473s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)
我有两个 BUILD.bazel 文件: 这个是用于 .cpp 类实现的:
cc_library(
name="species",
srcs=glob(["*.cpp"]),
hdrs=glob(["*.h"]),
visibility=["//visibility:public"]
)
这是一个用于谷歌测试的文件,该文件具有species_test.cpp:
cc_test(
name="species_test",
srcs=["species_test.cpp"],
copts=["-Iexternal/gtest/include"],
deps=[
"@gtest//::main",
"//species"
]
)
这是我的工作区文件:
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
name = "gtest",
remote = "https://github.com/google/googletest",
branch = "v1.10.x",
)
我不知道错误指的是什么,非常感谢任何指出我正确方向或清除任何东西的东西。
【问题讨论】:
-
您好,您的存储库的结构是什么?我猜您的两个 BUILD 文件位于两个不同的目录中,因此对应于不同的包。那么,你尝试过
bazel test //<test_directory>:species_test --test_output=all
标签: c++ visual-studio-code googletest bazel