Skip to content

Conversation

@XueSongTap
Copy link
Contributor

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版本 基于Bazel编译的UT不完善 #2904 (comment)

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的
foreach(BRPC_UT ${BRPC_UNITTESTS})
一致

Side effects:

  • Performance effects:无

  • Breaking backward compatibility: 无


Check List:

Signed-off-by: yexiaochuan <tap91624@gmail.com>
… license header

Signed-off-by: yexiaochuan <tap91624@gmail.com>
Signed-off-by: yexiaochuan <tap91624@gmail.com>
@chenBright
Copy link
Contributor

Is it possible to use bazel tests with github workflows?

@XueSongTap
Copy link
Contributor Author

Sure, i"ll work on workflow

@wwbmmm
Copy link
Contributor

wwbmmm commented Aug 19, 2025

This code looks no problem, but I don't know why the ci-linux workflow is not runned…

- name: run bazel tests
run: bazel test --test_output=errors --verbose_failures -- //test/...

clang-bazel-unittest:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StackTraceTest.find_symbol seems to fail in clang14. It is recommended to use clang12 with sudo apt-get install -y clang-12 lldb-12 lld-12.

Copy link
Contributor

@chenBright chenBright Aug 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And --action_env=CC=clang-12.

Copy link
Contributor

@chenBright chenBright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build on Macos has been fixed in master. Please update and rebase master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants