Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
f11a8f91
Unverified
Commit
f11a8f91
authored
Feb 12, 2018
by
Conor Burgess
Committed by
GitHub
Feb 12, 2018
Browse files
Merge branch 'master' into fix-argc
parents
27bb844e
15392f1a
Changes
66
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
38 deletions
+60
-38
googletest/test/gtest_uninitialized_test_.cc
googletest/test/gtest_uninitialized_test_.cc
+2
-2
googletest/test/gtest_unittest.cc
googletest/test/gtest_unittest.cc
+8
-8
googletest/test/gtest_xml_outfiles_test.py
googletest/test/gtest_xml_outfiles_test.py
+0
-4
googletest/test/gtest_xml_output_unittest.py
googletest/test/gtest_xml_output_unittest.py
+46
-13
googletest/test/gtest_xml_test_utils.py
googletest/test/gtest_xml_test_utils.py
+3
-10
googletest/xcode/Scripts/versiongenerate.py
googletest/xcode/Scripts/versiongenerate.py
+1
-1
No files found.
googletest/test/gtest_uninitialized_test_.cc
View file @
f11a8f91
...
...
@@ -34,8 +34,8 @@
TEST
(
DummyTest
,
Dummy
)
{
// This test doesn't verify anything. We just need it to create a
// realistic stage for testing the behavior of Google Test when
// RUN_ALL_TESTS() is called without
testing::InitGoogleTest() being
// called first.
// RUN_ALL_TESTS() is called without
//
testing::InitGoogleTest() being
called first.
}
int
main
()
{
...
...
googletest/test/gtest_unittest.cc
View file @
f11a8f91
...
...
@@ -34,9 +34,9 @@
#include "gtest/gtest.h"
// Verifies that the command line flag variables can be accessed
//
in
code once
<
gtest/gtest.h
>
has been
#included.
// Do not move it after other #includes.
// Verifies that the command line flag variables can be accessed
in
// code once
"
gtest/gtest.h
"
has been
//
#included.
Do not move it after other
gtest
#includes.
TEST
(
CommandLineFlagsTest
,
CanBeAccessedInCodeOnceGTestHIsIncluded
)
{
bool
dummy
=
testing
::
GTEST_FLAG
(
also_run_disabled_tests
)
||
testing
::
GTEST_FLAG
(
break_on_failure
)
...
...
@@ -538,7 +538,7 @@ TEST(CodePointToUtf8Test, CanEncode8To11Bits) {
// 101 0111 0110 => 110-10101 10-110110
// Some compilers (e.g., GCC on MinGW) cannot handle non-ASCII codepoints
// in wide strings and wide chars. In order to accomodate them, we have to
// in wide strings and wide chars. In order to accom
m
odate them, we have to
// introduce such character constants as integers.
EXPECT_EQ
(
"
\xD5\xB6
"
,
CodePointToUtf8
(
static_cast
<
wchar_t
>
(
0x576
)));
...
...
@@ -1779,7 +1779,7 @@ TEST(Int32FromEnvOrDieDeathTest, AbortsOnFailure) {
}
// Tests that Int32FromEnvOrDie() aborts with an error message
// if the variable cannot be represnted by an Int32.
// if the variable cannot be repres
e
nted by an Int32.
TEST
(
Int32FromEnvOrDieDeathTest
,
AbortsOnInt32Overflow
)
{
SetEnv
(
GTEST_FLAG_PREFIX_UPPER_
"VAR"
,
"1234567891234567891234"
);
EXPECT_DEATH_IF_SUPPORTED
(
...
...
@@ -3658,7 +3658,7 @@ TEST(AssertionTest, AssertFalseWithAssertionResult) {
}
#ifdef __BORLANDC__
// Restores warnings after previous "#pragma option push" supressed them
// Restores warnings after previous "#pragma option push" sup
p
ressed them
# pragma option pop
#endif
...
...
@@ -4384,7 +4384,7 @@ TEST(ExpectTest, ExpectFalseWithAssertionResult) {
}
#ifdef __BORLANDC__
// Restores warnings after previous "#pragma option push" supressed them
// Restores warnings after previous "#pragma option push" sup
p
ressed them
# pragma option pop
#endif
...
...
@@ -6642,7 +6642,7 @@ TEST(StreamingAssertionsTest, Truth2) {
}
#ifdef __BORLANDC__
// Restores warnings after previous "#pragma option push" supressed them
// Restores warnings after previous "#pragma option push" sup
p
ressed them
# pragma option pop
#endif
...
...
googletest/test/gtest_xml_outfiles_test.py
View file @
f11a8f91
...
...
@@ -31,15 +31,11 @@
"""Unit test for the gtest_xml_output module."""
__author__
=
"keith.ray@gmail.com (Keith Ray)"
import
os
from
xml.dom
import
minidom
,
Node
import
gtest_test_utils
import
gtest_xml_test_utils
GTEST_OUTPUT_SUBDIR
=
"xml_outfiles"
GTEST_OUTPUT_1_TEST
=
"gtest_xml_outfile1_test_"
GTEST_OUTPUT_2_TEST
=
"gtest_xml_outfile2_test_"
...
...
googletest/test/gtest_xml_output_unittest.py
View file @
f11a8f91
...
...
@@ -31,8 +31,6 @@
"""Unit test for the gtest_xml_output module"""
__author__
=
'eefacm@gmail.com (Sean Mcafee)'
import
datetime
import
errno
import
os
...
...
@@ -43,12 +41,16 @@ from xml.dom import minidom, Node
import
gtest_test_utils
import
gtest_xml_test_utils
GTEST_FILTER_FLAG
=
'--gtest_filter'
GTEST_LIST_TESTS_FLAG
=
'--gtest_list_tests'
GTEST_OUTPUT_FLAG
=
"--gtest_output"
GTEST_DEFAULT_OUTPUT_FILE
=
"test_detail.xml"
GTEST_PROGRAM_NAME
=
"gtest_xml_output_unittest_"
GTEST_OUTPUT_FLAG
=
'--gtest_output'
GTEST_DEFAULT_OUTPUT_FILE
=
'test_detail.xml'
GTEST_PROGRAM_NAME
=
'gtest_xml_output_unittest_'
# The environment variables for test sharding.
TOTAL_SHARDS_ENV_VAR
=
'GTEST_TOTAL_SHARDS'
SHARD_INDEX_ENV_VAR
=
'GTEST_SHARD_INDEX'
SHARD_STATUS_FILE_ENV_VAR
=
'GTEST_SHARD_STATUS_FILE'
SUPPORTS_STACK_TRACES
=
False
...
...
@@ -141,6 +143,19 @@ EXPECTED_FILTERED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
</testsuite>
</testsuites>"""
EXPECTED_SHARDED_TEST_XML
=
"""<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="3" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests" ad_hoc_property="42">
<testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="Succeeds" status="run" time="*" classname="SuccessfulTest"/>
</testsuite>
<testsuite name="NoFixtureTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="RecordProperty" status="run" time="*" classname="NoFixtureTest" key="1"/>
</testsuite>
<testsuite name="Single/ValueParamTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="AnotherTestThatHasValueParamAttribute/1" value_param="42" status="run" time="*" classname="Single/ValueParamTest" />
</testsuite>
</testsuites>"""
EXPECTED_EMPTY_XML
=
"""<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="0" failures="0" disabled="0" errors="0" time="*"
timestamp="*" name="AllTests">
...
...
@@ -182,7 +197,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
Runs a test program that generates an empty XML output, and checks if
the timestamp attribute in the testsuites tag is valid.
"""
actual
=
self
.
_GetXmlOutput
(
'gtest_no_test_unittest'
,
[],
0
)
actual
=
self
.
_GetXmlOutput
(
'gtest_no_test_unittest'
,
[],
{},
0
)
date_time_str
=
actual
.
documentElement
.
getAttributeNode
(
'timestamp'
).
value
# datetime.strptime() is only available in Python 2.5+ so we have to
# parse the expected datetime manually.
...
...
@@ -212,8 +227,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
'gtest_no_test_unittest'
)
try
:
os
.
remove
(
output_file
)
except
OSError
:
e
=
sys
.
exc_info
()[
1
]
except
OSError
,
e
:
if
e
.
errno
!=
errno
.
ENOENT
:
raise
...
...
@@ -263,7 +277,22 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
self
.
_TestXmlOutput
(
GTEST_PROGRAM_NAME
,
EXPECTED_FILTERED_TEST_XML
,
0
,
extra_args
=
[
'%s=SuccessfulTest.*'
%
GTEST_FILTER_FLAG
])
def
_GetXmlOutput
(
self
,
gtest_prog_name
,
extra_args
,
expected_exit_code
):
def
testShardedTestXmlOutput
(
self
):
"""Verifies XML output when run using multiple shards.
Runs a test program that executes only one shard and verifies that tests
from other shards do not show up in the XML output.
"""
self
.
_TestXmlOutput
(
GTEST_PROGRAM_NAME
,
EXPECTED_SHARDED_TEST_XML
,
0
,
extra_env
=
{
SHARD_INDEX_ENV_VAR
:
'0'
,
TOTAL_SHARDS_ENV_VAR
:
'10'
})
def
_GetXmlOutput
(
self
,
gtest_prog_name
,
extra_args
,
extra_env
,
expected_exit_code
):
"""
Returns the xml output generated by running the program gtest_prog_name.
Furthermore, the program's exit code must be expected_exit_code.
...
...
@@ -274,7 +303,11 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
command
=
([
gtest_prog_path
,
'%s=xml:%s'
%
(
GTEST_OUTPUT_FLAG
,
xml_path
)]
+
extra_args
)
p
=
gtest_test_utils
.
Subprocess
(
command
)
environ_copy
=
os
.
environ
.
copy
()
if
extra_env
:
environ_copy
.
update
(
extra_env
)
p
=
gtest_test_utils
.
Subprocess
(
command
,
env
=
environ_copy
)
if
p
.
terminated_by_signal
:
self
.
assert_
(
False
,
'%s was killed by signal %d'
%
(
gtest_prog_name
,
p
.
signal
))
...
...
@@ -288,7 +321,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
return
actual
def
_TestXmlOutput
(
self
,
gtest_prog_name
,
expected_xml
,
expected_exit_code
,
extra_args
=
None
):
expected_exit_code
,
extra_args
=
None
,
extra_env
=
None
):
"""
Asserts that the XML document generated by running the program
gtest_prog_name matches expected_xml, a string containing another
...
...
@@ -297,7 +330,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
"""
actual
=
self
.
_GetXmlOutput
(
gtest_prog_name
,
extra_args
or
[],
expected_exit_code
)
extra_env
or
{},
expected_exit_code
)
expected
=
minidom
.
parseString
(
expected_xml
)
self
.
NormalizeXml
(
actual
.
documentElement
)
self
.
AssertEquivalentNodes
(
expected
.
documentElement
,
...
...
googletest/test/gtest_xml_test_utils.py
View file @
f11a8f91
#!/usr/bin/env python
#
# Copyright 2006, Google Inc.
# All rights reserved.
#
...
...
@@ -31,15 +29,10 @@
"""Unit test utilities for gtest_xml_output"""
__author__
=
'eefacm@gmail.com (Sean Mcafee)'
import
re
from
xml.dom
import
minidom
,
Node
import
gtest_test_utils
GTEST_OUTPUT_FLAG
=
'--gtest_output'
GTEST_DEFAULT_OUTPUT_FILE
=
'test_detail.xml'
class
GTestXMLTestCase
(
gtest_test_utils
.
TestCase
):
...
...
@@ -101,7 +94,7 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
self
.
assertEquals
(
len
(
expected_children
),
len
(
actual_children
),
'number of child elements differ in element '
+
actual_node
.
tagName
)
for
child_id
,
child
in
expected_children
.
items
():
for
child_id
,
child
in
expected_children
.
iter
items
():
self
.
assert_
(
child_id
in
actual_children
,
'<%s> is not in <%s> (in element %s)'
%
(
child_id
,
actual_children
,
actual_node
.
tagName
))
...
...
@@ -187,8 +180,8 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
# Replaces the source line information with a normalized form.
cdata
=
re
.
sub
(
source_line_pat
,
'
\\
1*
\n
'
,
child
.
nodeValue
)
# Removes the actual stack trace.
child
.
nodeValue
=
re
.
sub
(
r
'
\n
Stack trace:\n(.|\n)*'
,
''
,
cdata
)
child
.
nodeValue
=
re
.
sub
(
r
'Stack trace:\n(.|\n)*'
,
'
Stack trace:
\n
*
'
,
cdata
)
for
child
in
element
.
childNodes
:
if
child
.
nodeType
==
Node
.
ELEMENT_NODE
:
self
.
NormalizeXml
(
child
)
googletest/xcode/Scripts/versiongenerate.py
View file @
f11a8f91
...
...
@@ -29,7 +29,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""A script to prepare version informtion for use the gtest Info.plist file.
"""A script to prepare version inform
a
tion for use the gtest Info.plist file.
This script extracts the version information from the configure.ac file and
uses it to generate a header file containing the same information. The
...
...
Prev
1
2
3
4
Next
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