From 4161a4cd05f2646fce7c0fa36eb177aa8b35b569 Mon Sep 17 00:00:00 2001 From: Mate Pek Date: Sat, 19 Oct 2024 22:17:15 +0800 Subject: [PATCH] fix gtest parsing --- CHANGELOG.md | 2 ++ src/WorkspaceManager.ts | 2 +- test/cpp/gtest/CMakeLists.txt | 3 ++- test/cpp/gtest/GoogleTest.cmake | 5 +++++ test/cpp/gtest/gtest1.cpp | 2 +- test/cpp/gtest/gtest3.cpp | 28 ++++++++++++++++++++++++++++ 6 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 test/cpp/gtest/gtest3.cpp diff --git a/CHANGELOG.md b/CHANGELOG.md index c1b4c2ab..a469d9ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - google test indentation [issue](https://github.com/matepek/vscode-catch2-test-adapter/issues/437) +- google test parsing [issue](https://github.com/matepek/vscode-catch2-test-adapter/issues/436) +- google test parsing: show global env setup and teardown: [issue](https://github.com/matepek/vscode-catch2-test-adapter/issues/442) ## [4.12.0] - 2024-03-29 diff --git a/src/WorkspaceManager.ts b/src/WorkspaceManager.ts index 534b6f39..23424c1f 100644 --- a/src/WorkspaceManager.ts +++ b/src/WorkspaceManager.ts @@ -149,7 +149,7 @@ export class WorkspaceManager implements vscode.Disposable { configuration.getEnableStrictPattern(), configuration.getGoogleTestTreatGMockWarningAs(), configuration.getGoogleTestGMockVerbose(), - true, + false, ); this._disposables.push( diff --git a/test/cpp/gtest/CMakeLists.txt b/test/cpp/gtest/CMakeLists.txt index d57571ca..ef43d6fe 100644 --- a/test/cpp/gtest/CMakeLists.txt +++ b/test/cpp/gtest/CMakeLists.txt @@ -1,4 +1,5 @@ include("GoogleTest.cmake") add_gtest_with_main(gtest1 "gtest1.cpp") -add_gtest_with_main(gtest2 "gtest2.cpp") \ No newline at end of file +add_gtest_with_main(gtest2 "gtest2.cpp") +add_gtest(gtest3 "gtest3.cpp") \ No newline at end of file diff --git a/test/cpp/gtest/GoogleTest.cmake b/test/cpp/gtest/GoogleTest.cmake index 6f974888..2eb51785 100644 --- a/test/cpp/gtest/GoogleTest.cmake +++ b/test/cpp/gtest/GoogleTest.cmake @@ -56,3 +56,8 @@ function(add_gtest_with_main target cpp_file) target_link_libraries(${target} PUBLIC ThirdParty.GoogleMockWithMain) endfunction() +function(add_gtest target cpp_file) + add_executable(${target} "${cpp_file}") + target_link_libraries(${target} PUBLIC ThirdParty.GoogleMockWithMain) +endfunction() + diff --git a/test/cpp/gtest/gtest1.cpp b/test/cpp/gtest/gtest1.cpp index af2f38cd..e43244ff 100644 --- a/test/cpp/gtest/gtest1.cpp +++ b/test/cpp/gtest/gtest1.cpp @@ -172,4 +172,4 @@ TEST(ThisTest, FailsWithEmpty) { TEST(ThisTest, AlsoFailsWithContext) { ASSERT_EQ(1, 2) << "Value of [" << 1 << "] is not equal to [" << 2 << "]"; -} \ No newline at end of file +} diff --git a/test/cpp/gtest/gtest3.cpp b/test/cpp/gtest/gtest3.cpp new file mode 100644 index 00000000..435bbe83 --- /dev/null +++ b/test/cpp/gtest/gtest3.cpp @@ -0,0 +1,28 @@ +#include +#include + +TEST(MyTest, Test) +{ + ASSERT_TRUE(true); +} + +class GlobalEnvironment : public ::testing::Environment { + public: + ~GlobalEnvironment() override {} + + void SetUp() override + { + std::cout << "GlobalEnvironment set up" << std::endl; + } + + void TearDown() override + { + std::cout << "GlobalEnvironment tear down" << std::endl; + } +}; +int main(int argc, char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(new GlobalEnvironment()); + return RUN_ALL_TESTS(); +} \ No newline at end of file