Bazel:如何在测试前运行py_binary以生成输入文件
Bazel: How to run py_binary to produce input files before testing
我有一个这样的py_binary
规则:
py_binary(
name = "testInputs",
srcs = ["testInputs.py"],
)
还有这样的cc_test
:
cc_test(
name = "test",
src = ["test.cc"],
data = [":testInputs"],
)
test.cc 旁边需要一个由testInputs.py
生成的输入文件(比如input.txt
(。 我希望testInputs
运行并向test
提供输入文件。
正如这里提到的,我试图依赖data
部分中的testInputs
。但测试在附近找不到输入文件。tree bazel-out | grep -F input.txt
的结果表明,即使testInput
规则也根本没有运行 - 因为input.txt
文件根本不存在。
cc_test
上的data = [":testInputs"]
将使py_binary
本身可供cc_test
使用,而不是py_binary
运行时可能产生的任何东西。
你会想要这样的东西:
cc_test(
name = "test",
src = ["test.cc"],
data = [":test_input.txt"],
)
genrule(
name = "gen_test_inputs",
tools = [":test_input_generator"],
outs = ["test_input.txt"],
cmd = "$(location :test_input_generator) $@"
)
py_binary(
name = "test_input_generator",
srcs = ["test_input_generator.py"],
)
相关文章:
- .cpp和.h文件中的模板专用化声明
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 文本文件中的单词链表
- CMake-按正确顺序将项目与C运行时对象文件链接
- 使用新行和不使用新行读取文件
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 挂起和取消挂起一个文件DLL
- 如何确定我已使用非编码文件到达 EOF?
- 命名空间中具有.h和.cpp文件的类
- 如何使用ndk-build.cmd构建Android.so文件
- 从包含m行的文件中提取n行,必要时(惰性地)重复该文件
- 读取文件并输入到矢量中
- 在C++中查找文件
- c++库的公共头文件中应该包含什么
- 如何使用curl c ++源代码发布wav文件数据,如何使用c ++使用--data-binary?
- 我必须在 [ios::binary] 模式下打开文件才能获得其大小
- 使用 ReadFile WinAPI 读取'Binary'文件
- 为什么我打开一个没有std::ios::binary的文件(std::ifstream)
- 如何同时将 ASCII 和 BINARY 数据写入同一个文件
- 是否建议始终使用'binary'模式打开文件?