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
8dea630e
Commit
8dea630e
authored
Aug 01, 2018
by
Gennadiy Civil
Browse files
various changes to tests
parent
421f527d
Changes
14
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
334 additions
and
797 deletions
+334
-797
googletest/test/BUILD.bazel
googletest/test/BUILD.bazel
+49
-7
googletest/test/googletest-death-test_ex_test.cc
googletest/test/googletest-death-test_ex_test.cc
+1
-1
googletest/test/googletest-param-test-invalid-name1-test.py
googletest/test/googletest-param-test-invalid-name1-test.py
+72
-0
googletest/test/googletest-param-test-invalid-name1-test_.cc
googletest/test/googletest-param-test-invalid-name1-test_.cc
+16
-8
googletest/test/googletest-param-test-invalid-name2-test.py
googletest/test/googletest-param-test-invalid-name2-test.py
+71
-0
googletest/test/googletest-param-test-invalid-name2-test_.cc
googletest/test/googletest-param-test-invalid-name2-test_.cc
+56
-0
googletest/test/googletest-param-test-test.cc
googletest/test/googletest-param-test-test.cc
+1
-1
googletest/test/googletest-param-test-test.h
googletest/test/googletest-param-test-test.h
+0
-0
googletest/test/googletest-param-test2-test.cc
googletest/test/googletest-param-test2-test.cc
+1
-1
googletest/test/googletest-test-part-test.cc
googletest/test/googletest-test-part-test.cc
+0
-0
googletest/test/googletest-test2_test.cc
googletest/test/googletest-test2_test.cc
+61
-0
googletest/test/gtest_all_test.cc
googletest/test/gtest_all_test.cc
+6
-6
googletest/test/gtest_json_outfiles_test.py
googletest/test/gtest_json_outfiles_test.py
+0
-162
googletest/test/gtest_json_output_unittest.py
googletest/test/gtest_json_output_unittest.py
+0
-611
No files found.
googletest/test/BUILD.bazel
View file @
8dea630e
...
...
@@ -79,6 +79,11 @@ cc_test(
"googletest-list-tests-unittest_.cc"
,
"googletest-shuffle-test_.cc"
,
"googletest-uninitialized-test_.cc"
,
"googletest-death-test_ex_test.cc"
,
"googletest-param-test-test"
,
"googletest-throw-on-failure-test_.cc"
,
"googletest-param-test-invalid-name1-test_.cc"
,
"googletest-param-test-invalid-name2-test_.cc"
,
],
)
+
select
({
...
...
@@ -145,16 +150,14 @@ cc_test(
)
cc_test
(
name
=
"gtest-param-test
_
test"
,
name
=
"g
oogle
test-param-test
-
test"
,
size
=
"small"
,
srcs
=
[
"gtest-param-test2_test.cc"
,
"gtest-param-test_test.cc"
,
"gtest-param-test_test.h"
,
],
deps
=
[
"//:gtest"
,
"googletest-param-test-test.cc"
,
"googletest-param-test-test.h"
,
"googletest-param-test2-test.cc"
,
],
deps
=
[
"//:gtest"
],
)
cc_test
(
...
...
@@ -483,3 +486,42 @@ py_test(
}),
deps
=
[
":gtest_test_utils"
],
)
# Verifies interaction of death tests and exceptions.
cc_test
(
name
=
"googletest-death-test_ex_catch_test"
,
size
=
"medium"
,
srcs
=
[
"googletest-death-test_ex_test.cc"
],
copts
=
[
"-fexceptions"
],
defines
=
[
"GTEST_ENABLE_CATCH_EXCEPTIONS_=1"
],
deps
=
[
"//:gtest"
],
)
cc_binary
(
name
=
"googletest-param-test-invalid-name1-test_"
,
testonly
=
1
,
srcs
=
[
"googletest-param-test-invalid-name1-test_.cc"
],
deps
=
[
"//:gtest"
],
)
cc_binary
(
name
=
"googletest-param-test-invalid-name2-test_"
,
testonly
=
1
,
srcs
=
[
"googletest-param-test-invalid-name2-test_.cc"
],
deps
=
[
"//:gtest"
],
)
py_test
(
name
=
"googletest-param-test-invalid-name1-test"
,
size
=
"small"
,
srcs
=
[
"googletest-param-test-invalid-name1-test.py"
],
data
=
[
":googletest-param-test-invalid-name1-test_"
],
deps
=
[
":gtest_test_utils"
],
)
py_test
(
name
=
"googletest-param-test-invalid-name2-test"
,
size
=
"small"
,
srcs
=
[
"googletest-param-test-invalid-name2-test.py"
],
data
=
[
":googletest-param-test-invalid-name2-test_"
],
deps
=
[
":gtest_test_utils"
],
)
googletest/test/gtest-death-test_ex_test.cc
→
googletest/test/g
oogle
test-death-test_ex_test.cc
View file @
8dea630e
...
...
@@ -69,7 +69,7 @@ TEST(CxxExceptionDeathTest, PrintsMessageForStdExceptions) {
"exceptional message"
);
// Verifies that the location is mentioned in the failure text.
EXPECT_NONFATAL_FAILURE
(
EXPECT_DEATH
(
throw
TestException
(),
""
),
"gtest-death-test_ex_test.cc"
);
"g
oogle
test-death-test_ex_test.cc"
);
}
# endif // GTEST_HAS_EXCEPTIONS
...
...
googletest/test/googletest-param-test-invalid-name1-test.py
0 → 100644
View file @
8dea630e
#!/usr/bin/env python
#
# Copyright 2015 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Verifies that Google Test warns the user when not initialized properly."""
__author__
=
'jmadill@google.com (Jamie Madill)'
import
os
IS_LINUX
=
os
.
name
==
'posix'
and
os
.
uname
()[
0
]
==
'Linux'
if
IS_LINUX
:
import
gtest_test_utils
else
:
import
gtest_test_utils
binary_name
=
'googletest-param-test-invalid-name1-test_'
COMMAND
=
gtest_test_utils
.
GetTestExecutablePath
(
binary_name
)
def
Assert
(
condition
):
if
not
condition
:
raise
AssertionError
def
TestExitCodeAndOutput
(
command
):
"""Runs the given command and verifies its exit code and output."""
err
=
(
'Parameterized test name
\'
"InvalidWithQuotes"
\'
is invalid'
)
p
=
gtest_test_utils
.
Subprocess
(
command
)
Assert
(
p
.
terminated_by_signal
)
# Verify the output message contains appropriate output
Assert
(
err
in
p
.
output
)
class
GTestParamTestInvalidName1Test
(
gtest_test_utils
.
TestCase
):
def
testExitCodeAndOutput
(
self
):
TestExitCodeAndOutput
(
COMMAND
)
if
__name__
==
'__main__'
:
gtest_test_utils
.
Main
()
googletest/test/g
test_uninitialized_
test_.cc
→
googletest/test/g
oogletest-param-test-invalid-name1-
test_.cc
View file @
8dea630e
// Copyright 20
08
, Google Inc.
// Copyright 20
15
, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
...
...
@@ -27,17 +27,25 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author:
wan
@google.com (
Zhanyong Wan
)
// Author:
jmadill
@google.com (
Jamie Madill
)
#include "gtest/gtest.h"
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.
namespace
{
class
DummyTest
:
public
::
testing
::
TestWithParam
<
const
char
*>
{};
TEST_P
(
DummyTest
,
Dummy
)
{
}
int
main
()
{
INSTANTIATE_TEST_CASE_P
(
InvalidTestName
,
DummyTest
,
::
testing
::
Values
(
"InvalidWithQuotes"
),
::
testing
::
PrintToStringParamName
());
}
// namespace
int
main
(
int
argc
,
char
*
argv
[])
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
googletest/test/googletest-param-test-invalid-name2-test.py
0 → 100644
View file @
8dea630e
#!/usr/bin/env python
#
# Copyright 2015 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Verifies that Google Test warns the user when not initialized properly."""
__author__
=
'jmadill@google.com (Jamie Madill)'
import
os
IS_LINUX
=
os
.
name
==
'posix'
and
os
.
uname
()[
0
]
==
'Linux'
if
IS_LINUX
:
import
gtest_test_utils
else
:
import
gtest_test_utils
binary_name
=
'googletest-param-test-invalid-name2-test_'
COMMAND
=
gtest_test_utils
.
GetTestExecutablePath
(
binary_name
)
def
Assert
(
condition
):
if
not
condition
:
raise
AssertionError
def
TestExitCodeAndOutput
(
command
):
"""Runs the given command and verifies its exit code and output."""
err
=
(
'Duplicate parameterized test name
\'
a
\'
'
)
p
=
gtest_test_utils
.
Subprocess
(
command
)
Assert
(
p
.
terminated_by_signal
)
# Check for appropriate output
Assert
(
err
in
p
.
output
)
class
GTestParamTestInvalidName2Test
(
gtest_test_utils
.
TestCase
):
def
testExitCodeAndOutput
(
self
):
TestExitCodeAndOutput
(
COMMAND
)
if
__name__
==
'__main__'
:
gtest_test_utils
.
Main
()
googletest/test/googletest-param-test-invalid-name2-test_.cc
0 → 100644
View file @
8dea630e
// Copyright 2015, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: jmadill@google.com (Jamie Madill)
#include "gtest/gtest.h"
namespace
{
class
DummyTest
:
public
::
testing
::
TestWithParam
<
const
char
*>
{};
std
::
string
StringParamTestSuffix
(
const
testing
::
TestParamInfo
<
const
char
*>&
info
)
{
return
std
::
string
(
info
.
param
);
}
TEST_P
(
DummyTest
,
Dummy
)
{
}
INSTANTIATE_TEST_CASE_P
(
DuplicateTestNames
,
DummyTest
,
::
testing
::
Values
(
"a"
,
"b"
,
"a"
,
"c"
),
StringParamTestSuffix
);
}
// namespace
int
main
(
int
argc
,
char
*
argv
[])
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
googletest/test/gtest-param-test
_
test.cc
→
googletest/test/g
oogle
test-param-test
-
test.cc
View file @
8dea630e
...
...
@@ -43,7 +43,7 @@
# include <vector>
# include "src/gtest-internal-inl.h" // for UnitTestOptions
# include "test/gtest-param-test
_
test.h"
# include "test/g
oogle
test-param-test
-
test.h"
using
::
std
::
vector
;
using
::
std
::
sort
;
...
...
googletest/test/gtest-param-test
_
test.h
→
googletest/test/g
oogle
test-param-test
-
test.h
View file @
8dea630e
File moved
googletest/test/gtest-param-test2
_
test.cc
→
googletest/test/g
oogle
test-param-test2
-
test.cc
View file @
8dea630e
...
...
@@ -33,7 +33,7 @@
// Google Test work.
#include "gtest/gtest.h"
#include "gtest-param-test
_
test.h"
#include "g
oogle
test-param-test
-
test.h"
using
::
testing
::
Values
;
using
::
testing
::
internal
::
ParamGenerator
;
...
...
googletest/test/gtest-test-part
_
test.cc
→
googletest/test/g
oogle
test-test-part
-
test.cc
View file @
8dea630e
File moved
googletest/test/googletest-test2_test.cc
0 → 100644
View file @
8dea630e
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vladl@google.com (Vlad Losev)
//
// Tests for Google Test itself. This verifies that the basic constructs of
// Google Test work.
#include "gtest/gtest.h"
#include "googletest-param-test-test.h"
using
::
testing
::
Values
;
using
::
testing
::
internal
::
ParamGenerator
;
// Tests that generators defined in a different translation unit
// are functional. The test using extern_gen_2 is defined
// in gtest-param-test_test.cc.
ParamGenerator
<
int
>
extern_gen_2
=
Values
(
33
);
// Tests that a parameterized test case can be defined in one translation unit
// and instantiated in another. The test is defined in gtest-param-test_test.cc
// and ExternalInstantiationTest fixture class is defined in
// gtest-param-test_test.h.
INSTANTIATE_TEST_CASE_P
(
MultiplesOf33
,
ExternalInstantiationTest
,
Values
(
33
,
66
));
// Tests that a parameterized test case can be instantiated
// in multiple translation units. Another instantiation is defined
// in gtest-param-test_test.cc and InstantiationInMultipleTranslaionUnitsTest
// fixture is defined in gtest-param-test_test.h
INSTANTIATE_TEST_CASE_P
(
Sequence2
,
InstantiationInMultipleTranslaionUnitsTest
,
Values
(
42
*
3
,
42
*
4
,
42
*
5
));
googletest/test/gtest_all_test.cc
View file @
8dea630e
...
...
@@ -33,14 +33,14 @@
//
// Sometimes it's desirable to build most of Google Test's own tests
// by compiling a single file. This file serves this purpose.
#include "gtest-filepath
_
test.cc"
#include "gtest-linked
_
ptr
_
test.cc"
#include "gtest-message
_
test.cc"
#include "gtest-options
_
test.cc"
#include "gtest-port
_
test.cc"
#include "g
oogle
test-filepath
-
test.cc"
#include "g
oogle
test-linked
-
ptr
-
test.cc"
#include "g
oogle
test-message
-
test.cc"
#include "g
oogle
test-options
-
test.cc"
#include "g
oogle
test-port
-
test.cc"
#include "gtest_pred_impl_unittest.cc"
#include "gtest_prod_test.cc"
#include "gtest-test-part
_
test.cc"
#include "g
oogle
test-test-part
-
test.cc"
#include "gtest-typed-test_test.cc"
#include "gtest-typed-test2_test.cc"
#include "gtest_unittest.cc"
...
...
googletest/test/gtest_json_outfiles_test.py
deleted
100644 → 0
View file @
421f527d
#!/usr/bin/env python
# Copyright 2018, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Unit test for the gtest_json_output module."""
import
json
import
os
import
gtest_json_test_utils
import
gtest_test_utils
GTEST_OUTPUT_SUBDIR
=
'json_outfiles'
GTEST_OUTPUT_1_TEST
=
'gtest_xml_outfile1_test_'
GTEST_OUTPUT_2_TEST
=
'gtest_xml_outfile2_test_'
EXPECTED_1
=
{
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'name'
:
u
'AllTests'
,
u
'testsuites'
:
[{
u
'name'
:
u
'PropertyOne'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'TestSomeProperties'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'PropertyOne'
,
u
'SetUpProp'
:
u
'1'
,
u
'TestSomeProperty'
:
u
'1'
,
u
'TearDownProp'
:
u
'1'
,
}],
}],
}
EXPECTED_2
=
{
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'timestamp'
:
u
'*'
,
u
'name'
:
u
'AllTests'
,
u
'testsuites'
:
[{
u
'name'
:
u
'PropertyTwo'
,
u
'tests'
:
1
,
u
'failures'
:
0
,
u
'disabled'
:
0
,
u
'errors'
:
0
,
u
'time'
:
u
'*'
,
u
'testsuite'
:
[{
u
'name'
:
u
'TestSomeProperties'
,
u
'status'
:
u
'RUN'
,
u
'time'
:
u
'*'
,
u
'classname'
:
u
'PropertyTwo'
,
u
'SetUpProp'
:
u
'2'
,
u
'TestSomeProperty'
:
u
'2'
,
u
'TearDownProp'
:
u
'2'
,
}],
}],
}
class
GTestJsonOutFilesTest
(
gtest_test_utils
.
TestCase
):
"""Unit test for Google Test's JSON output functionality."""
def
setUp
(
self
):
# We want the trailing '/' that the last "" provides in os.path.join, for
# telling Google Test to create an output directory instead of a single file
# for xml output.
self
.
output_dir_
=
os
.
path
.
join
(
gtest_test_utils
.
GetTempDir
(),
GTEST_OUTPUT_SUBDIR
,
''
)
self
.
DeleteFilesAndDir
()
def
tearDown
(
self
):
self
.
DeleteFilesAndDir
()
def
DeleteFilesAndDir
(
self
):
try
:
os
.
remove
(
os
.
path
.
join
(
self
.
output_dir_
,
GTEST_OUTPUT_1_TEST
+
'.json'
))
except
os
.
error
:
pass
try
:
os
.
remove
(
os
.
path
.
join
(
self
.
output_dir_
,
GTEST_OUTPUT_2_TEST
+
'.json'
))
except
os
.
error
:
pass
try
:
os
.
rmdir
(
self
.
output_dir_
)
except
os
.
error
:
pass
def
testOutfile1
(
self
):
self
.
_TestOutFile
(
GTEST_OUTPUT_1_TEST
,
EXPECTED_1
)
def
testOutfile2
(
self
):
self
.
_TestOutFile
(
GTEST_OUTPUT_2_TEST
,
EXPECTED_2
)
def
_TestOutFile
(
self
,
test_name
,
expected
):
gtest_prog_path
=
gtest_test_utils
.
GetTestExecutablePath
(
test_name
)
command
=
[
gtest_prog_path
,
'--gtest_output=json:%s'
%
self
.
output_dir_
]
p
=
gtest_test_utils
.
Subprocess
(
command
,
working_dir
=
gtest_test_utils
.
GetTempDir
())
self
.
assert_
(
p
.
exited
)
self
.
assertEquals
(
0
,
p
.
exit_code
)
# TODO(wan@google.com): libtool causes the built test binary to be
# named lt-gtest_xml_outfiles_test_ instead of
# gtest_xml_outfiles_test_. To account for this possibility, we
# allow both names in the following code. We should remove this
# hack when Chandler Carruth's libtool replacement tool is ready.
output_file_name1
=
test_name
+
'.json'
output_file1
=
os
.
path
.
join
(
self
.
output_dir_
,
output_file_name1
)
output_file_name2
=
'lt-'
+
output_file_name1
output_file2
=
os
.
path
.
join
(
self
.
output_dir_
,
output_file_name2
)
self
.
assert_
(
os
.
path
.
isfile
(
output_file1
)
or
os
.
path
.
isfile
(
output_file2
),
output_file1
)
if
os
.
path
.
isfile
(
output_file1
):
with
open
(
output_file1
)
as
f
:
actual
=
json
.
load
(
f
)
else
:
with
open
(
output_file2
)
as
f
:
actual
=
json
.
load
(
f
)
self
.
assertEqual
(
expected
,
gtest_json_test_utils
.
normalize
(
actual
))
if
__name__
==
'__main__'
:
os
.
environ
[
'GTEST_STACK_TRACE_DEPTH'
]
=
'0'
gtest_test_utils
.
Main
()
googletest/test/gtest_json_output_unittest.py
deleted
100644 → 0
View file @
421f527d
This diff is collapsed.
Click to expand it.
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