-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gtest_main not linked correctly without srcs #20
Comments
This should be fixable by adding
|
Thanks. Adding |
This boils down to you own customization problem. I think you can rollout your own version of test main and it should be quiet simple: int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
EXPECT_GT(::testing::UnitTest::GetInstance()->total_test_suite_count(), 0);
return RUN_ALL_TESTS();
} |
It can work. But I think the point gtest_main target exists is not to have the same main function in every test file. although not a huge deal to have them. In the mean time, cmake links gtest_main fine with .cu file in one of my project that I maintain both bazel and cmake build. So a little less motivation to do so. |
I mean, there is nothing prevent you from add a add_library(a_cu_lib STATIC CU_FILES)
add_executable(dummy_test_cu a_cu_lib gtest_main) The problems here is the I'd prefer the following macro, and you should not present a def cuda_test(name, srcs, deps, *args, *kwargs):
cuda_library(name = name + "_cu", srcs = srcs, alwayslink=True)
cc_test(name = name, deps = [name + "_cu"] + deps) |
with exact same content, one in cu file, one in cpp file
BUILD file
If I run
bazel test --test_output=all //:dummy_test
1 test will run.
But if I run
bazel test --config=cuda --test_output=all //:dummy_test_cu
Everything will build and run "successfully". except no test is actually run
I do need to define test as cu file because there will be CUDA code in it. Technically they can be wrapped in another lib and test file only contains pure c++ code, but that's extra work. Besides, a silent success without tests being actually run is dangerous. It can be easily missed in a bigger project.
Maybe explicitly support
cuda_test
andcuda_binary
?The text was updated successfully, but these errors were encountered: