Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
5e0cf72b
Commit
5e0cf72b
authored
Jun 26, 2020
by
Mark Barolak
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2718 from NINI1988:master
PiperOrigin-RevId: 317696457
parents
62f388e1
ff487265
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
194 additions
and
12 deletions
+194
-12
CMakeLists.txt
googletest/CMakeLists.txt
+3
-0
gtest-param-test.h
googletest/include/gtest/gtest-param-test.h
+2
-1
gtest-param-util.h
googletest/include/gtest/internal/gtest-param-util.h
+10
-6
gtest_list_output_unittest.py
googletest/test/gtest_list_output_unittest.py
+149
-5
gtest_list_output_unittest_.cc
googletest/test/gtest_list_output_unittest_.cc
+30
-0
No files found.
googletest/CMakeLists.txt
View file @
5e0cf72b
...
@@ -320,6 +320,9 @@ $env:Path = \"$project_bin;$env:Path\"
...
@@ -320,6 +320,9 @@ $env:Path = \"$project_bin;$env:Path\"
cxx_executable
(
googletest-uninitialized-test_ test gtest
)
cxx_executable
(
googletest-uninitialized-test_ test gtest
)
py_test
(
googletest-uninitialized-test
)
py_test
(
googletest-uninitialized-test
)
cxx_executable
(
gtest_list_output_unittest_ test gtest
)
py_test
(
gtest_list_output_unittest
)
cxx_executable
(
gtest_xml_outfile1_test_ test gtest_main
)
cxx_executable
(
gtest_xml_outfile1_test_ test gtest_main
)
cxx_executable
(
gtest_xml_outfile2_test_ test gtest_main
)
cxx_executable
(
gtest_xml_outfile2_test_ test gtest_main
)
py_test
(
gtest_xml_outfiles_test
)
py_test
(
gtest_xml_outfiles_test
)
...
...
googletest/include/gtest/gtest-param-test.h
View file @
5e0cf72b
...
@@ -428,7 +428,8 @@ internal::CartesianProductHolder<Generator...> Combine(const Generator&... g) {
...
@@ -428,7 +428,8 @@ internal::CartesianProductHolder<Generator...> Combine(const Generator&... g) {
->AddTestPattern( \
->AddTestPattern( \
GTEST_STRINGIFY_(test_suite_name), GTEST_STRINGIFY_(test_name), \
GTEST_STRINGIFY_(test_suite_name), GTEST_STRINGIFY_(test_name), \
new ::testing::internal::TestMetaFactory<GTEST_TEST_CLASS_NAME_( \
new ::testing::internal::TestMetaFactory<GTEST_TEST_CLASS_NAME_( \
test_suite_name, test_name)>()); \
test_suite_name, test_name)>(), \
::testing::internal::CodeLocation(__FILE__, __LINE__)); \
return 0; \
return 0; \
} \
} \
static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \
static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \
...
...
googletest/include/gtest/internal/gtest-param-util.h
View file @
5e0cf72b
...
@@ -520,9 +520,10 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
...
@@ -520,9 +520,10 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
// parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is
// parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is
// test suite base name and DoBar is test base name.
// test suite base name and DoBar is test base name.
void
AddTestPattern
(
const
char
*
test_suite_name
,
const
char
*
test_base_name
,
void
AddTestPattern
(
const
char
*
test_suite_name
,
const
char
*
test_base_name
,
TestMetaFactoryBase
<
ParamType
>*
meta_factory
)
{
TestMetaFactoryBase
<
ParamType
>*
meta_factory
,
tests_
.
push_back
(
std
::
shared_ptr
<
TestInfo
>
(
CodeLocation
code_location
)
{
new
TestInfo
(
test_suite_name
,
test_base_name
,
meta_factory
)));
tests_
.
push_back
(
std
::
shared_ptr
<
TestInfo
>
(
new
TestInfo
(
test_suite_name
,
test_base_name
,
meta_factory
,
code_location
)));
}
}
// INSTANTIATE_TEST_SUITE_P macro uses AddGenerator() to record information
// INSTANTIATE_TEST_SUITE_P macro uses AddGenerator() to record information
// about a generator.
// about a generator.
...
@@ -589,7 +590,7 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
...
@@ -589,7 +590,7 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
MakeAndRegisterTestInfo
(
MakeAndRegisterTestInfo
(
test_suite_name
.
c_str
(),
test_name_stream
.
GetString
().
c_str
(),
test_suite_name
.
c_str
(),
test_name_stream
.
GetString
().
c_str
(),
nullptr
,
// No type parameter.
nullptr
,
// No type parameter.
PrintToString
(
*
param_it
).
c_str
(),
code_location_
,
PrintToString
(
*
param_it
).
c_str
(),
test_info
->
code_location
,
GetTestSuiteTypeId
(),
GetTestSuiteTypeId
(),
SuiteApiResolver
<
TestSuite
>::
GetSetUpCaseOrSuite
(
file
,
line
),
SuiteApiResolver
<
TestSuite
>::
GetSetUpCaseOrSuite
(
file
,
line
),
SuiteApiResolver
<
TestSuite
>::
GetTearDownCaseOrSuite
(
file
,
line
),
SuiteApiResolver
<
TestSuite
>::
GetTearDownCaseOrSuite
(
file
,
line
),
...
@@ -610,14 +611,17 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
...
@@ -610,14 +611,17 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
// with TEST_P macro.
// with TEST_P macro.
struct
TestInfo
{
struct
TestInfo
{
TestInfo
(
const
char
*
a_test_suite_base_name
,
const
char
*
a_test_base_name
,
TestInfo
(
const
char
*
a_test_suite_base_name
,
const
char
*
a_test_base_name
,
TestMetaFactoryBase
<
ParamType
>*
a_test_meta_factory
)
TestMetaFactoryBase
<
ParamType
>*
a_test_meta_factory
,
CodeLocation
a_code_location
)
:
test_suite_base_name
(
a_test_suite_base_name
),
:
test_suite_base_name
(
a_test_suite_base_name
),
test_base_name
(
a_test_base_name
),
test_base_name
(
a_test_base_name
),
test_meta_factory
(
a_test_meta_factory
)
{}
test_meta_factory
(
a_test_meta_factory
),
code_location
(
a_code_location
)
{}
const
std
::
string
test_suite_base_name
;
const
std
::
string
test_suite_base_name
;
const
std
::
string
test_base_name
;
const
std
::
string
test_base_name
;
const
std
::
unique_ptr
<
TestMetaFactoryBase
<
ParamType
>
>
test_meta_factory
;
const
std
::
unique_ptr
<
TestMetaFactoryBase
<
ParamType
>
>
test_meta_factory
;
const
CodeLocation
code_location
;
};
};
using
TestInfoContainer
=
::
std
::
vector
<
std
::
shared_ptr
<
TestInfo
>
>
;
using
TestInfoContainer
=
::
std
::
vector
<
std
::
shared_ptr
<
TestInfo
>
>
;
// Records data received from INSTANTIATE_TEST_SUITE_P macros:
// Records data received from INSTANTIATE_TEST_SUITE_P macros:
...
...
googletest/test/gtest_list_output_unittest.py
View file @
5e0cf72b
...
@@ -46,16 +46,42 @@ GTEST_LIST_TESTS_FLAG = '--gtest_list_tests'
...
@@ -46,16 +46,42 @@ GTEST_LIST_TESTS_FLAG = '--gtest_list_tests'
GTEST_OUTPUT_FLAG
=
'--gtest_output'
GTEST_OUTPUT_FLAG
=
'--gtest_output'
EXPECTED_XML
=
"""<
\
?xml version="1.0" encoding="UTF-8"
\
?>
EXPECTED_XML
=
"""<
\
?xml version="1.0" encoding="UTF-8"
\
?>
<testsuites tests="
2
" name="AllTests">
<testsuites tests="
16
" name="AllTests">
<testsuite name="FooTest" tests="2">
<testsuite name="FooTest" tests="2">
<testcase name="Test1" file=".*gtest_list_output_unittest_.cc" line="43" />
<testcase name="Test1" file=".*gtest_list_output_unittest_.cc" line="43" />
<testcase name="Test2" file=".*gtest_list_output_unittest_.cc" line="45" />
<testcase name="Test2" file=".*gtest_list_output_unittest_.cc" line="45" />
</testsuite>
</testsuite>
<testsuite name="FooTestFixture" tests="2">
<testcase name="Test3" file=".*gtest_list_output_unittest_.cc" line="48" />
<testcase name="Test4" file=".*gtest_list_output_unittest_.cc" line="49" />
</testsuite>
<testsuite name="TypedTest/0" tests="2">
<testcase name="Test7" type_param="int" file=".*gtest_list_output_unittest_.cc" line="60" />
<testcase name="Test8" type_param="int" file=".*gtest_list_output_unittest_.cc" line="61" />
</testsuite>
<testsuite name="TypedTest/1" tests="2">
<testcase name="Test7" type_param="bool" file=".*gtest_list_output_unittest_.cc" line="60" />
<testcase name="Test8" type_param="bool" file=".*gtest_list_output_unittest_.cc" line="61" />
</testsuite>
<testsuite name="Single/TypeParameterizedTestSuite/0" tests="2">
<testcase name="Test9" type_param="int" file=".*gtest_list_output_unittest_.cc" line="68" />
<testcase name="Test10" type_param="int" file=".*gtest_list_output_unittest_.cc" line="69" />
</testsuite>
<testsuite name="Single/TypeParameterizedTestSuite/1" tests="2">
<testcase name="Test9" type_param="bool" file=".*gtest_list_output_unittest_.cc" line="68" />
<testcase name="Test10" type_param="bool" file=".*gtest_list_output_unittest_.cc" line="69" />
</testsuite>
<testsuite name="ValueParam/ValueParamTest" tests="4">
<testcase name="Test5/0" value_param="33" file=".*gtest_list_output_unittest_.cc" line="52" />
<testcase name="Test5/1" value_param="42" file=".*gtest_list_output_unittest_.cc" line="52" />
<testcase name="Test6/0" value_param="33" file=".*gtest_list_output_unittest_.cc" line="53" />
<testcase name="Test6/1" value_param="42" file=".*gtest_list_output_unittest_.cc" line="53" />
</testsuite>
</testsuites>
</testsuites>
"""
"""
EXPECTED_JSON
=
"""{
EXPECTED_JSON
=
"""{
"tests":
2
,
"tests":
16
,
"name": "AllTests",
"name": "AllTests",
"testsuites":
\
[
"testsuites":
\
[
{
{
...
@@ -73,6 +99,124 @@ EXPECTED_JSON = """{
...
@@ -73,6 +99,124 @@ EXPECTED_JSON = """{
"line": 45
"line": 45
}
}
\
]
\
]
},
{
"name": "FooTestFixture",
"tests": 2,
"testsuite":
\
[
{
"name": "Test3",
"file": ".*gtest_list_output_unittest_.cc",
"line": 48
},
{
"name": "Test4",
"file": ".*gtest_list_output_unittest_.cc",
"line": 49
}
\
]
},
{
"name": "TypedTest
\\\\
/0",
"tests": 2,
"testsuite":
\
[
{
"name": "Test7",
"type_param": "int",
"file": ".*gtest_list_output_unittest_.cc",
"line": 60
},
{
"name": "Test8",
"type_param": "int",
"file": ".*gtest_list_output_unittest_.cc",
"line": 61
}
\
]
},
{
"name": "TypedTest
\\\\
/1",
"tests": 2,
"testsuite":
\
[
{
"name": "Test7",
"type_param": "bool",
"file": ".*gtest_list_output_unittest_.cc",
"line": 60
},
{
"name": "Test8",
"type_param": "bool",
"file": ".*gtest_list_output_unittest_.cc",
"line": 61
}
\
]
},
{
"name": "Single
\\\\
/TypeParameterizedTestSuite
\\\\
/0",
"tests": 2,
"testsuite":
\
[
{
"name": "Test9",
"type_param": "int",
"file": ".*gtest_list_output_unittest_.cc",
"line": 68
},
{
"name": "Test10",
"type_param": "int",
"file": ".*gtest_list_output_unittest_.cc",
"line": 69
}
\
]
},
{
"name": "Single
\\\\
/TypeParameterizedTestSuite
\\\\
/1",
"tests": 2,
"testsuite":
\
[
{
"name": "Test9",
"type_param": "bool",
"file": ".*gtest_list_output_unittest_.cc",
"line": 68
},
{
"name": "Test10",
"type_param": "bool",
"file": ".*gtest_list_output_unittest_.cc",
"line": 69
}
\
]
},
{
"name": "ValueParam
\\\\
/ValueParamTest",
"tests": 4,
"testsuite":
\
[
{
"name": "Test5
\\\\
/0",
"value_param": "33",
"file": ".*gtest_list_output_unittest_.cc",
"line": 52
},
{
"name": "Test5
\\\\
/1",
"value_param": "42",
"file": ".*gtest_list_output_unittest_.cc",
"line": 52
},
{
"name": "Test6
\\\\
/0",
"value_param": "33",
"file": ".*gtest_list_output_unittest_.cc",
"line": 53
},
{
"name": "Test6
\\\\
/1",
"value_param": "42",
"file": ".*gtest_list_output_unittest_.cc",
"line": 53
}
\
]
}
}
\
]
\
]
}
}
...
@@ -114,8 +258,8 @@ class GTestListTestsOutputUnitTest(gtest_test_utils.TestCase):
...
@@ -114,8 +258,8 @@ class GTestListTestsOutputUnitTest(gtest_test_utils.TestCase):
p
=
gtest_test_utils
.
Subprocess
(
p
=
gtest_test_utils
.
Subprocess
(
command
,
env
=
environ_copy
,
working_dir
=
gtest_test_utils
.
GetTempDir
())
command
,
env
=
environ_copy
,
working_dir
=
gtest_test_utils
.
GetTempDir
())
self
.
assert
_
(
p
.
exited
)
self
.
assert
True
(
p
.
exited
)
self
.
assertEqual
s
(
0
,
p
.
exit_code
)
self
.
assertEqual
(
0
,
p
.
exit_code
)
with
open
(
file_path
)
as
f
:
with
open
(
file_path
)
as
f
:
result
=
f
.
read
()
result
=
f
.
read
()
return
result
return
result
...
@@ -128,7 +272,7 @@ class GTestListTestsOutputUnitTest(gtest_test_utils.TestCase):
...
@@ -128,7 +272,7 @@ class GTestListTestsOutputUnitTest(gtest_test_utils.TestCase):
for
actual_line
in
actual_lines
:
for
actual_line
in
actual_lines
:
expected_line
=
expected_lines
[
line_count
]
expected_line
=
expected_lines
[
line_count
]
expected_line_re
=
re
.
compile
(
expected_line
.
strip
())
expected_line_re
=
re
.
compile
(
expected_line
.
strip
())
self
.
assert
_
(
self
.
assert
True
(
expected_line_re
.
match
(
actual_line
.
strip
()),
expected_line_re
.
match
(
actual_line
.
strip
()),
(
'actual output of "
%
s",
\n
'
(
'actual output of "
%
s",
\n
'
'which does not match expected regex of "
%
s"
\n
'
'which does not match expected regex of "
%
s"
\n
'
...
...
googletest/test/gtest_list_output_unittest_.cc
View file @
5e0cf72b
...
@@ -44,6 +44,36 @@ TEST(FooTest, Test1) {}
...
@@ -44,6 +44,36 @@ TEST(FooTest, Test1) {}
TEST
(
FooTest
,
Test2
)
{}
TEST
(
FooTest
,
Test2
)
{}
class
FooTestFixture
:
public
::
testing
::
Test
{};
TEST_F
(
FooTestFixture
,
Test3
)
{}
TEST_F
(
FooTestFixture
,
Test4
)
{}
class
ValueParamTest
:
public
::
testing
::
TestWithParam
<
int
>
{};
TEST_P
(
ValueParamTest
,
Test5
)
{}
TEST_P
(
ValueParamTest
,
Test6
)
{}
INSTANTIATE_TEST_SUITE_P
(
ValueParam
,
ValueParamTest
,
::
testing
::
Values
(
33
,
42
));
#if GTEST_HAS_TYPED_TEST
template
<
typename
T
>
class
TypedTest
:
public
::
testing
::
Test
{};
typedef
testing
::
Types
<
int
,
bool
>
TypedTestTypes
;
TYPED_TEST_SUITE
(
TypedTest
,
TypedTestTypes
);
TYPED_TEST
(
TypedTest
,
Test7
)
{}
TYPED_TEST
(
TypedTest
,
Test8
)
{}
#endif
#if GTEST_HAS_TYPED_TEST_P
template
<
typename
T
>
class
TypeParameterizedTestSuite
:
public
::
testing
::
Test
{};
TYPED_TEST_SUITE_P
(
TypeParameterizedTestSuite
);
TYPED_TEST_P
(
TypeParameterizedTestSuite
,
Test9
)
{}
TYPED_TEST_P
(
TypeParameterizedTestSuite
,
Test10
)
{}
REGISTER_TYPED_TEST_SUITE_P
(
TypeParameterizedTestSuite
,
Test9
,
Test10
);
typedef
testing
::
Types
<
int
,
bool
>
TypeParameterizedTestSuiteTypes
;
// NOLINT
INSTANTIATE_TYPED_TEST_SUITE_P
(
Single
,
TypeParameterizedTestSuite
,
TypeParameterizedTestSuiteTypes
);
#endif
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment