Googletest never fails (where it should) with bazel test but works with cmake & clionWhat's the difference between gtest.lib and gtest_main.lib?Unit Test Output & Project Structure Advice — CMake + Google Test FrameworkNo tests found when using gtest with cmake/ctestCMake - eliminate obsolete 3rd-party library downloadgtest unexpected conversiongtest and MinGW linkageXcode doesn't compile with gtest framework, however sees itCan't build C/C++ program with gmock/gmock.h, too many errors are generatedUpgrading Mac Os, now Clion is not working ask to me configuration path is not correctCucumber-CPP: All steps undefined in exampleAfter Updating NDK Build is not generating
Leveraging cash for buying car
Difference between sizeof(struct name_of_struct) vs sizeof(name_of_struct)?
Does anyone recognize these rockets, and their location?
Someone who is granted access to information but not expected to read it
A Tale of Snake and Coffee
How to make a villain when your PCs are villains?
My parents claim they cannot pay for my college education; what are my options?
How many times to repeat an event with known probability before it has occurred a number of times
How to search for Android apps without ads?
How can I improve readability and length of a method with many if statements?
SQL Server has encountered occurences of I/O requests taking longer than 15 seconds
TiKZ won't graph 1/sqrt(x)
Why did the USA sell so many airplanes prior to WW2?
Can I give my friend the sour dough "throw away" as a starter to their sourdough starter?
Idiom for 'person who gets violent when drunk"
I sent an angry e-mail to my interviewers about a conflict at my home institution. Could this affect my application?
Why not make one big CPU core?
Threading data on TimeSeries
Basic power tool set for Home repair and simple projects
Can an open source licence be revoked if it violates employer's IP?
Co-worker is now managing my team. Does this mean that I'm being demoted?
Confusion about good reduction
Are soroban (Japanese abacus) classes worth doing?
When is the phrase "j'ai bon" used?
Googletest never fails (where it should) with bazel test but works with cmake & clion
What's the difference between gtest.lib and gtest_main.lib?Unit Test Output & Project Structure Advice — CMake + Google Test FrameworkNo tests found when using gtest with cmake/ctestCMake - eliminate obsolete 3rd-party library downloadgtest unexpected conversiongtest and MinGW linkageXcode doesn't compile with gtest framework, however sees itCan't build C/C++ program with gmock/gmock.h, too many errors are generatedUpgrading Mac Os, now Clion is not working ask to me configuration path is not correctCucumber-CPP: All steps undefined in exampleAfter Updating NDK Build is not generating
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am trying to use googletest with bazel and cmake.
The cmake and clion works perfect as for the test part, it fails where it should fail and passes where it should pass.
However, bazel test
will pass all the tests even they should not.
Bazel test not working
For example, I have the stupid_test.cc
file:
#include "gtest/gtest.h"
TEST(StupidTests, Stupid1)
EXPECT_EQ(100, 20);
EXPECT_TRUE(false);
which should fail always.
The bazel BUILD
file:
cc_test(
name = "stupid_test",
srcs = ["stupid_test.cc"],
deps = [
"//bazel_build/googletest:gtest",
],
)
where bazel_build/googletest
is exactly the same files downloaded from the googletest github.
Then I run bazel test :stupid_test
, the output is:
⇒ blaze test :stupid_test
DEBUG: /private/var/tmp/_bazel_myusername/741c62b201e51840aa320b156e05fd70/external/bazel_tools/tools/osx/xcode_configure.bzl:87:9: Invoking xcodebuild failed, developer dir: /Users/honghaoli/Downloads/Xcode.app/Contents/Developer ,return code 1, stderr: xcrun: error: invalid DEVELOPER_DIR path (/Users/honghaoli/Downloads/Xcode.app/Contents/Developer), missing xcrun at: /Users/honghaoli/Downloads/Xcode.app/Contents/Developer/usr/bin/xcrun
, stdout:
INFO: Analysed target //:stupid_test (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
Target //:stupid_test up-to-date:
bazel-bin/stupid_test
INFO: Elapsed time: 1.840s, Critical Path: 1.55s
INFO: 4 processes: 4 darwin-sandbox.
INFO: Build completed successfully, 4 total actions
//:stupid_test PASSED in 0.1s
Executed 1 out of 1 test: 1 test passes.
INFO: Build completed successfully, 4 total actions
I have no idea why it passed.
CMake Works
The same test file would fail with very clear message using cmake and clion. For example, part of the CMakeLists
add_executable(stupid_test stupid_test.cc)
target_link_libraries(stupid_test gtest gtest_main)
add_test(NAME stupid_test COMMAND stupid_test)
and the output fail message:
Testing started at 19:16 ...
/Users/myusername...blabla/cmake-build-debug/stupid_test --gtest_filter=* --gtest_color=no
Running main() from /Users/myusername...blabla/cmake-build-debug/googletest-src/googletest/src/gtest_main.cc
[==========] Running 1 test from 1 test suite./Users/myusername...blabla/stupid_test.cc:11: Failure
Expected equality of these values:
100
20
/Users/myusername...blabla/stupid_test.cc:12: Failure
Value of: false
Actual: false
Expected: true
/Users/myusername...blabla/stupid_test.cc:13: Failure
Value of: true
Actual: true
Expected: false
Process finished with exit code 1
I am using the Mac OS 10.14 if that helps.
c++ unit-testing cmake googletest bazel
add a comment |
I am trying to use googletest with bazel and cmake.
The cmake and clion works perfect as for the test part, it fails where it should fail and passes where it should pass.
However, bazel test
will pass all the tests even they should not.
Bazel test not working
For example, I have the stupid_test.cc
file:
#include "gtest/gtest.h"
TEST(StupidTests, Stupid1)
EXPECT_EQ(100, 20);
EXPECT_TRUE(false);
which should fail always.
The bazel BUILD
file:
cc_test(
name = "stupid_test",
srcs = ["stupid_test.cc"],
deps = [
"//bazel_build/googletest:gtest",
],
)
where bazel_build/googletest
is exactly the same files downloaded from the googletest github.
Then I run bazel test :stupid_test
, the output is:
⇒ blaze test :stupid_test
DEBUG: /private/var/tmp/_bazel_myusername/741c62b201e51840aa320b156e05fd70/external/bazel_tools/tools/osx/xcode_configure.bzl:87:9: Invoking xcodebuild failed, developer dir: /Users/honghaoli/Downloads/Xcode.app/Contents/Developer ,return code 1, stderr: xcrun: error: invalid DEVELOPER_DIR path (/Users/honghaoli/Downloads/Xcode.app/Contents/Developer), missing xcrun at: /Users/honghaoli/Downloads/Xcode.app/Contents/Developer/usr/bin/xcrun
, stdout:
INFO: Analysed target //:stupid_test (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
Target //:stupid_test up-to-date:
bazel-bin/stupid_test
INFO: Elapsed time: 1.840s, Critical Path: 1.55s
INFO: 4 processes: 4 darwin-sandbox.
INFO: Build completed successfully, 4 total actions
//:stupid_test PASSED in 0.1s
Executed 1 out of 1 test: 1 test passes.
INFO: Build completed successfully, 4 total actions
I have no idea why it passed.
CMake Works
The same test file would fail with very clear message using cmake and clion. For example, part of the CMakeLists
add_executable(stupid_test stupid_test.cc)
target_link_libraries(stupid_test gtest gtest_main)
add_test(NAME stupid_test COMMAND stupid_test)
and the output fail message:
Testing started at 19:16 ...
/Users/myusername...blabla/cmake-build-debug/stupid_test --gtest_filter=* --gtest_color=no
Running main() from /Users/myusername...blabla/cmake-build-debug/googletest-src/googletest/src/gtest_main.cc
[==========] Running 1 test from 1 test suite./Users/myusername...blabla/stupid_test.cc:11: Failure
Expected equality of these values:
100
20
/Users/myusername...blabla/stupid_test.cc:12: Failure
Value of: false
Actual: false
Expected: true
/Users/myusername...blabla/stupid_test.cc:13: Failure
Value of: true
Actual: true
Expected: false
Process finished with exit code 1
I am using the Mac OS 10.14 if that helps.
c++ unit-testing cmake googletest bazel
add a comment |
I am trying to use googletest with bazel and cmake.
The cmake and clion works perfect as for the test part, it fails where it should fail and passes where it should pass.
However, bazel test
will pass all the tests even they should not.
Bazel test not working
For example, I have the stupid_test.cc
file:
#include "gtest/gtest.h"
TEST(StupidTests, Stupid1)
EXPECT_EQ(100, 20);
EXPECT_TRUE(false);
which should fail always.
The bazel BUILD
file:
cc_test(
name = "stupid_test",
srcs = ["stupid_test.cc"],
deps = [
"//bazel_build/googletest:gtest",
],
)
where bazel_build/googletest
is exactly the same files downloaded from the googletest github.
Then I run bazel test :stupid_test
, the output is:
⇒ blaze test :stupid_test
DEBUG: /private/var/tmp/_bazel_myusername/741c62b201e51840aa320b156e05fd70/external/bazel_tools/tools/osx/xcode_configure.bzl:87:9: Invoking xcodebuild failed, developer dir: /Users/honghaoli/Downloads/Xcode.app/Contents/Developer ,return code 1, stderr: xcrun: error: invalid DEVELOPER_DIR path (/Users/honghaoli/Downloads/Xcode.app/Contents/Developer), missing xcrun at: /Users/honghaoli/Downloads/Xcode.app/Contents/Developer/usr/bin/xcrun
, stdout:
INFO: Analysed target //:stupid_test (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
Target //:stupid_test up-to-date:
bazel-bin/stupid_test
INFO: Elapsed time: 1.840s, Critical Path: 1.55s
INFO: 4 processes: 4 darwin-sandbox.
INFO: Build completed successfully, 4 total actions
//:stupid_test PASSED in 0.1s
Executed 1 out of 1 test: 1 test passes.
INFO: Build completed successfully, 4 total actions
I have no idea why it passed.
CMake Works
The same test file would fail with very clear message using cmake and clion. For example, part of the CMakeLists
add_executable(stupid_test stupid_test.cc)
target_link_libraries(stupid_test gtest gtest_main)
add_test(NAME stupid_test COMMAND stupid_test)
and the output fail message:
Testing started at 19:16 ...
/Users/myusername...blabla/cmake-build-debug/stupid_test --gtest_filter=* --gtest_color=no
Running main() from /Users/myusername...blabla/cmake-build-debug/googletest-src/googletest/src/gtest_main.cc
[==========] Running 1 test from 1 test suite./Users/myusername...blabla/stupid_test.cc:11: Failure
Expected equality of these values:
100
20
/Users/myusername...blabla/stupid_test.cc:12: Failure
Value of: false
Actual: false
Expected: true
/Users/myusername...blabla/stupid_test.cc:13: Failure
Value of: true
Actual: true
Expected: false
Process finished with exit code 1
I am using the Mac OS 10.14 if that helps.
c++ unit-testing cmake googletest bazel
I am trying to use googletest with bazel and cmake.
The cmake and clion works perfect as for the test part, it fails where it should fail and passes where it should pass.
However, bazel test
will pass all the tests even they should not.
Bazel test not working
For example, I have the stupid_test.cc
file:
#include "gtest/gtest.h"
TEST(StupidTests, Stupid1)
EXPECT_EQ(100, 20);
EXPECT_TRUE(false);
which should fail always.
The bazel BUILD
file:
cc_test(
name = "stupid_test",
srcs = ["stupid_test.cc"],
deps = [
"//bazel_build/googletest:gtest",
],
)
where bazel_build/googletest
is exactly the same files downloaded from the googletest github.
Then I run bazel test :stupid_test
, the output is:
⇒ blaze test :stupid_test
DEBUG: /private/var/tmp/_bazel_myusername/741c62b201e51840aa320b156e05fd70/external/bazel_tools/tools/osx/xcode_configure.bzl:87:9: Invoking xcodebuild failed, developer dir: /Users/honghaoli/Downloads/Xcode.app/Contents/Developer ,return code 1, stderr: xcrun: error: invalid DEVELOPER_DIR path (/Users/honghaoli/Downloads/Xcode.app/Contents/Developer), missing xcrun at: /Users/honghaoli/Downloads/Xcode.app/Contents/Developer/usr/bin/xcrun
, stdout:
INFO: Analysed target //:stupid_test (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
Target //:stupid_test up-to-date:
bazel-bin/stupid_test
INFO: Elapsed time: 1.840s, Critical Path: 1.55s
INFO: 4 processes: 4 darwin-sandbox.
INFO: Build completed successfully, 4 total actions
//:stupid_test PASSED in 0.1s
Executed 1 out of 1 test: 1 test passes.
INFO: Build completed successfully, 4 total actions
I have no idea why it passed.
CMake Works
The same test file would fail with very clear message using cmake and clion. For example, part of the CMakeLists
add_executable(stupid_test stupid_test.cc)
target_link_libraries(stupid_test gtest gtest_main)
add_test(NAME stupid_test COMMAND stupid_test)
and the output fail message:
Testing started at 19:16 ...
/Users/myusername...blabla/cmake-build-debug/stupid_test --gtest_filter=* --gtest_color=no
Running main() from /Users/myusername...blabla/cmake-build-debug/googletest-src/googletest/src/gtest_main.cc
[==========] Running 1 test from 1 test suite./Users/myusername...blabla/stupid_test.cc:11: Failure
Expected equality of these values:
100
20
/Users/myusername...blabla/stupid_test.cc:12: Failure
Value of: false
Actual: false
Expected: true
/Users/myusername...blabla/stupid_test.cc:13: Failure
Value of: true
Actual: true
Expected: false
Process finished with exit code 1
I am using the Mac OS 10.14 if that helps.
c++ unit-testing cmake googletest bazel
c++ unit-testing cmake googletest bazel
asked Mar 25 at 2:23
Valar MorghulisValar Morghulis
510314
510314
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I figured out the reason.
Just change
"//bazel_build/googletest:gtest",
in the BUILD
file into
"//bazel_build/googletest:gtest_main",
I'm still confused!
If the gtest
does not work, it should at least fail the build or throw error/warnings. It should never say:
Executed 1 out of 1 test: 1 test passes.
as the output.
I consider it as a bug.
A relevant post but not the answer for my problem here.
– Valar Morghulis
Mar 25 at 5:33
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330525%2fgoogletest-never-fails-where-it-should-with-bazel-test-but-works-with-cmake%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I figured out the reason.
Just change
"//bazel_build/googletest:gtest",
in the BUILD
file into
"//bazel_build/googletest:gtest_main",
I'm still confused!
If the gtest
does not work, it should at least fail the build or throw error/warnings. It should never say:
Executed 1 out of 1 test: 1 test passes.
as the output.
I consider it as a bug.
A relevant post but not the answer for my problem here.
– Valar Morghulis
Mar 25 at 5:33
add a comment |
I figured out the reason.
Just change
"//bazel_build/googletest:gtest",
in the BUILD
file into
"//bazel_build/googletest:gtest_main",
I'm still confused!
If the gtest
does not work, it should at least fail the build or throw error/warnings. It should never say:
Executed 1 out of 1 test: 1 test passes.
as the output.
I consider it as a bug.
A relevant post but not the answer for my problem here.
– Valar Morghulis
Mar 25 at 5:33
add a comment |
I figured out the reason.
Just change
"//bazel_build/googletest:gtest",
in the BUILD
file into
"//bazel_build/googletest:gtest_main",
I'm still confused!
If the gtest
does not work, it should at least fail the build or throw error/warnings. It should never say:
Executed 1 out of 1 test: 1 test passes.
as the output.
I consider it as a bug.
I figured out the reason.
Just change
"//bazel_build/googletest:gtest",
in the BUILD
file into
"//bazel_build/googletest:gtest_main",
I'm still confused!
If the gtest
does not work, it should at least fail the build or throw error/warnings. It should never say:
Executed 1 out of 1 test: 1 test passes.
as the output.
I consider it as a bug.
answered Mar 25 at 5:31
Valar MorghulisValar Morghulis
510314
510314
A relevant post but not the answer for my problem here.
– Valar Morghulis
Mar 25 at 5:33
add a comment |
A relevant post but not the answer for my problem here.
– Valar Morghulis
Mar 25 at 5:33
A relevant post but not the answer for my problem here.
– Valar Morghulis
Mar 25 at 5:33
A relevant post but not the answer for my problem here.
– Valar Morghulis
Mar 25 at 5:33
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330525%2fgoogletest-never-fails-where-it-should-with-bazel-test-but-works-with-cmake%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown