Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
514265c4
Commit
514265c4
authored
Nov 22, 2008
by
vladlosev
Browse files
Fixed two of the failing tests mentioned in issue 9
parent
d4e57d12
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
9 deletions
+34
-9
test/gtest_test_utils.py
test/gtest_test_utils.py
+25
-0
test/gtest_xml_outfiles_test.py
test/gtest_xml_outfiles_test.py
+4
-3
test/gtest_xml_output_unittest.py
test/gtest_xml_output_unittest.py
+5
-6
No files found.
test/gtest_test_utils.py
View file @
514265c4
...
...
@@ -116,6 +116,31 @@ def GetExitStatus(exit_code):
return
-
1
def
RunCommandSuppressOutput
(
command
,
working_dir
=
None
):
"""Changes into a specified directory, if provided, and executes a command.
Restores the old directory afterwards.
Args:
command: A command to run.
working_dir: A directory to change into.
"""
old_dir
=
None
try
:
if
working_dir
is
not
None
:
old_dir
=
os
.
getcwd
()
os
.
chdir
(
working_dir
)
f
=
os
.
popen
(
command
,
'r'
)
f
.
read
()
ret_code
=
f
.
close
()
finally
:
if
old_dir
is
not
None
:
os
.
chdir
(
old_dir
)
if
ret_code
is
None
:
ret_code
=
0
return
ret_code
def
Main
():
"""Runs the unit test."""
...
...
test/gtest_xml_outfiles_test.py
View file @
514265c4
...
...
@@ -100,9 +100,10 @@ class GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase):
def
_TestOutFile
(
self
,
test_name
,
expected_xml
):
gtest_prog_path
=
os
.
path
.
join
(
gtest_test_utils
.
GetBuildDir
(),
test_name
)
command
=
"cd %s && %s --gtest_output=xml:%s &> /dev/null"
%
(
tempfile
.
mkdtemp
(),
gtest_prog_path
,
self
.
output_dir_
)
status
=
os
.
system
(
command
)
command
=
"%s --gtest_output=xml:%s"
%
(
gtest_prog_path
,
self
.
output_dir_
)
status
=
gtest_test_utils
.
RunCommandSuppressOutput
(
command
,
working_dir
=
tempfile
.
mkdtemp
())
self
.
assertEquals
(
0
,
gtest_test_utils
.
GetExitStatus
(
status
))
# TODO(wan@google.com): libtool causes the built test binary to be
...
...
test/gtest_xml_output_unittest.py
View file @
514265c4
...
...
@@ -131,9 +131,9 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
if
e
.
errno
!=
errno
.
ENOENT
:
raise
status
=
os
.
system
(
"cd %s && %s %s=xml &> /dev/null"
%
(
temp_dir
,
gtest_prog_path
,
GTEST_OUTPUT_FLAG
)
)
status
=
gtest_test_utils
.
RunCommandSuppressOutput
(
"%s %s=xml"
%
(
gtest_prog_path
,
GTEST_OUTPUT_FLAG
)
,
working_dir
=
temp_dir
)
self
.
assertEquals
(
0
,
gtest_test_utils
.
GetExitStatus
(
status
))
self
.
assert_
(
os
.
path
.
isfile
(
output_file
))
...
...
@@ -150,9 +150,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):
gtest_prog_path
=
os
.
path
.
join
(
gtest_test_utils
.
GetBuildDir
(),
gtest_prog_name
)
command
=
(
"%s %s=xml:%s &> /dev/null"
%
(
gtest_prog_path
,
GTEST_OUTPUT_FLAG
,
xml_path
))
status
=
os
.
system
(
command
)
command
=
(
"%s %s=xml:%s"
%
(
gtest_prog_path
,
GTEST_OUTPUT_FLAG
,
xml_path
))
status
=
gtest_test_utils
.
RunCommandSuppressOutput
(
command
)
if
os
.
WIFSIGNALED
(
status
):
signal
=
os
.
WTERMSIG
(
status
)
self
.
assert_
(
False
,
...
...
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