Skip to content

Commit

Permalink
fix gtest parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
matepek committed Oct 19, 2024
1 parent 15f2705 commit 4161a4c
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/WorkspaceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class WorkspaceManager implements vscode.Disposable {
configuration.getEnableStrictPattern(),
configuration.getGoogleTestTreatGMockWarningAs(),
configuration.getGoogleTestGMockVerbose(),
true,
false,
);

this._disposables.push(
Expand Down
3 changes: 2 additions & 1 deletion test/cpp/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include("GoogleTest.cmake")

add_gtest_with_main(gtest1 "gtest1.cpp")
add_gtest_with_main(gtest2 "gtest2.cpp")
add_gtest_with_main(gtest2 "gtest2.cpp")
add_gtest(gtest3 "gtest3.cpp")
5 changes: 5 additions & 0 deletions test/cpp/gtest/GoogleTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

2 changes: 1 addition & 1 deletion test/cpp/gtest/gtest1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,4 @@ TEST(ThisTest, FailsWithEmpty) {

TEST(ThisTest, AlsoFailsWithContext) {
ASSERT_EQ(1, 2) << "Value of [" << 1 << "] is not equal to [" << 2 << "]";
}
}
28 changes: 28 additions & 0 deletions test/cpp/gtest/gtest3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <gtest/gtest.h>
#include <iostream>

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

0 comments on commit 4161a4c

Please sign in to comment.