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
ff5ffd45
Commit
ff5ffd45
authored
Feb 01, 2016
by
Billy Donahue
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #688 from tamland/python3
Python 3 support
parents
a9b73f81
456fc2b5
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
36 additions
and
29 deletions
+36
-29
fuse_gtest_files.py
googletest/scripts/fuse_gtest_files.py
+18
-15
gtest_env_var_test.py
googletest/test/gtest_env_var_test.py
+2
-2
gtest_filter_unittest.py
googletest/test/gtest_filter_unittest.py
+8
-5
gtest_output_test.py
googletest/test/gtest_output_test.py
+1
-1
gtest_test_utils.py
googletest/test/gtest_test_utils.py
+1
-1
gtest_throw_on_failure_test.py
googletest/test/gtest_throw_on_failure_test.py
+1
-1
gtest_uninitialized_test.py
googletest/test/gtest_uninitialized_test.py
+2
-2
gtest_xml_output_unittest.py
googletest/test/gtest_xml_output_unittest.py
+2
-1
gtest_xml_test_utils.py
googletest/test/gtest_xml_test_utils.py
+1
-1
No files found.
googletest/scripts/fuse_gtest_files.py
View file @
ff5ffd45
...
@@ -60,7 +60,10 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
...
@@ -60,7 +60,10 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
import
os
import
os
import
re
import
re
import
sets
try
:
from
sets
import
Set
as
set
# For Python 2.3 compatibility
except
ImportError
:
pass
import
sys
import
sys
# We assume that this file is in the scripts/ directory in the Google
# We assume that this file is in the scripts/ directory in the Google
...
@@ -90,10 +93,10 @@ def VerifyFileExists(directory, relative_path):
...
@@ -90,10 +93,10 @@ def VerifyFileExists(directory, relative_path):
"""
"""
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
directory
,
relative_path
)):
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
directory
,
relative_path
)):
print
'ERROR: Cannot find
%
s in directory
%
s.'
%
(
relative_path
,
print
(
'ERROR: Cannot find
%
s in directory
%
s.'
%
(
relative_path
,
directory
)
directory
)
)
print
(
'Please either specify a valid project root directory '
print
(
'Please either specify a valid project root directory '
'or omit it on the command line.'
)
'or omit it on the command line.'
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
...
@@ -119,11 +122,11 @@ def VerifyOutputFile(output_dir, relative_path):
...
@@ -119,11 +122,11 @@ def VerifyOutputFile(output_dir, relative_path):
# TODO(wan@google.com): The following user-interaction doesn't
# TODO(wan@google.com): The following user-interaction doesn't
# work with automated processes. We should provide a way for the
# work with automated processes. We should provide a way for the
# Makefile to force overwriting the files.
# Makefile to force overwriting the files.
print
(
'
%
s already exists in directory
%
s - overwrite it? (y/N) '
%
print
(
'
%
s already exists in directory
%
s - overwrite it? (y/N) '
%
(
relative_path
,
output_dir
))
(
relative_path
,
output_dir
))
answer
=
sys
.
stdin
.
readline
()
.
strip
()
answer
=
sys
.
stdin
.
readline
()
.
strip
()
if
answer
not
in
[
'y'
,
'Y'
]:
if
answer
not
in
[
'y'
,
'Y'
]:
print
'ABORTED.'
print
(
'ABORTED.'
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
# Makes sure the directory holding the output file exists; creates
# Makes sure the directory holding the output file exists; creates
...
@@ -146,8 +149,8 @@ def ValidateOutputDir(output_dir):
...
@@ -146,8 +149,8 @@ def ValidateOutputDir(output_dir):
def
FuseGTestH
(
gtest_root
,
output_dir
):
def
FuseGTestH
(
gtest_root
,
output_dir
):
"""Scans folder gtest_root to generate gtest/gtest.h in output_dir."""
"""Scans folder gtest_root to generate gtest/gtest.h in output_dir."""
output_file
=
file
(
os
.
path
.
join
(
output_dir
,
GTEST_H_OUTPUT
),
'w'
)
output_file
=
open
(
os
.
path
.
join
(
output_dir
,
GTEST_H_OUTPUT
),
'w'
)
processed_files
=
set
s
.
Set
()
# Holds all gtest headers we've processed.
processed_files
=
set
()
# Holds all gtest headers we've processed.
def
ProcessFile
(
gtest_header_path
):
def
ProcessFile
(
gtest_header_path
):
"""Processes the given gtest header file."""
"""Processes the given gtest header file."""
...
@@ -159,7 +162,7 @@ def FuseGTestH(gtest_root, output_dir):
...
@@ -159,7 +162,7 @@ def FuseGTestH(gtest_root, output_dir):
processed_files
.
add
(
gtest_header_path
)
processed_files
.
add
(
gtest_header_path
)
# Reads each line in the given gtest header.
# Reads each line in the given gtest header.
for
line
in
file
(
os
.
path
.
join
(
gtest_root
,
gtest_header_path
),
'r'
):
for
line
in
open
(
os
.
path
.
join
(
gtest_root
,
gtest_header_path
),
'r'
):
m
=
INCLUDE_GTEST_FILE_REGEX
.
match
(
line
)
m
=
INCLUDE_GTEST_FILE_REGEX
.
match
(
line
)
if
m
:
if
m
:
# It's '#include "gtest/..."' - let's process it recursively.
# It's '#include "gtest/..."' - let's process it recursively.
...
@@ -175,7 +178,7 @@ def FuseGTestH(gtest_root, output_dir):
...
@@ -175,7 +178,7 @@ def FuseGTestH(gtest_root, output_dir):
def
FuseGTestAllCcToFile
(
gtest_root
,
output_file
):
def
FuseGTestAllCcToFile
(
gtest_root
,
output_file
):
"""Scans folder gtest_root to generate gtest/gtest-all.cc in output_file."""
"""Scans folder gtest_root to generate gtest/gtest-all.cc in output_file."""
processed_files
=
set
s
.
Set
()
processed_files
=
set
()
def
ProcessFile
(
gtest_source_file
):
def
ProcessFile
(
gtest_source_file
):
"""Processes the given gtest source file."""
"""Processes the given gtest source file."""
...
@@ -187,7 +190,7 @@ def FuseGTestAllCcToFile(gtest_root, output_file):
...
@@ -187,7 +190,7 @@ def FuseGTestAllCcToFile(gtest_root, output_file):
processed_files
.
add
(
gtest_source_file
)
processed_files
.
add
(
gtest_source_file
)
# Reads each line in the given gtest source file.
# Reads each line in the given gtest source file.
for
line
in
file
(
os
.
path
.
join
(
gtest_root
,
gtest_source_file
),
'r'
):
for
line
in
open
(
os
.
path
.
join
(
gtest_root
,
gtest_source_file
),
'r'
):
m
=
INCLUDE_GTEST_FILE_REGEX
.
match
(
line
)
m
=
INCLUDE_GTEST_FILE_REGEX
.
match
(
line
)
if
m
:
if
m
:
if
'include/'
+
m
.
group
(
1
)
==
GTEST_SPI_H_SEED
:
if
'include/'
+
m
.
group
(
1
)
==
GTEST_SPI_H_SEED
:
...
@@ -218,7 +221,7 @@ def FuseGTestAllCcToFile(gtest_root, output_file):
...
@@ -218,7 +221,7 @@ def FuseGTestAllCcToFile(gtest_root, output_file):
def
FuseGTestAllCc
(
gtest_root
,
output_dir
):
def
FuseGTestAllCc
(
gtest_root
,
output_dir
):
"""Scans folder gtest_root to generate gtest/gtest-all.cc in output_dir."""
"""Scans folder gtest_root to generate gtest/gtest-all.cc in output_dir."""
output_file
=
file
(
os
.
path
.
join
(
output_dir
,
GTEST_ALL_CC_OUTPUT
),
'w'
)
output_file
=
open
(
os
.
path
.
join
(
output_dir
,
GTEST_ALL_CC_OUTPUT
),
'w'
)
FuseGTestAllCcToFile
(
gtest_root
,
output_file
)
FuseGTestAllCcToFile
(
gtest_root
,
output_file
)
output_file
.
close
()
output_file
.
close
()
...
@@ -242,7 +245,7 @@ def main():
...
@@ -242,7 +245,7 @@ def main():
# fuse_gtest_files.py GTEST_ROOT_DIR OUTPUT_DIR
# fuse_gtest_files.py GTEST_ROOT_DIR OUTPUT_DIR
FuseGTest
(
sys
.
argv
[
1
],
sys
.
argv
[
2
])
FuseGTest
(
sys
.
argv
[
1
],
sys
.
argv
[
2
])
else
:
else
:
print
__doc__
print
(
__doc__
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
...
...
googletest/test/gtest_env_var_test.py
View file @
ff5ffd45
...
@@ -47,8 +47,8 @@ environ = os.environ.copy()
...
@@ -47,8 +47,8 @@ environ = os.environ.copy()
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_filter_unittest.py
View file @
ff5ffd45
...
@@ -44,7 +44,10 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
...
@@ -44,7 +44,10 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
import
os
import
os
import
re
import
re
import
sets
try
:
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
...
@@ -58,7 +61,7 @@ import gtest_test_utils
...
@@ -58,7 +61,7 @@ import gtest_test_utils
# 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'
]
=
''
os
.
environ
[
'EMPTY_VAR'
]
=
''
child
=
gtest_test_utils
.
Subprocess
(
child
=
gtest_test_utils
.
Subprocess
(
[
sys
.
executable
,
'-c'
,
'import os; print
\'
EMPTY_VAR
\'
in os.environ
'
])
[
sys
.
executable
,
'-c'
,
'import os; print
(
\'
EMPTY_VAR
\'
in os.environ)
'
])
CAN_PASS_EMPTY_ENV
=
eval
(
child
.
output
)
CAN_PASS_EMPTY_ENV
=
eval
(
child
.
output
)
...
@@ -71,7 +74,7 @@ CAN_PASS_EMPTY_ENV = eval(child.output)
...
@@ -71,7 +74,7 @@ CAN_PASS_EMPTY_ENV = eval(child.output)
os
.
environ
[
'UNSET_VAR'
]
=
'X'
os
.
environ
[
'UNSET_VAR'
]
=
'X'
del
os
.
environ
[
'UNSET_VAR'
]
del
os
.
environ
[
'UNSET_VAR'
]
child
=
gtest_test_utils
.
Subprocess
(
child
=
gtest_test_utils
.
Subprocess
(
[
sys
.
executable
,
'-c'
,
'import os; print
\'
UNSET_VAR
\'
not in os.environ
'
])
[
sys
.
executable
,
'-c'
,
'import os; print
(
\'
UNSET_VAR
\'
not in os.environ)
'
])
CAN_UNSET_ENV
=
eval
(
child
.
output
)
CAN_UNSET_ENV
=
eval
(
child
.
output
)
...
@@ -243,14 +246,14 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
...
@@ -243,14 +246,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
s
.
Set
(
set_var
),
sets
.
S
et
(
full_partition
))
self
.
assertEqual
(
set
(
set_var
),
s
et
(
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
s
.
Set
(
tests_to_run
)
-
sets
.
S
et
(
PARAM_TESTS
))
return
list
(
set
(
tests_to_run
)
-
s
et
(
PARAM_TESTS
))
else
:
else
:
return
tests_to_run
return
tests_to_run
...
...
googletest/test/gtest_output_test.py
View file @
ff5ffd45
...
@@ -279,7 +279,7 @@ class GTestOutputTest(gtest_test_utils.TestCase):
...
@@ -279,7 +279,7 @@ class GTestOutputTest(gtest_test_utils.TestCase):
def
testOutput
(
self
):
def
testOutput
(
self
):
output
=
GetOutputOfAllCommands
()
output
=
GetOutputOfAllCommands
()
golden_file
=
open
(
GOLDEN_PATH
,
'r
b
'
)
golden_file
=
open
(
GOLDEN_PATH
,
'r'
)
# 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
...
...
googletest/test/gtest_test_utils.py
View file @
ff5ffd45
...
@@ -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
)
print
>>
sys
.
stderr
,
message
sys
.
stdout
.
write
(
message
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
return
path
return
path
...
...
googletest/test/gtest_throw_on_failure_test.py
View file @
ff5ffd45
...
@@ -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 @
ff5ffd45
...
@@ -46,8 +46,8 @@ def Assert(condition):
...
@@ -46,8 +46,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_output_unittest.py
View file @
ff5ffd45
...
@@ -209,7 +209,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
...
@@ -209,7 +209,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
'gtest_no_test_unittest'
)
'gtest_no_test_unittest'
)
try
:
try
:
os
.
remove
(
output_file
)
os
.
remove
(
output_file
)
except
OSError
,
e
:
except
OSError
:
e
=
sys
.
exc_info
()[
1
]
if
e
.
errno
!=
errno
.
ENOENT
:
if
e
.
errno
!=
errno
.
ENOENT
:
raise
raise
...
...
googletest/test/gtest_xml_test_utils.py
View file @
ff5ffd45
...
@@ -101,7 +101,7 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
...
@@ -101,7 +101,7 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
self
.
assertEquals
(
self
.
assertEquals
(
len
(
expected_children
),
len
(
actual_children
),
len
(
expected_children
),
len
(
actual_children
),
'number of child elements differ in element '
+
actual_node
.
tagName
)
'number of child elements differ in element '
+
actual_node
.
tagName
)
for
child_id
,
child
in
expected_children
.
ite
rite
ms
():
for
child_id
,
child
in
expected_children
.
items
():
self
.
assert_
(
child_id
in
actual_children
,
self
.
assert_
(
child_id
in
actual_children
,
'<
%
s> is not in <
%
s> (in element
%
s)'
%
'<
%
s> is not in <
%
s> (in element
%
s)'
%
(
child_id
,
actual_children
,
actual_node
.
tagName
))
(
child_id
,
actual_children
,
actual_node
.
tagName
))
...
...
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