@ -42,6 +42,7 @@ we test that here also.
import os
import os
import re
import re
try :
try :
from sets import Set as set # For Python 2.3 compatibility
from sets import Set as set # For Python 2.3 compatibility
except ImportError :
except ImportError :
@ -60,7 +61,8 @@ CAN_PASS_EMPTY_ENV = False
if sys . executable :
if sys . executable :
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 )
@ -75,8 +77,8 @@ if sys.executable:
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 )
@ -84,7 +86,7 @@ if sys.executable:
# make sense on platforms that cannot pass empty env variables (Win32)
# make sense on platforms that cannot pass empty env variables (Win32)
# and on platforms that cannot unset variables (since we cannot tell
# and on platforms that cannot unset variables (since we cannot tell
# the difference between "" and NULL -- Borland and Solaris < 5.10)
# the difference between "" and NULL -- Borland and Solaris < 5.10)
CAN_TEST_EMPTY_FILTER = ( CAN_PASS_EMPTY_ENV and CAN_UNSET_ENV )
CAN_TEST_EMPTY_FILTER = CAN_PASS_EMPTY_ENV and CAN_UNSET_ENV
# The environment variable for specifying the test filters.
# The environment variable for specifying the test filters.
@ -121,8 +123,10 @@ DISABLED_BANNER_REGEX = re.compile(r'^\[\s*DISABLED\s*\] (.*)')
LIST_TESTS_FLAG = ' --gtest_list_tests '
LIST_TESTS_FLAG = ' --gtest_list_tests '
# Indicates whether Google Test supports death tests.
# Indicates whether Google Test supports death tests.
SUPPORTS_DEATH_TESTS = ' HasDeathTest ' in gtest_test_utils . Subprocess (
SUPPORTS_DEATH_TESTS = (
[ COMMAND , LIST_TESTS_FLAG ] ) . output
' HasDeathTest '
in gtest_test_utils . Subprocess ( [ COMMAND , LIST_TESTS_FLAG ] ) . output
)
# Full names of all tests in googletest-filter-unittests_.
# Full names of all tests in googletest-filter-unittests_.
PARAM_TESTS = [
PARAM_TESTS = [
@ -134,7 +138,7 @@ PARAM_TESTS = [
' SeqQ/ParamTest.TestX/1 ' ,
' SeqQ/ParamTest.TestX/1 ' ,
' SeqQ/ParamTest.TestY/0 ' ,
' SeqQ/ParamTest.TestY/0 ' ,
' SeqQ/ParamTest.TestY/1 ' ,
' SeqQ/ParamTest.TestY/1 ' ,
]
]
DISABLED_TESTS = [
DISABLED_TESTS = [
' BarTest.DISABLED_TestFour ' ,
' BarTest.DISABLED_TestFour ' ,
@ -143,29 +147,31 @@ DISABLED_TESTS = [
' DISABLED_FoobarTest.Test1 ' ,
' DISABLED_FoobarTest.Test1 ' ,
' DISABLED_FoobarTest.DISABLED_Test2 ' ,
' DISABLED_FoobarTest.DISABLED_Test2 ' ,
' DISABLED_FoobarbazTest.TestA ' ,
' DISABLED_FoobarbazTest.TestA ' ,
]
]
if SUPPORTS_DEATH_TESTS :
if SUPPORTS_DEATH_TESTS :
DEATH_TESTS = [
DEATH_TESTS = [
' HasDeathTest.Test1 ' ,
' HasDeathTest.Test1 ' ,
' HasDeathTest.Test2 ' ,
' HasDeathTest.Test2 ' ,
]
]
else :
else :
DEATH_TESTS = [ ]
DEATH_TESTS = [ ]
# All the non-disabled tests.
# All the non-disabled tests.
ACTIVE_TESTS = [
ACTIVE_TESTS = (
' FooTest.Abc ' ,
[
' FooTest.Xyz ' ,
' FooTest.Abc ' ,
' FooTest.Xyz ' ,
' BarTest.TestOne ' ,
' BarTest.TestOne ' ,
' BarTest.TestTwo ' ,
' BarTest.TestTwo ' ,
' BarTest.TestThree ' ,
' BarTest.TestThree ' ,
' BazTest.TestOne ' ,
' BazTest.TestOne ' ,
' BazTest.TestA ' ,
' BazTest.TestA ' ,
' BazTest.TestB ' ,
' BazTest.TestB ' ,
]
] + DEATH_TESTS + PARAM_TESTS
+ DEATH_TESTS
+ PARAM_TESTS
)
param_tests_present = None
param_tests_present = None
@ -183,14 +189,15 @@ def SetEnvVar(env_var, value):
del environ [ env_var ]
del environ [ env_var ]
def RunAndReturnOutput ( args = None ) :
def RunAndReturnOutput ( args = None ) :
""" Runs the test program and returns its output. """
""" Runs the test program and returns its output. """
return gtest_test_utils . Subprocess ( [ COMMAND ] + ( args or [ ] ) ,
return gtest_test_utils . Subprocess (
env = environ ) . output
[ COMMAND ] + ( args or [ ] ) , env = environ
) . output
def RunAndExtractTestList ( args = None ) :
def RunAndExtractTestList ( args = None ) :
""" Runs the test program and returns its exit code and a list of tests run. """
""" Runs the test program and returns its exit code and a list of tests run. """
p = gtest_test_utils . Subprocess ( [ COMMAND ] + ( args or [ ] ) , env = environ )
p = gtest_test_utils . Subprocess ( [ COMMAND ] + ( args or [ ] ) , env = environ )
@ -234,10 +241,13 @@ def InvokeWithModifiedEnv(extra_env, function, *args, **kwargs):
def RunWithSharding ( total_shards , shard_index , command ) :
def RunWithSharding ( total_shards , shard_index , command ) :
""" Runs a test program shard and returns exit code and a list of tests run. """
""" Runs a test program shard and returns exit code and a list of tests run. """
extra_env = { SHARD_INDEX_ENV_VAR : str ( shard_index ) ,
extra_env = {
TOTAL_SHARDS_ENV_VAR : str ( total_shards ) }
SHARD_INDEX_ENV_VAR : str ( shard_index ) ,
TOTAL_SHARDS_ENV_VAR : str ( total_shards ) ,
}
return InvokeWithModifiedEnv ( extra_env , RunAndExtractTestList , command )
return InvokeWithModifiedEnv ( extra_env , RunAndExtractTestList , command )
# The unit test.
# The unit test.
@ -303,8 +313,14 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
tests_run = RunAndExtractTestList ( args ) [ 0 ]
tests_run = RunAndExtractTestList ( args ) [ 0 ]
self . AssertSetEqual ( tests_run , tests_to_run )
self . AssertSetEqual ( tests_run , tests_to_run )
def RunAndVerifyWithSharding ( self , gtest_filter , total_shards , tests_to_run ,
def RunAndVerifyWithSharding (
args = None , check_exit_0 = False ) :
self ,
gtest_filter ,
total_shards ,
tests_to_run ,
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 googletest - filter - unittest_ with the given filter , and
Runs all shards of googletest - filter - unittest_ with the given filter , and
@ -316,9 +332,9 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
gtest_filter : A filter to apply to the tests .
gtest_filter : A filter to apply to the tests .
total_shards : A total number of shards to split test run into .
total_shards : A total number of shards to split test run into .
tests_to_run : A set of tests expected to run .
tests_to_run : A set of tests expected to run .
args : Arguments to pass to the to the test binary .
args : Arguments to pass to the to the test binary .
check_exit_0 : When set to a true value , make sure that all shards
check_exit_0 : When set to a true value , make sure that all shards return
return 0.
0.
"""
"""
tests_to_run = self . AdjustForParameterizedTests ( tests_to_run )
tests_to_run = self . AdjustForParameterizedTests ( tests_to_run )
@ -372,8 +388,9 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
global param_tests_present
global param_tests_present
if param_tests_present is None :
if param_tests_present is None :
param_tests_present = PARAM_TEST_REGEX . search (
param_tests_present = (
RunAndReturnOutput ( ) ) is not None
PARAM_TEST_REGEX . search ( RunAndReturnOutput ( ) ) is not None
)
def testDefaultBehavior ( self ) :
def testDefaultBehavior ( self ) :
""" Tests the behavior of not specifying the filter. """
""" Tests the behavior of not specifying the filter. """
@ -425,8 +442,9 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
BAZ_TESTS = [ ' BazTest.TestOne ' , ' BazTest.TestA ' , ' BazTest.TestB ' ]
BAZ_TESTS = [ ' BazTest.TestOne ' , ' BazTest.TestA ' , ' BazTest.TestB ' ]
self . RunAndVerify ( ' BazTest.* ' , BAZ_TESTS )
self . RunAndVerify ( ' BazTest.* ' , BAZ_TESTS )
self . RunAndVerifyAllowingDisabled ( ' BazTest.* ' ,
self . RunAndVerifyAllowingDisabled (
BAZ_TESTS + [ ' BazTest.DISABLED_TestC ' ] )
' BazTest.* ' , BAZ_TESTS + [ ' BazTest.DISABLED_TestC ' ]
)
def testFilterByTest ( self ) :
def testFilterByTest ( self ) :
""" Tests filtering by test name. """
""" Tests filtering by test name. """
@ -437,38 +455,50 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
""" Select only the disabled tests to run. """
""" Select only the disabled tests to run. """
self . RunAndVerify ( ' DISABLED_FoobarTest.Test1 ' , [ ] )
self . RunAndVerify ( ' DISABLED_FoobarTest.Test1 ' , [ ] )
self . RunAndVerifyAllowingDisabled ( ' DISABLED_FoobarTest.Test1 ' ,
self . RunAndVerifyAllowingDisabled (
[ ' DISABLED_FoobarTest.Test1 ' ] )
' DISABLED_FoobarTest.Test1 ' , [ ' DISABLED_FoobarTest.Test1 ' ]
)
self . RunAndVerify ( ' *DISABLED_* ' , [ ] )
self . RunAndVerify ( ' *DISABLED_* ' , [ ] )
self . RunAndVerifyAllowingDisabled ( ' *DISABLED_* ' , DISABLED_TESTS )
self . RunAndVerifyAllowingDisabled ( ' *DISABLED_* ' , DISABLED_TESTS )
self . RunAndVerify ( ' *.DISABLED_* ' , [ ] )
self . RunAndVerify ( ' *.DISABLED_* ' , [ ] )
self . RunAndVerifyAllowingDisabled ( ' *.DISABLED_* ' , [
self . RunAndVerifyAllowingDisabled (
' BarTest.DISABLED_TestFour ' ,
' *.DISABLED_* ' ,
' BarTest.DISABLED_TestFive ' ,
[
' BazTest.DISABLED_TestC ' ,
' BarTest.DISABLED_TestFour ' ,
' DISABLED_FoobarTest.DISABLED_Test2 ' ,
' BarTest.DISABLED_TestFive ' ,
] )
' BazTest.DISABLED_TestC ' ,
' DISABLED_FoobarTest.DISABLED_Test2 ' ,
] ,
)
self . RunAndVerify ( ' DISABLED_* ' , [ ] )
self . RunAndVerify ( ' DISABLED_* ' , [ ] )
self . RunAndVerifyAllowingDisabled ( ' DISABLED_* ' , [
self . RunAndVerifyAllowingDisabled (
' DISABLED_FoobarTest.Test1 ' ,
' DISABLED_* ' ,
' DISABLED_FoobarTest.DISABLED_Test2 ' ,
[
' DISABLED_FoobarbazTest.TestA ' ,
' DISABLED_FoobarTest.Test1 ' ,
] )
' DISABLED_FoobarTest.DISABLED_Test2 ' ,
' DISABLED_FoobarbazTest.TestA ' ,
] ,
)
def testWildcardInTestCaseName ( self ) :
def testWildcardInTestCaseName ( self ) :
""" Tests using wildcard in the test case name. """
""" Tests using wildcard in the test case name. """
self . RunAndVerify ( ' *a*.* ' , [
self . RunAndVerify (
' BarTest.TestOne ' ,
' *a*.* ' ,
' BarTest.TestTwo ' ,
[
' BarTest.TestThree ' ,
' BarTest.TestOne ' ,
' BarTest.TestTwo ' ,
' BazTest.TestOne ' ,
' BarTest.TestThree ' ,
' BazTest.TestA ' ,
' BazTest.TestOne ' ,
' BazTest.TestB ' , ] + DEATH_TESTS + PARAM_TESTS )
' BazTest.TestA ' ,
' BazTest.TestB ' ,
]
+ DEATH_TESTS
+ PARAM_TESTS ,
)
def testWildcardInTestName ( self ) :
def testWildcardInTestName ( self ) :
""" Tests using wildcard in the test name. """
""" Tests using wildcard in the test name. """
@ -478,23 +508,27 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
def testFilterWithoutDot ( self ) :
def testFilterWithoutDot ( self ) :
""" Tests a filter that has no ' . ' in it. """
""" Tests a filter that has no ' . ' in it. """
self . RunAndVerify ( ' *z* ' , [
self . RunAndVerify (
' FooTest.Xyz ' ,
' *z* ' ,
[
' BazTest.TestOne ' ,
' FooTest.Xyz ' ,
' BazTest.TestA ' ,
' BazTest.TestOne ' ,
' BazTest.TestB ' ,
' BazTest.TestA ' ,
] )
' BazTest.TestB ' ,
] ,
)
def testTwoPatterns ( self ) :
def testTwoPatterns ( self ) :
""" Tests filters that consist of two patterns. """
""" Tests filters that consist of two patterns. """
self . RunAndVerify ( ' Foo*.*:*A* ' , [
self . RunAndVerify (
' FooTest.Abc ' ,
' Foo*.*:*A* ' ,
' FooTest.Xyz ' ,
[
' FooTest.Abc ' ,
' BazTest.TestA ' ,
' FooTest.Xyz ' ,
] )
' BazTest.TestA ' ,
] ,
)
# An empty pattern + a non-empty one
# An empty pattern + a non-empty one
self . RunAndVerify ( ' :*A* ' , [ ' FooTest.Abc ' , ' BazTest.TestA ' ] )
self . RunAndVerify ( ' :*A* ' , [ ' FooTest.Abc ' , ' BazTest.TestA ' ] )
@ -502,83 +536,109 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
def testThreePatterns ( self ) :
def testThreePatterns ( self ) :
""" Tests filters that consist of three patterns. """
""" Tests filters that consist of three patterns. """
self . RunAndVerify ( ' *oo*:*A*:*One ' , [
self . RunAndVerify (
' FooTest.Abc ' ,
' *oo*:*A*:*One ' ,
' FooTest.Xyz ' ,
[
' FooTest.Abc ' ,
' BarTest.TestOne ' ,
' FooTest.Xyz ' ,
' BarTest.TestOne ' ,
' BazTest.TestOne ' ,
' BazTest.TestOne ' ,
' BazTest.TestA ' ,
' BazTest.TestA ' ,
] )
] ,
)
# The 2nd pattern is empty.
# The 2nd pattern is empty.
self . RunAndVerify ( ' *oo*::*One ' , [
self . RunAndVerify (
' FooTest.Abc ' ,
' *oo*::*One ' ,
' FooTest.Xyz ' ,
[
' FooTest.Abc ' ,
' BarTest.TestOne ' ,
' FooTest.Xyz ' ,
' BarTest.TestOne ' ,
' BazTest.TestOne ' ,
' BazTest.TestOne ' ,
] )
] ,
)
# The last 2 patterns are empty.
# The last 2 patterns are empty.
self . RunAndVerify ( ' *oo*:: ' , [
self . RunAndVerify (
' FooTest.Abc ' ,
' *oo*:: ' ,
' FooTest.Xyz ' ,
[
] )
' FooTest.Abc ' ,
' FooTest.Xyz ' ,
] ,
)
def testNegativeFilters ( self ) :
def testNegativeFilters ( self ) :
self . RunAndVerify ( ' *-BazTest.TestOne ' , [
self . RunAndVerify (
' FooTest.Abc ' ,
' *-BazTest.TestOne ' ,
' FooTest.Xyz ' ,
[
' FooTest.Abc ' ,
' BarTest.TestOne ' ,
' FooTest.Xyz ' ,
' BarTest.TestTwo ' ,
' BarTest.TestOne ' ,
' BarTest.TestThree ' ,
' BarTest.TestTwo ' ,
' BarTest.TestThree ' ,
' BazTest.TestA ' ,
' BazTest.TestA ' ,
' BazTest.TestB ' ,
' BazTest.TestB ' ,
] + DEATH_TESTS + PARAM_TESTS )
]
+ DEATH_TESTS
self . RunAndVerify ( ' *-FooTest.Abc:BazTest.* ' , [
+ PARAM_TESTS ,
' FooTest.Xyz ' ,
)
' BarTest.TestOne ' ,
self . RunAndVerify (
' BarTest.TestTwo ' ,
' *-FooTest.Abc:BazTest.* ' ,
' BarTest.TestThree ' ,
[
] + DEATH_TESTS + PARAM_TESTS )
' FooTest.Xyz ' ,
' BarTest.TestOne ' ,
self . RunAndVerify ( ' BarTest.*-BarTest.TestOne ' , [
' BarTest.TestTwo ' ,
' BarTest.TestTwo ' ,
' BarTest.TestThree ' ,
' BarTest.TestThree ' ,
]
] )
+ DEATH_TESTS
+ PARAM_TESTS ,
)
self . RunAndVerify (
' BarTest.*-BarTest.TestOne ' ,
[
' BarTest.TestTwo ' ,
' BarTest.TestThree ' ,
] ,
)
# Tests without leading '*'.
# Tests without leading '*'.
self . RunAndVerify ( ' -FooTest.Abc:FooTest.Xyz:BazTest.* ' , [
self . RunAndVerify (
' BarTest.TestOne ' ,
' -FooTest.Abc:FooTest.Xyz:BazTest.* ' ,
' BarTest.TestTwo ' ,
[
' BarTest.TestThree ' ,
' BarTest.TestOne ' ,
] + DEATH_TESTS + PARAM_TESTS )
' BarTest.TestTwo ' ,
' BarTest.TestThree ' ,
]
+ DEATH_TESTS
+ PARAM_TESTS ,
)
# Value parameterized tests.
# Value parameterized tests.
self . RunAndVerify ( ' */* ' , PARAM_TESTS )
self . RunAndVerify ( ' */* ' , PARAM_TESTS )
# Value parameterized tests filtering by the sequence name.
# Value parameterized tests filtering by the sequence name.
self . RunAndVerify ( ' SeqP/* ' , [
self . RunAndVerify (
' SeqP/ParamTest.TestX/0 ' ,
' SeqP/* ' ,
' SeqP/ParamTest.TestX/1 ' ,
[
' SeqP/ParamTest.TestY/0 ' ,
' SeqP/ParamTest.TestX/0 ' ,
' SeqP/ParamTest.TestY/1 ' ,
' SeqP/ParamTest.TestX/1 ' ,
] )
' SeqP/ParamTest.TestY/0 ' ,
' SeqP/ParamTest.TestY/1 ' ,
] ,
)
# Value parameterized tests filtering by the test name.
# Value parameterized tests filtering by the test name.
self . RunAndVerify ( ' */0 ' , [
self . RunAndVerify (
' SeqP/ParamTest.TestX/0 ' ,
' */0 ' ,
' SeqP/ParamTest.TestY/0 ' ,
[
' SeqQ/ParamTest.TestX/0 ' ,
' SeqP/ParamTest.TestX/0 ' ,
' SeqQ/ParamTest.TestY/0 ' ,
' SeqP/ParamTest.TestY/0 ' ,
] )
' SeqQ/ParamTest.TestX/0 ' ,
' SeqQ/ParamTest.TestY/0 ' ,
] ,
)
def testFlagOverridesEnvVar ( self ) :
def testFlagOverridesEnvVar ( self ) :
""" Tests that the filter flag overrides the filtering env. variable. """
""" Tests that the filter flag overrides the filtering env. variable. """
@ -593,8 +653,9 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
def testShardStatusFileIsCreated ( self ) :
def testShardStatusFileIsCreated ( self ) :
""" Tests that the shard file is created if specified in the environment. """
""" Tests that the shard file is created if specified in the environment. """
shard_status_file = os . path . join ( gtest_test_utils . GetTempDir ( ) ,
shard_status_file = os . path . join (
' shard_status_file ' )
gtest_test_utils . GetTempDir ( ) , ' shard_status_file '
)
self . assertTrue ( not os . path . exists ( shard_status_file ) )
self . assertTrue ( not os . path . exists ( shard_status_file ) )
extra_env = { SHARD_STATUS_FILE_ENV_VAR : shard_status_file }
extra_env = { SHARD_STATUS_FILE_ENV_VAR : shard_status_file }
@ -607,15 +668,16 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
def testShardStatusFileIsCreatedWithListTests ( self ) :
def testShardStatusFileIsCreatedWithListTests ( self ) :
""" Tests that the shard file is created with the " list_tests " flag. """
""" Tests that the shard file is created with the " list_tests " flag. """
shard_status_file = os . path . join ( gtest_test_utils . GetTempDir ( ) ,
shard_status_file = os . path . join (
' shard_status_file2 ' )
gtest_test_utils . GetTempDir ( ) , ' shard_status_file2 '
)
self . assertTrue ( not os . path . exists ( shard_status_file ) )
self . assertTrue ( not os . path . exists ( shard_status_file ) )
extra_env = { SHARD_STATUS_FILE_ENV_VAR : shard_status_file }
extra_env = { SHARD_STATUS_FILE_ENV_VAR : shard_status_file }
try :
try :
output = InvokeWithModifiedEnv ( extra_env ,
output = InvokeWithModifiedEnv (
RunAndReturnOutput ,
extra_env , RunAndReturnOutput , [ LIST_TESTS_FLAG ]
[ LIST_TESTS_FLAG ] )
)
finally :
finally :
# This assertion ensures that Google Test enumerated the tests as
# This assertion ensures that Google Test enumerated the tests as
# opposed to running them.
# opposed to running them.
@ -636,19 +698,25 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
make_filter = lambda s : [ ' -- %s = %s ' % ( FILTER_FLAG , s ) ]
make_filter = lambda s : [ ' -- %s = %s ' % ( FILTER_FLAG , s ) ]
banners = RunAndExtractDisabledBannerList ( make_filter ( ' * ' ) )
banners = RunAndExtractDisabledBannerList ( make_filter ( ' * ' ) )
self . AssertSetEqual ( banners , [
self . AssertSetEqual (
' BarTest.DISABLED_TestFour ' , ' BarTest.DISABLED_TestFive ' ,
banners ,
' BazTest.DISABLED_TestC '
[
] )
' BarTest.DISABLED_TestFour ' ,
' BarTest.DISABLED_TestFive ' ,
' BazTest.DISABLED_TestC ' ,
] ,
)
banners = RunAndExtractDisabledBannerList ( make_filter ( ' Bar* ' ) )
banners = RunAndExtractDisabledBannerList ( make_filter ( ' Bar* ' ) )
self . AssertSetEqual (
self . AssertSetEqual (
banners , [ ' BarTest.DISABLED_TestFour ' , ' BarTest.DISABLED_TestFive ' ] )
banners , [ ' BarTest.DISABLED_TestFour ' , ' BarTest.DISABLED_TestFive ' ]
)
banners = RunAndExtractDisabledBannerList ( make_filter ( ' *-Bar* ' ) )
banners = RunAndExtractDisabledBannerList ( make_filter ( ' *-Bar* ' ) )
self . AssertSetEqual ( banners , [ ' BazTest.DISABLED_TestC ' ] )
self . AssertSetEqual ( banners , [ ' BazTest.DISABLED_TestC ' ] )
if SUPPORTS_DEATH_TESTS :
if SUPPORTS_DEATH_TESTS :
def testShardingWorksWithDeathTests ( self ) :
def testShardingWorksWithDeathTests ( self ) :
""" Tests integration with death tests and sharding. """
""" Tests integration with death tests and sharding. """
@ -656,19 +724,23 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
expected_tests = [
expected_tests = [
' HasDeathTest.Test1 ' ,
' HasDeathTest.Test1 ' ,
' HasDeathTest.Test2 ' ,
' HasDeathTest.Test2 ' ,
' SeqP/ParamTest.TestX/0 ' ,
' SeqP/ParamTest.TestX/0 ' ,
' SeqP/ParamTest.TestX/1 ' ,
' SeqP/ParamTest.TestX/1 ' ,
' SeqP/ParamTest.TestY/0 ' ,
' SeqP/ParamTest.TestY/0 ' ,
' SeqP/ParamTest.TestY/1 ' ,
' SeqP/ParamTest.TestY/1 ' ,
]
]
for flag in [ ' --gtest_death_test_style=threadsafe ' ,
for flag in [
' --gtest_death_test_style=fast ' ] :
' --gtest_death_test_style=threadsafe ' ,
self . RunAndVerifyWithSharding ( gtest_filter , 3 , expected_tests ,
' --gtest_death_test_style=fast ' ,
check_exit_0 = True , args = [ flag ] )
] :
self . RunAndVerifyWithSharding ( gtest_filter , 5 , expected_tests ,
self . RunAndVerifyWithSharding (
check_exit_0 = True , args = [ flag ] )
gtest_filter , 3 , expected_tests , check_exit_0 = True , args = [ flag ]
)
self . RunAndVerifyWithSharding (
gtest_filter , 5 , expected_tests , check_exit_0 = True , args = [ flag ]
)
if __name__ == ' __main__ ' :
if __name__ == ' __main__ ' :
gtest_test_utils . Main ( )
gtest_test_utils . Main ( )