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;








1















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.










share|improve this question




























    1















    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.










    share|improve this question
























      1












      1








      1


      1






      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.










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 2:23









      Valar MorghulisValar Morghulis

      510314




      510314






















          1 Answer
          1






          active

          oldest

          votes


















          1














          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.






          share|improve this answer























          • A relevant post but not the answer for my problem here.

            – Valar Morghulis
            Mar 25 at 5:33











          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
          );



          );













          draft saved

          draft discarded


















          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









          1














          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.






          share|improve this answer























          • A relevant post but not the answer for my problem here.

            – Valar Morghulis
            Mar 25 at 5:33















          1














          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.






          share|improve this answer























          • A relevant post but not the answer for my problem here.

            – Valar Morghulis
            Mar 25 at 5:33













          1












          1








          1







          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.






          share|improve this answer













          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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

















          • 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

















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript