Skip to content

Commit 4161a4c

Browse files
committed
fix gtest parsing
1 parent 15f2705 commit 4161a4c

File tree

6 files changed

+39
-3
lines changed

6 files changed

+39
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1111
### Fixed
1212

1313
- google test indentation [issue](https://github.com/matepek/vscode-catch2-test-adapter/issues/437)
14+
- google test parsing [issue](https://github.com/matepek/vscode-catch2-test-adapter/issues/436)
15+
- google test parsing: show global env setup and teardown: [issue](https://github.com/matepek/vscode-catch2-test-adapter/issues/442)
1416

1517
## [4.12.0] - 2024-03-29
1618

src/WorkspaceManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export class WorkspaceManager implements vscode.Disposable {
149149
configuration.getEnableStrictPattern(),
150150
configuration.getGoogleTestTreatGMockWarningAs(),
151151
configuration.getGoogleTestGMockVerbose(),
152-
true,
152+
false,
153153
);
154154

155155
this._disposables.push(

test/cpp/gtest/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include("GoogleTest.cmake")
22

33
add_gtest_with_main(gtest1 "gtest1.cpp")
4-
add_gtest_with_main(gtest2 "gtest2.cpp")
4+
add_gtest_with_main(gtest2 "gtest2.cpp")
5+
add_gtest(gtest3 "gtest3.cpp")

test/cpp/gtest/GoogleTest.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,8 @@ function(add_gtest_with_main target cpp_file)
5656
target_link_libraries(${target} PUBLIC ThirdParty.GoogleMockWithMain)
5757
endfunction()
5858

59+
function(add_gtest target cpp_file)
60+
add_executable(${target} "${cpp_file}")
61+
target_link_libraries(${target} PUBLIC ThirdParty.GoogleMockWithMain)
62+
endfunction()
63+

test/cpp/gtest/gtest1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,4 @@ TEST(ThisTest, FailsWithEmpty) {
172172

173173
TEST(ThisTest, AlsoFailsWithContext) {
174174
ASSERT_EQ(1, 2) << "Value of [" << 1 << "] is not equal to [" << 2 << "]";
175-
}
175+
}

test/cpp/gtest/gtest3.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <gtest/gtest.h>
2+
#include <iostream>
3+
4+
TEST(MyTest, Test)
5+
{
6+
ASSERT_TRUE(true);
7+
}
8+
9+
class GlobalEnvironment : public ::testing::Environment {
10+
public:
11+
~GlobalEnvironment() override {}
12+
13+
void SetUp() override
14+
{
15+
std::cout << "GlobalEnvironment set up" << std::endl;
16+
}
17+
18+
void TearDown() override
19+
{
20+
std::cout << "GlobalEnvironment tear down" << std::endl;
21+
}
22+
};
23+
int main(int argc, char** argv)
24+
{
25+
::testing::InitGoogleTest(&argc, argv);
26+
::testing::AddGlobalTestEnvironment(new GlobalEnvironment());
27+
return RUN_ALL_TESTS();
28+
}

0 commit comments

Comments
 (0)