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
a28968d6
Commit
a28968d6
authored
Aug 01, 2018
by
Gennadiy Civil
Browse files
changes to googletest break on failure and googletest filter unittests
parent
d75922ca
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
31 deletions
+38
-31
googletest/test/BUILD.bazel
googletest/test/BUILD.bazel
+23
-16
googletest/test/googletest-break-on-failure-unittest.py
googletest/test/googletest-break-on-failure-unittest.py
+4
-4
googletest/test/googletest-break-on-failure-unittest_.cc
googletest/test/googletest-break-on-failure-unittest_.cc
+0
-0
googletest/test/googletest-filter-unittest.py
googletest/test/googletest-filter-unittest.py
+6
-6
googletest/test/googletest-filter-unittest_.cc
googletest/test/googletest-filter-unittest_.cc
+0
-0
googletest/test/googletest-throw-on-failure-test.py
googletest/test/googletest-throw-on-failure-test.py
+4
-4
googletest/test/googletest-throw-on-failure-test_.cc
googletest/test/googletest-throw-on-failure-test_.cc
+1
-1
No files found.
googletest/test/BUILD.bazel
View file @
a28968d6
...
@@ -227,35 +227,39 @@ py_test(
...
@@ -227,35 +227,39 @@ py_test(
)
)
cc_binary
(
cc_binary
(
name
=
"gtest
_
filter
_
unittest_"
,
name
=
"g
oogle
test
-
filter
-
unittest_"
,
testonly
=
1
,
testonly
=
1
,
srcs
=
[
"gtest
_
filter
_
unittest_.cc"
],
srcs
=
[
"g
oogle
test
-
filter
-
unittest_.cc"
],
deps
=
[
"//:gtest"
],
deps
=
[
"//:gtest"
],
)
)
py_test
(
py_test
(
name
=
"gtest
_
filter
_
unittest"
,
name
=
"g
oogle
test
-
filter
-
unittest"
,
size
=
"
small
"
,
size
=
"
medium
"
,
srcs
=
[
"gtest
_
filter
_
unittest.py"
],
srcs
=
[
"g
oogle
test
-
filter
-
unittest.py"
],
data
=
[
":gtest
_
filter
_
unittest_"
],
data
=
[
":g
oogle
test
-
filter
-
unittest_"
],
deps
=
[
":gtest_test_utils"
],
deps
=
[
":gtest_test_utils"
],
)
)
cc_binary
(
cc_binary
(
name
=
"gtest
_
break
_
on
_
failure
_
unittest_"
,
name
=
"g
oogle
test
-
break
-
on
-
failure
-
unittest_"
,
testonly
=
1
,
testonly
=
1
,
srcs
=
[
"gtest
_
break
_
on
_
failure
_
unittest_.cc"
],
srcs
=
[
"g
oogle
test
-
break
-
on
-
failure
-
unittest_.cc"
],
deps
=
[
"//:gtest"
],
deps
=
[
"//:gtest"
],
)
)
py_test
(
py_test
(
name
=
"gtest
_
break
_
on
_
failure
_
unittest"
,
name
=
"g
oogle
test
-
break
-
on
-
failure
-
unittest"
,
size
=
"small"
,
size
=
"small"
,
srcs
=
[
"gtest
_
break
_
on
_
failure
_
unittest.py"
],
srcs
=
[
"g
oogle
test
-
break
-
on
-
failure
-
unittest.py"
],
data
=
[
":gtest
_
break
_
on
_
failure
_
unittest_"
],
data
=
[
":g
oogle
test
-
break
-
on
-
failure
-
unittest_"
],
deps
=
[
":gtest_test_utils"
],
deps
=
[
":gtest_test_utils"
],
)
)
cc_test
(
cc_test
(
name
=
"gtest_assert_by_exception_test"
,
name
=
"gtest_assert_by_exception_test"
,
size
=
"small"
,
size
=
"small"
,
...
@@ -263,21 +267,24 @@ cc_test(
...
@@ -263,21 +267,24 @@ cc_test(
deps
=
[
"//:gtest"
],
deps
=
[
"//:gtest"
],
)
)
cc_binary
(
cc_binary
(
name
=
"gtest
_
throw
_
on
_
failure
_
test_"
,
name
=
"g
oogle
test
-
throw
-
on
-
failure
-
test_"
,
testonly
=
1
,
testonly
=
1
,
srcs
=
[
"gtest
_
throw
_
on
_
failure
_
test_.cc"
],
srcs
=
[
"g
oogle
test
-
throw
-
on
-
failure
-
test_.cc"
],
deps
=
[
"//:gtest"
],
deps
=
[
"//:gtest"
],
)
)
py_test
(
py_test
(
name
=
"gtest
_
throw
_
on
_
failure
_
test"
,
name
=
"g
oogle
test
-
throw
-
on
-
failure
-
test"
,
size
=
"small"
,
size
=
"small"
,
srcs
=
[
"gtest
_
throw
_
on
_
failure
_
test.py"
],
srcs
=
[
"g
oogle
test
-
throw
-
on
-
failure
-
test.py"
],
data
=
[
":gtest
_
throw
_
on
_
failure
_
test_"
],
data
=
[
":g
oogle
test
-
throw
-
on
-
failure
-
test_"
],
deps
=
[
":gtest_test_utils"
],
deps
=
[
":gtest_test_utils"
],
)
)
cc_binary
(
cc_binary
(
name
=
"gtest_list_tests_unittest_"
,
name
=
"gtest_list_tests_unittest_"
,
testonly
=
1
,
testonly
=
1
,
...
...
googletest/test/gtest
_
break
_
on
_
failure
_
unittest.py
→
googletest/test/g
oogle
test
-
break
-
on
-
failure
-
unittest.py
View file @
a28968d6
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
A user can ask Google Test to seg-fault when an assertion fails, using
A user can ask Google Test to seg-fault when an assertion fails, using
either the GTEST_BREAK_ON_FAILURE environment variable or the
either the GTEST_BREAK_ON_FAILURE environment variable or the
--gtest_break_on_failure flag. This script tests such functionality
--gtest_break_on_failure flag. This script tests such functionality
by invoking gtest
_
break
_
on
_
failure
_
unittest_ (a program written with
by invoking g
oogle
test
-
break
-
on
-
failure
-
unittest_ (a program written with
Google Test) with different environments and command line flags.
Google Test) with different environments and command line flags.
"""
"""
...
@@ -59,9 +59,9 @@ THROW_ON_FAILURE_ENV_VAR = 'GTEST_THROW_ON_FAILURE'
...
@@ -59,9 +59,9 @@ THROW_ON_FAILURE_ENV_VAR = 'GTEST_THROW_ON_FAILURE'
# The environment variable for enabling/disabling the catch-exceptions mode.
# The environment variable for enabling/disabling the catch-exceptions mode.
CATCH_EXCEPTIONS_ENV_VAR
=
'GTEST_CATCH_EXCEPTIONS'
CATCH_EXCEPTIONS_ENV_VAR
=
'GTEST_CATCH_EXCEPTIONS'
# Path to the gtest
_
break
_
on
_
failure
_
unittest_ program.
# Path to the g
oogle
test
-
break
-
on
-
failure
-
unittest_ program.
EXE_PATH
=
gtest_test_utils
.
GetTestExecutablePath
(
EXE_PATH
=
gtest_test_utils
.
GetTestExecutablePath
(
'gtest
_
break
_
on
_
failure
_
unittest_'
)
'g
oogle
test
-
break
-
on
-
failure
-
unittest_'
)
environ
=
gtest_test_utils
.
environ
environ
=
gtest_test_utils
.
environ
...
@@ -95,7 +95,7 @@ class GTestBreakOnFailureUnitTest(gtest_test_utils.TestCase):
...
@@ -95,7 +95,7 @@ class GTestBreakOnFailureUnitTest(gtest_test_utils.TestCase):
"""
"""
def
RunAndVerify
(
self
,
env_var_value
,
flag_value
,
expect_seg_fault
):
def
RunAndVerify
(
self
,
env_var_value
,
flag_value
,
expect_seg_fault
):
"""Runs gtest
_
break
_
on
_
failure
_
unittest_ and verifies that it does
"""Runs g
oogle
test
-
break
-
on
-
failure
-
unittest_ and verifies that it does
(or does not) have a seg-fault.
(or does not) have a seg-fault.
Args:
Args:
...
...
googletest/test/gtest
_
break
_
on
_
failure
_
unittest_.cc
→
googletest/test/g
oogle
test
-
break
-
on
-
failure
-
unittest_.cc
View file @
a28968d6
File moved
googletest/test/gtest
_
filter
_
unittest.py
→
googletest/test/g
oogle
test
-
filter
-
unittest.py
View file @
a28968d6
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
A user can specify which test(s) in a Google Test program to run via either
A user can specify which test(s) in a Google Test program to run via either
the GTEST_FILTER environment variable or the --gtest_filter flag.
the GTEST_FILTER environment variable or the --gtest_filter flag.
This script tests such functionality by invoking
This script tests such functionality by invoking
gtest
_
filter
_
unittest_ (a program written with Google Test) with different
g
oogle
test
-
filter
-
unittest_ (a program written with Google Test) with different
environments and command line flags.
environments and command line flags.
Note that test sharding may also influence which tests are filtered. Therefore,
Note that test sharding may also influence which tests are filtered. Therefore,
...
@@ -100,8 +100,8 @@ FILTER_FLAG = 'gtest_filter'
...
@@ -100,8 +100,8 @@ FILTER_FLAG = 'gtest_filter'
# The command line flag for including disabled tests.
# The command line flag for including disabled tests.
ALSO_RUN_DISABLED_TESTS_FLAG
=
'gtest_also_run_disabled_tests'
ALSO_RUN_DISABLED_TESTS_FLAG
=
'gtest_also_run_disabled_tests'
# Command to run the gtest
_
filter
_
unittest_ program.
# Command to run the g
oogle
test
-
filter
-
unittest_ program.
COMMAND
=
gtest_test_utils
.
GetTestExecutablePath
(
'gtest
_
filter
_
unittest_'
)
COMMAND
=
gtest_test_utils
.
GetTestExecutablePath
(
'g
oogle
test
-
filter
-
unittest_'
)
# Regex for determining whether parameterized tests are enabled in the binary.
# Regex for determining whether parameterized tests are enabled in the binary.
PARAM_TEST_REGEX
=
re
.
compile
(
r
'/ParamTest'
)
PARAM_TEST_REGEX
=
re
.
compile
(
r
'/ParamTest'
)
...
@@ -120,7 +120,7 @@ LIST_TESTS_FLAG = '--gtest_list_tests'
...
@@ -120,7 +120,7 @@ LIST_TESTS_FLAG = '--gtest_list_tests'
SUPPORTS_DEATH_TESTS
=
'HasDeathTest'
in
gtest_test_utils
.
Subprocess
(
SUPPORTS_DEATH_TESTS
=
'HasDeathTest'
in
gtest_test_utils
.
Subprocess
(
[
COMMAND
,
LIST_TESTS_FLAG
]).
output
[
COMMAND
,
LIST_TESTS_FLAG
]).
output
# Full names of all tests in gtest
_
filter
_
unittests_.
# Full names of all tests in g
oogle
test
-
filter
-
unittests_.
PARAM_TESTS
=
[
PARAM_TESTS
=
[
'SeqP/ParamTest.TestX/0'
,
'SeqP/ParamTest.TestX/0'
,
'SeqP/ParamTest.TestX/1'
,
'SeqP/ParamTest.TestX/1'
,
...
@@ -292,7 +292,7 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
...
@@ -292,7 +292,7 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
args
=
None
,
check_exit_0
=
False
):
args
=
None
,
check_exit_0
=
False
):
"""Checks that binary runs correct tests for the given filter and shard.
"""Checks that binary runs correct tests for the given filter and shard.
Runs all shards of gtest
_
filter
_
unittest_ with the given filter, and
Runs all shards of g
oogle
test
-
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, .
If check_exit_0, .
...
@@ -330,7 +330,7 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
...
@@ -330,7 +330,7 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
def
RunAndVerifyAllowingDisabled
(
self
,
gtest_filter
,
tests_to_run
):
def
RunAndVerifyAllowingDisabled
(
self
,
gtest_filter
,
tests_to_run
):
"""Checks that the binary runs correct set of tests for the given filter.
"""Checks that the binary runs correct set of tests for the given filter.
Runs gtest
_
filter
_
unittest_ with the given filter, and enables
Runs g
oogle
test
-
filter
-
unittest_ with the given filter, and enables
disabled tests. Verifies that the right set of tests were run.
disabled tests. Verifies that the right set of tests were run.
Args:
Args:
...
...
googletest/test/gtest
_
filter
_
unittest_.cc
→
googletest/test/g
oogle
test
-
filter
-
unittest_.cc
View file @
a28968d6
File moved
googletest/test/gtest
_
throw
_
on
_
failure
_
test.py
→
googletest/test/g
oogle
test
-
throw
-
on
-
failure
-
test.py
View file @
a28968d6
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
"""Tests Google Test's throw-on-failure mode with exceptions disabled.
"""Tests Google Test's throw-on-failure mode with exceptions disabled.
This script invokes gtest
_
throw
_
on
_
failure
_
test_ (a program written with
This script invokes g
oogle
test
-
throw
-
on
-
failure
-
test_ (a program written with
Google Test) with different environments and command line flags.
Google Test) with different environments and command line flags.
"""
"""
...
@@ -46,10 +46,10 @@ import gtest_test_utils
...
@@ -46,10 +46,10 @@ import gtest_test_utils
# The command line flag for enabling/disabling the throw-on-failure mode.
# The command line flag for enabling/disabling the throw-on-failure mode.
THROW_ON_FAILURE
=
'gtest_throw_on_failure'
THROW_ON_FAILURE
=
'gtest_throw_on_failure'
# Path to the gtest
_
throw
_
on
_
failure
_
test_ program, compiled with
# Path to the g
oogle
test
-
throw
-
on
-
failure
-
test_ program, compiled with
# exceptions disabled.
# exceptions disabled.
EXE_PATH
=
gtest_test_utils
.
GetTestExecutablePath
(
EXE_PATH
=
gtest_test_utils
.
GetTestExecutablePath
(
'gtest
_
throw
_
on
_
failure
_
test_'
)
'g
oogle
test
-
throw
-
on
-
failure
-
test_'
)
# Utilities.
# Utilities.
...
@@ -81,7 +81,7 @@ class ThrowOnFailureTest(gtest_test_utils.TestCase):
...
@@ -81,7 +81,7 @@ class ThrowOnFailureTest(gtest_test_utils.TestCase):
"""Tests the throw-on-failure mode."""
"""Tests the throw-on-failure mode."""
def
RunAndVerify
(
self
,
env_var_value
,
flag_value
,
should_fail
):
def
RunAndVerify
(
self
,
env_var_value
,
flag_value
,
should_fail
):
"""Runs gtest
_
throw
_
on
_
failure
_
test_ and verifies that it does
"""Runs g
oogle
test
-
throw
-
on
-
failure
-
test_ and verifies that it does
(or does not) exit with a non-zero code.
(or does not) exit with a non-zero code.
Args:
Args:
...
...
googletest/test/gtest
_
throw
_
on
_
failure
_
test_.cc
→
googletest/test/g
oogle
test
-
throw
-
on
-
failure
-
test_.cc
View file @
a28968d6
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
// Tests Google Test's throw-on-failure mode with exceptions disabled.
// Tests Google Test's throw-on-failure mode with exceptions disabled.
//
//
// This program must be compiled with exceptions disabled. It will be
// This program must be compiled with exceptions disabled. It will be
// invoked by gtest
_
throw
_
on
_
failure
_
test.py, and is expected to exit
// invoked by g
oogle
test
-
throw
-
on
-
failure
-
test.py, and is expected to exit
// with non-zero in the throw-on-failure mode or 0 otherwise.
// with non-zero in the throw-on-failure mode or 0 otherwise.
#include "gtest/gtest.h"
#include "gtest/gtest.h"
...
...
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