brpc
brpc copied to clipboard
build(test): generate per-file brpc cc_test to improve Bazel UT coverage
What problem does this PR solve?
Part: #2904
Problem Summary:
- BUILD.bazel 只编译了极少数 brpc 单元测试;
- 直接 glob(["brpc_*_unittest.cpp"]) 会把多个含 int main() 的源文件链接进同一可执行文件,引发 duplicate symbol: main,导致其余测试无法构建。
- CMake 已覆盖全部 UT。为了让两套构建结果一致,需要在 Bazel 侧同样编译(并可执行)全部 brpc 单测文件。
- 其中
test/brpc_http_rpc_protocol_unittest.cpp的修改是为了兼容bazel指定的 更高的proto版本 https://github.com/apache/brpc/issues/2904#issuecomment-2935095655
What is changed and the side effects?
Changed:
| 位置 | 变更 | 说明 |
|---|---|---|
| test/brpc_unit_test.bzl | 新增 | 提供 generate_brpc_unit_tests() 宏:- 输入 任意 .cpp 列表 → 输出 “一文件一 cc_test” + 聚合 test_suite。 |
| test/BUILD.bazel | 新增brpc_test UT 部分 | 一次宏调用即可把 全部 brpc_*_unittest.cpp 生成 多个 cc_test;逻辑与 test/CMakeLists.txt的 https://github.com/apache/brpc/blob/c24e641009fa0305f0efebce694d0dad886c85ca/test/CMakeLists.txt#L253 一致 |
Side effects:
-
Performance effects:无
-
Breaking backward compatibility: 无
Check List:
- Please make sure your changes are compilable.
- When providing us with a new feature, it is best to add related tests.
- Please follow Contributor Covenant Code of Conduct.
Is it possible to use bazel tests with github workflows?
Sure, i"ll work on workflow
This code looks no problem, but I don't know why the ci-linux workflow is not runned…