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
8d707dfe
Commit
8d707dfe
authored
Jan 22, 2018
by
Gennadiy Civil
Browse files
code merge
parent
62ba5d91
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
44 additions
and
43 deletions
+44
-43
googletest/test/gtest_color_test.py
googletest/test/gtest_color_test.py
+0
-1
googletest/test/gtest_filter_unittest.py
googletest/test/gtest_filter_unittest.py
+20
-18
googletest/test/gtest_list_tests_unittest.py
googletest/test/gtest_list_tests_unittest.py
+4
-4
googletest/test/gtest_output_test.py
googletest/test/gtest_output_test.py
+8
-5
googletest/test/gtest_test_utils.py
googletest/test/gtest_test_utils.py
+8
-8
googletest/test/gtest_throw_on_failure_test.py
googletest/test/gtest_throw_on_failure_test.py
+1
-1
googletest/test/gtest_uninitialized_test.py
googletest/test/gtest_uninitialized_test.py
+3
-2
googletest/test/gtest_xml_outfiles_test.py
googletest/test/gtest_xml_outfiles_test.py
+0
-4
No files found.
googletest/test/gtest_color_test.py
View file @
8d707dfe
...
@@ -36,7 +36,6 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
...
@@ -36,7 +36,6 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
import
os
import
os
import
gtest_test_utils
import
gtest_test_utils
IS_WINDOWS
=
os
.
name
=
'nt'
IS_WINDOWS
=
os
.
name
=
'nt'
COLOR_ENV_VAR
=
'GTEST_COLOR'
COLOR_ENV_VAR
=
'GTEST_COLOR'
...
...
googletest/test/gtest_filter_unittest.py
View file @
8d707dfe
...
@@ -44,12 +44,8 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
...
@@ -44,12 +44,8 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
import
os
import
os
import
re
import
re
try
:
import
sets
from
sets
import
Set
as
set
# For Python 2.3 compatibility
except
ImportError
:
pass
import
sys
import
sys
import
gtest_test_utils
import
gtest_test_utils
# Constants.
# Constants.
...
@@ -59,10 +55,12 @@ import gtest_test_utils
...
@@ -59,10 +55,12 @@ import gtest_test_utils
# script in a subprocess to print whether the variable is STILL in
# script in a subprocess to print whether the variable is STILL in
# os.environ. We then use 'eval' to parse the child's output so that an
# os.environ. We then use 'eval' to parse the child's output so that an
# exception is thrown if the input is anything other than 'True' nor 'False'.
# exception is thrown if the input is anything other than 'True' nor 'False'.
os
.
environ
[
'EMPTY_VAR'
]
=
''
CAN_PASS_EMPTY_ENV
=
False
child
=
gtest_test_utils
.
Subprocess
(
if
sys
.
executable
:
[
sys
.
executable
,
'-c'
,
'import os; print(
\'
EMPTY_VAR
\'
in os.environ)'
])
os
.
environ
[
'EMPTY_VAR'
]
=
''
CAN_PASS_EMPTY_ENV
=
eval
(
child
.
output
)
child
=
gtest_test_utils
.
Subprocess
(
[
sys
.
executable
,
'-c'
,
'import os; print
\'
EMPTY_VAR
\'
in os.environ'
])
CAN_PASS_EMPTY_ENV
=
eval
(
child
.
output
)
# Check if this platform can unset environment variables in child processes.
# Check if this platform can unset environment variables in child processes.
...
@@ -71,11 +69,14 @@ CAN_PASS_EMPTY_ENV = eval(child.output)
...
@@ -71,11 +69,14 @@ CAN_PASS_EMPTY_ENV = eval(child.output)
# is NO LONGER in os.environ.
# is NO LONGER in os.environ.
# We use 'eval' to parse the child's output so that an exception
# We use 'eval' to parse the child's output so that an exception
# is thrown if the input is neither 'True' nor 'False'.
# is thrown if the input is neither 'True' nor 'False'.
os
.
environ
[
'UNSET_VAR'
]
=
'X'
CAN_UNSET_ENV
=
False
del
os
.
environ
[
'UNSET_VAR'
]
if
sys
.
executable
:
child
=
gtest_test_utils
.
Subprocess
(
os
.
environ
[
'UNSET_VAR'
]
=
'X'
[
sys
.
executable
,
'-c'
,
'import os; print(
\'
UNSET_VAR
\'
not in os.environ)'
])
del
os
.
environ
[
'UNSET_VAR'
]
CAN_UNSET_ENV
=
eval
(
child
.
output
)
child
=
gtest_test_utils
.
Subprocess
(
[
sys
.
executable
,
'-c'
,
'import os; print
\'
UNSET_VAR
\'
not in os.environ'
])
CAN_UNSET_ENV
=
eval
(
child
.
output
)
# Checks if we should test with an empty filter. This doesn't
# Checks if we should test with an empty filter. This doesn't
...
@@ -97,7 +98,7 @@ SHARD_STATUS_FILE_ENV_VAR = 'GTEST_SHARD_STATUS_FILE'
...
@@ -97,7 +98,7 @@ SHARD_STATUS_FILE_ENV_VAR = 'GTEST_SHARD_STATUS_FILE'
FILTER_FLAG
=
'gtest_filter'
FILTER_FLAG
=
'gtest_filter'
# The command line flag for including disabled tests.
# The command line flag for including disabled tests.
ALSO_RUN_DISABED_TESTS_FLAG
=
'gtest_also_run_disabled_tests'
ALSO_RUN_DISAB
L
ED_TESTS_FLAG
=
'gtest_also_run_disabled_tests'
# Command to run the gtest_filter_unittest_ program.
# Command to run the gtest_filter_unittest_ program.
COMMAND
=
gtest_test_utils
.
GetTestExecutablePath
(
'gtest_filter_unittest_'
)
COMMAND
=
gtest_test_utils
.
GetTestExecutablePath
(
'gtest_filter_unittest_'
)
...
@@ -246,14 +247,14 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
...
@@ -246,14 +247,14 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
for
slice_var
in
list_of_sets
:
for
slice_var
in
list_of_sets
:
full_partition
.
extend
(
slice_var
)
full_partition
.
extend
(
slice_var
)
self
.
assertEqual
(
len
(
set_var
),
len
(
full_partition
))
self
.
assertEqual
(
len
(
set_var
),
len
(
full_partition
))
self
.
assertEqual
(
set
(
set_var
),
set
(
full_partition
))
self
.
assertEqual
(
set
s
.
Set
(
set_var
),
set
s
.
Set
(
full_partition
))
def
AdjustForParameterizedTests
(
self
,
tests_to_run
):
def
AdjustForParameterizedTests
(
self
,
tests_to_run
):
"""Adjust tests_to_run in case value parameterized tests are disabled."""
"""Adjust tests_to_run in case value parameterized tests are disabled."""
global
param_tests_present
global
param_tests_present
if
not
param_tests_present
:
if
not
param_tests_present
:
return
list
(
set
(
tests_to_run
)
-
set
(
PARAM_TESTS
))
return
list
(
set
s
.
Set
(
tests_to_run
)
-
set
s
.
Set
(
PARAM_TESTS
))
else
:
else
:
return
tests_to_run
return
tests_to_run
...
@@ -294,6 +295,7 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
...
@@ -294,6 +295,7 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
Runs all shards of gtest_filter_unittest_ with the given filter, and
Runs all shards of gtest_filter_unittest_ with the given filter, and
verifies that the right set of tests were run. The union of tests run
verifies that the right set of tests were run. The union of tests run
on each shard should be identical to tests_to_run, without duplicates.
on each shard should be identical to tests_to_run, without duplicates.
If check_exit_0, .
Args:
Args:
gtest_filter: A filter to apply to the tests.
gtest_filter: A filter to apply to the tests.
...
@@ -339,7 +341,7 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
...
@@ -339,7 +341,7 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
tests_to_run
=
self
.
AdjustForParameterizedTests
(
tests_to_run
)
tests_to_run
=
self
.
AdjustForParameterizedTests
(
tests_to_run
)
# Construct the command line.
# Construct the command line.
args
=
[
'--%s'
%
ALSO_RUN_DISABED_TESTS_FLAG
]
args
=
[
'--%s'
%
ALSO_RUN_DISAB
L
ED_TESTS_FLAG
]
if
gtest_filter
is
not
None
:
if
gtest_filter
is
not
None
:
args
.
append
(
'--%s=%s'
%
(
FILTER_FLAG
,
gtest_filter
))
args
.
append
(
'--%s=%s'
%
(
FILTER_FLAG
,
gtest_filter
))
...
...
googletest/test/gtest_list_tests_unittest.py
View file @
8d707dfe
...
@@ -39,9 +39,8 @@ Google Test) the command line flags.
...
@@ -39,9 +39,8 @@ Google Test) the command line flags.
__author__
=
'phanna@google.com (Patrick Hanna)'
__author__
=
'phanna@google.com (Patrick Hanna)'
import
gtest_test_utils
import
re
import
re
import
gtest_test_utils
# Constants.
# Constants.
...
@@ -71,7 +70,7 @@ FooTest\.
...
@@ -71,7 +70,7 @@ FooTest\.
TypedTest/0\. # TypeParam = (VeryLo{245}|class VeryLo{239})\.\.\.
TypedTest/0\. # TypeParam = (VeryLo{245}|class VeryLo{239})\.\.\.
TestA
TestA
TestB
TestB
TypedTest/1\. # TypeParam = int\s*\*
( __ptr64)?
TypedTest/1\. # TypeParam = int\s*\*
TestA
TestA
TestB
TestB
TypedTest/2\. # TypeParam = .*MyArray<bool,\s*42>
TypedTest/2\. # TypeParam = .*MyArray<bool,\s*42>
...
@@ -80,7 +79,7 @@ TypedTest/2\. # TypeParam = .*MyArray<bool,\s*42>
...
@@ -80,7 +79,7 @@ TypedTest/2\. # TypeParam = .*MyArray<bool,\s*42>
My/TypeParamTest/0\. # TypeParam = (VeryLo{245}|class VeryLo{239})\.\.\.
My/TypeParamTest/0\. # TypeParam = (VeryLo{245}|class VeryLo{239})\.\.\.
TestA
TestA
TestB
TestB
My/TypeParamTest/1\. # TypeParam = int\s*\*
( __ptr64)?
My/TypeParamTest/1\. # TypeParam = int\s*\*
TestA
TestA
TestB
TestB
My/TypeParamTest/2\. # TypeParam = .*MyArray<bool,\s*42>
My/TypeParamTest/2\. # TypeParam = .*MyArray<bool,\s*42>
...
@@ -123,6 +122,7 @@ def Run(args):
...
@@ -123,6 +122,7 @@ def Run(args):
# The unit test.
# The unit test.
class
GTestListTestsUnitTest
(
gtest_test_utils
.
TestCase
):
class
GTestListTestsUnitTest
(
gtest_test_utils
.
TestCase
):
"""Tests using the --gtest_list_tests flag to list all tests."""
"""Tests using the --gtest_list_tests flag to list all tests."""
...
...
googletest/test/gtest_output_test.py
View file @
8d707dfe
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
"""Tests the text output of Google C++ Testing Framework.
"""Tests the text output of Google C++ Testing Framework.
SYNOPSIS
SYNOPSIS
gtest_output_test.py --build_dir=BUILD/DIR --gengolden
gtest_output_test.py --build_dir=BUILD/DIR --gengolden
# where BUILD/DIR contains the built gtest_output_test_ file.
# where BUILD/DIR contains the built gtest_output_test_ file.
...
@@ -51,6 +52,7 @@ import gtest_test_utils
...
@@ -51,6 +52,7 @@ import gtest_test_utils
GENGOLDEN_FLAG
=
'--gengolden'
GENGOLDEN_FLAG
=
'--gengolden'
CATCH_EXCEPTIONS_ENV_VAR_NAME
=
'GTEST_CATCH_EXCEPTIONS'
CATCH_EXCEPTIONS_ENV_VAR_NAME
=
'GTEST_CATCH_EXCEPTIONS'
IS_LINUX
=
os
.
name
==
'posix'
and
os
.
uname
()[
0
]
==
'Linux'
IS_WINDOWS
=
os
.
name
==
'nt'
IS_WINDOWS
=
os
.
name
==
'nt'
# TODO(vladl@google.com): remove the _lin suffix.
# TODO(vladl@google.com): remove the _lin suffix.
...
@@ -250,11 +252,12 @@ test_list = GetShellCommandOutput(COMMAND_LIST_TESTS)
...
@@ -250,11 +252,12 @@ test_list = GetShellCommandOutput(COMMAND_LIST_TESTS)
SUPPORTS_DEATH_TESTS
=
'DeathTest'
in
test_list
SUPPORTS_DEATH_TESTS
=
'DeathTest'
in
test_list
SUPPORTS_TYPED_TESTS
=
'TypedTest'
in
test_list
SUPPORTS_TYPED_TESTS
=
'TypedTest'
in
test_list
SUPPORTS_THREADS
=
'ExpectFailureWithThreadsTest'
in
test_list
SUPPORTS_THREADS
=
'ExpectFailureWithThreadsTest'
in
test_list
SUPPORTS_STACK_TRACES
=
False
SUPPORTS_STACK_TRACES
=
IS_LINUX
CAN_GENERATE_GOLDEN_FILE
=
(
SUPPORTS_DEATH_TESTS
and
CAN_GENERATE_GOLDEN_FILE
=
(
SUPPORTS_DEATH_TESTS
and
SUPPORTS_TYPED_TESTS
and
SUPPORTS_TYPED_TESTS
and
SUPPORTS_THREADS
and
SUPPORTS_THREADS
and
SUPPORTS_STACK_TRACES
and
not
IS_WINDOWS
)
not
IS_WINDOWS
)
class
GTestOutputTest
(
gtest_test_utils
.
TestCase
):
class
GTestOutputTest
(
gtest_test_utils
.
TestCase
):
...
@@ -280,7 +283,7 @@ class GTestOutputTest(gtest_test_utils.TestCase):
...
@@ -280,7 +283,7 @@ class GTestOutputTest(gtest_test_utils.TestCase):
def
testOutput
(
self
):
def
testOutput
(
self
):
output
=
GetOutputOfAllCommands
()
output
=
GetOutputOfAllCommands
()
golden_file
=
open
(
GOLDEN_PATH
,
'r'
)
golden_file
=
open
(
GOLDEN_PATH
,
'r
b
'
)
# A mis-configured source control system can cause \r appear in EOL
# A mis-configured source control system can cause \r appear in EOL
# sequences when we read the golden file irrespective of an operating
# sequences when we read the golden file irrespective of an operating
# system used. Therefore, we need to strip those \r's from newlines
# system used. Therefore, we need to strip those \r's from newlines
...
@@ -331,9 +334,9 @@ if __name__ == '__main__':
...
@@ -331,9 +334,9 @@ if __name__ == '__main__':
else
:
else
:
message
=
(
message
=
(
"""Unable to write a golden file when compiled in an environment
"""Unable to write a golden file when compiled in an environment
that does not support all the required features (death tests,
typed tests,
that does not support all the required features (death tests,
and multiple threads). Please generate the golden file using a binary built
typed tests, stack traces, and multiple threads).
with those features enabled
."""
)
Please build this test and generate the golden file using Blaze on Linux
."""
)
sys
.
stderr
.
write
(
message
)
sys
.
stderr
.
write
(
message
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
...
...
googletest/test/gtest_test_utils.py
View file @
8d707dfe
#!/usr/bin/env python
#
# Copyright 2006, Google Inc.
# Copyright 2006, Google Inc.
# All rights reserved.
# All rights reserved.
#
#
...
@@ -33,10 +31,15 @@
...
@@ -33,10 +31,15 @@
__author__
=
'wan@google.com (Zhanyong Wan)'
__author__
=
'wan@google.com (Zhanyong Wan)'
import
atexit
import
os
import
os
import
shutil
import
sys
import
sys
IS_LINUX
=
os
.
name
==
'posix'
and
os
.
uname
()[
0
]
==
'Linux'
IS_WINDOWS
=
os
.
name
==
'nt'
IS_CYGWIN
=
os
.
name
==
'posix'
and
'CYGWIN'
in
os
.
uname
()[
0
]
import
atexit
import
shutil
import
tempfile
import
tempfile
import
unittest
import
unittest
_test_module
=
unittest
_test_module
=
unittest
...
@@ -53,9 +56,6 @@ except:
...
@@ -53,9 +56,6 @@ except:
GTEST_OUTPUT_VAR_NAME
=
'GTEST_OUTPUT'
GTEST_OUTPUT_VAR_NAME
=
'GTEST_OUTPUT'
IS_WINDOWS
=
os
.
name
==
'nt'
IS_CYGWIN
=
os
.
name
==
'posix'
and
'CYGWIN'
in
os
.
uname
()[
0
]
# The environment variable for specifying the path to the premature-exit file.
# The environment variable for specifying the path to the premature-exit file.
PREMATURE_EXIT_FILE_ENV_VAR
=
'TEST_PREMATURE_EXIT_FILE'
PREMATURE_EXIT_FILE_ENV_VAR
=
'TEST_PREMATURE_EXIT_FILE'
...
@@ -178,7 +178,7 @@ def GetTestExecutablePath(executable_name, build_dir=None):
...
@@ -178,7 +178,7 @@ def GetTestExecutablePath(executable_name, build_dir=None):
'Unable to find the test binary "%s". Please make sure to provide
\n
'
'Unable to find the test binary "%s". Please make sure to provide
\n
'
'a path to the binary via the --build_dir flag or the BUILD_DIR
\n
'
'a path to the binary via the --build_dir flag or the BUILD_DIR
\n
'
'environment variable.'
%
path
)
'environment variable.'
%
path
)
sys
.
stdout
.
write
(
message
)
print
>>
sys
.
stderr
,
message
sys
.
exit
(
1
)
sys
.
exit
(
1
)
return
path
return
path
...
...
googletest/test/gtest_throw_on_failure_test.py
View file @
8d707dfe
...
@@ -70,7 +70,7 @@ def SetEnvVar(env_var, value):
...
@@ -70,7 +70,7 @@ def SetEnvVar(env_var, value):
def
Run
(
command
):
def
Run
(
command
):
"""Runs a command; returns True/False if its exit code is/isn't 0."""
"""Runs a command; returns True/False if its exit code is/isn't 0."""
print
(
'Running "%s". . .'
%
' '
.
join
(
command
)
)
print
'Running "%s". . .'
%
' '
.
join
(
command
)
p
=
gtest_test_utils
.
Subprocess
(
command
)
p
=
gtest_test_utils
.
Subprocess
(
command
)
return
p
.
exited
and
p
.
exit_code
==
0
return
p
.
exited
and
p
.
exit_code
==
0
...
...
googletest/test/gtest_uninitialized_test.py
View file @
8d707dfe
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
__author__
=
'wan@google.com (Zhanyong Wan)'
__author__
=
'wan@google.com (Zhanyong Wan)'
import
os
import
gtest_test_utils
import
gtest_test_utils
...
@@ -46,8 +47,8 @@ def Assert(condition):
...
@@ -46,8 +47,8 @@ def Assert(condition):
def
AssertEq
(
expected
,
actual
):
def
AssertEq
(
expected
,
actual
):
if
expected
!=
actual
:
if
expected
!=
actual
:
print
(
'Expected: %s'
%
(
expected
,)
)
print
'Expected: %s'
%
(
expected
,)
print
(
' Actual: %s'
%
(
actual
,)
)
print
' Actual: %s'
%
(
actual
,)
raise
AssertionError
raise
AssertionError
...
...
googletest/test/gtest_xml_outfiles_test.py
View file @
8d707dfe
...
@@ -31,15 +31,11 @@
...
@@ -31,15 +31,11 @@
"""Unit test for the gtest_xml_output module."""
"""Unit test for the gtest_xml_output module."""
__author__
=
"keith.ray@gmail.com (Keith Ray)"
import
os
import
os
from
xml.dom
import
minidom
,
Node
from
xml.dom
import
minidom
,
Node
import
gtest_test_utils
import
gtest_test_utils
import
gtest_xml_test_utils
import
gtest_xml_test_utils
GTEST_OUTPUT_SUBDIR
=
"xml_outfiles"
GTEST_OUTPUT_SUBDIR
=
"xml_outfiles"
GTEST_OUTPUT_1_TEST
=
"gtest_xml_outfile1_test_"
GTEST_OUTPUT_1_TEST
=
"gtest_xml_outfile1_test_"
GTEST_OUTPUT_2_TEST
=
"gtest_xml_outfile2_test_"
GTEST_OUTPUT_2_TEST
=
"gtest_xml_outfile2_test_"
...
...
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