128f6c2f2SEnji Cooper#!/usr/bin/env python 228f6c2f2SEnji Cooper# 328f6c2f2SEnji Cooper# Copyright 2020 Google Inc. All Rights Reserved. 428f6c2f2SEnji Cooper# 528f6c2f2SEnji Cooper# Redistribution and use in source and binary forms, with or without 628f6c2f2SEnji Cooper# modification, are permitted provided that the following conditions are 728f6c2f2SEnji Cooper# met: 828f6c2f2SEnji Cooper# 928f6c2f2SEnji Cooper# * Redistributions of source code must retain the above copyright 1028f6c2f2SEnji Cooper# notice, this list of conditions and the following disclaimer. 1128f6c2f2SEnji Cooper# * Redistributions in binary form must reproduce the above 1228f6c2f2SEnji Cooper# copyright notice, this list of conditions and the following disclaimer 1328f6c2f2SEnji Cooper# in the documentation and/or other materials provided with the 1428f6c2f2SEnji Cooper# distribution. 1528f6c2f2SEnji Cooper# * Neither the name of Google Inc. nor the names of its 1628f6c2f2SEnji Cooper# contributors may be used to endorse or promote products derived from 1728f6c2f2SEnji Cooper# this software without specific prior written permission. 1828f6c2f2SEnji Cooper# 1928f6c2f2SEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2028f6c2f2SEnji Cooper# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2128f6c2f2SEnji Cooper# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2228f6c2f2SEnji Cooper# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2328f6c2f2SEnji Cooper# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2428f6c2f2SEnji Cooper# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2528f6c2f2SEnji Cooper# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2628f6c2f2SEnji Cooper# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2728f6c2f2SEnji Cooper# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2828f6c2f2SEnji Cooper# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2928f6c2f2SEnji Cooper# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3028f6c2f2SEnji Cooper 3128f6c2f2SEnji Cooper"""Unit test for Google Test fail_fast. 3228f6c2f2SEnji Cooper 3328f6c2f2SEnji CooperA user can specify if a Google Test program should continue test execution 3428f6c2f2SEnji Cooperafter a test failure via the GTEST_FAIL_FAST environment variable or the 3528f6c2f2SEnji Cooper--gtest_fail_fast flag. The default value of the flag can also be changed 3628f6c2f2SEnji Cooperby Bazel fail fast environment variable TESTBRIDGE_TEST_RUNNER_FAIL_FAST. 3728f6c2f2SEnji Cooper 3828f6c2f2SEnji CooperThis script tests such functionality by invoking googletest-failfast-unittest_ 3928f6c2f2SEnji Cooper(a program written with Google Test) with different environments and command 4028f6c2f2SEnji Cooperline flags. 4128f6c2f2SEnji Cooper""" 4228f6c2f2SEnji Cooper 4328f6c2f2SEnji Cooperimport os 4428f6c2f2SEnji Cooperfrom googletest.test import gtest_test_utils 4528f6c2f2SEnji Cooper 4628f6c2f2SEnji Cooper# Constants. 4728f6c2f2SEnji Cooper 4828f6c2f2SEnji Cooper# Bazel testbridge environment variable for fail fast 4928f6c2f2SEnji CooperBAZEL_FAIL_FAST_ENV_VAR = 'TESTBRIDGE_TEST_RUNNER_FAIL_FAST' 5028f6c2f2SEnji Cooper 5128f6c2f2SEnji Cooper# The environment variable for specifying fail fast. 5228f6c2f2SEnji CooperFAIL_FAST_ENV_VAR = 'GTEST_FAIL_FAST' 5328f6c2f2SEnji Cooper 5428f6c2f2SEnji Cooper# The command line flag for specifying fail fast. 5528f6c2f2SEnji CooperFAIL_FAST_FLAG = 'gtest_fail_fast' 5628f6c2f2SEnji Cooper 5728f6c2f2SEnji Cooper# The command line flag to run disabled tests. 5828f6c2f2SEnji CooperRUN_DISABLED_FLAG = 'gtest_also_run_disabled_tests' 5928f6c2f2SEnji Cooper 6028f6c2f2SEnji Cooper# The command line flag for specifying a filter. 6128f6c2f2SEnji CooperFILTER_FLAG = 'gtest_filter' 6228f6c2f2SEnji Cooper 6328f6c2f2SEnji Cooper# Command to run the googletest-failfast-unittest_ program. 6428f6c2f2SEnji CooperCOMMAND = gtest_test_utils.GetTestExecutablePath( 6528f6c2f2SEnji Cooper 'googletest-failfast-unittest_' 6628f6c2f2SEnji Cooper) 6728f6c2f2SEnji Cooper 6828f6c2f2SEnji Cooper# The command line flag to tell Google Test to output the list of tests it 6928f6c2f2SEnji Cooper# will run. 7028f6c2f2SEnji CooperLIST_TESTS_FLAG = '--gtest_list_tests' 7128f6c2f2SEnji Cooper 7228f6c2f2SEnji Cooper# Indicates whether Google Test supports death tests. 7328f6c2f2SEnji CooperSUPPORTS_DEATH_TESTS = ( 7428f6c2f2SEnji Cooper 'HasDeathTest' 7528f6c2f2SEnji Cooper in gtest_test_utils.Subprocess([COMMAND, LIST_TESTS_FLAG]).output 7628f6c2f2SEnji Cooper) 7728f6c2f2SEnji Cooper 7828f6c2f2SEnji Cooper# Utilities. 7928f6c2f2SEnji Cooper 8028f6c2f2SEnji Cooperenviron = os.environ.copy() 8128f6c2f2SEnji Cooper 8228f6c2f2SEnji Cooper 8328f6c2f2SEnji Cooperdef SetEnvVar(env_var, value): 8428f6c2f2SEnji Cooper """Sets the env variable to 'value'; unsets it when 'value' is None.""" 8528f6c2f2SEnji Cooper 8628f6c2f2SEnji Cooper if value is not None: 8728f6c2f2SEnji Cooper environ[env_var] = value 8828f6c2f2SEnji Cooper elif env_var in environ: 8928f6c2f2SEnji Cooper del environ[env_var] 9028f6c2f2SEnji Cooper 9128f6c2f2SEnji Cooper 9228f6c2f2SEnji Cooperdef RunAndReturnOutput(test_suite=None, fail_fast=None, run_disabled=False): 9328f6c2f2SEnji Cooper """Runs the test program and returns its output.""" 9428f6c2f2SEnji Cooper 9528f6c2f2SEnji Cooper args = [] 9628f6c2f2SEnji Cooper xml_path = os.path.join( 9728f6c2f2SEnji Cooper gtest_test_utils.GetTempDir(), '.GTestFailFastUnitTest.xml' 9828f6c2f2SEnji Cooper ) 9928f6c2f2SEnji Cooper args += ['--gtest_output=xml:' + xml_path] 10028f6c2f2SEnji Cooper if fail_fast is not None: 10128f6c2f2SEnji Cooper if isinstance(fail_fast, str): 10228f6c2f2SEnji Cooper args += ['--%s=%s' % (FAIL_FAST_FLAG, fail_fast)] 10328f6c2f2SEnji Cooper elif fail_fast: 10428f6c2f2SEnji Cooper args += ['--%s' % FAIL_FAST_FLAG] 10528f6c2f2SEnji Cooper else: 10628f6c2f2SEnji Cooper args += ['--no%s' % FAIL_FAST_FLAG] 10728f6c2f2SEnji Cooper if test_suite: 10828f6c2f2SEnji Cooper args += ['--%s=%s.*' % (FILTER_FLAG, test_suite)] 10928f6c2f2SEnji Cooper if run_disabled: 11028f6c2f2SEnji Cooper args += ['--%s' % RUN_DISABLED_FLAG] 11128f6c2f2SEnji Cooper txt_out = gtest_test_utils.Subprocess([COMMAND] + args, env=environ).output 11228f6c2f2SEnji Cooper with open(xml_path) as xml_file: 11328f6c2f2SEnji Cooper return txt_out, xml_file.read() 11428f6c2f2SEnji Cooper 11528f6c2f2SEnji Cooper 11628f6c2f2SEnji Cooper# The unit test. 11728f6c2f2SEnji Cooperclass GTestFailFastUnitTest(gtest_test_utils.TestCase): 11828f6c2f2SEnji Cooper """Tests the env variable or the command line flag for fail_fast.""" 11928f6c2f2SEnji Cooper 12028f6c2f2SEnji Cooper def testDefaultBehavior(self): 12128f6c2f2SEnji Cooper """Tests the behavior of not specifying the fail_fast.""" 12228f6c2f2SEnji Cooper 12328f6c2f2SEnji Cooper txt, _ = RunAndReturnOutput() 12428f6c2f2SEnji Cooper self.assertIn('22 FAILED TEST', txt) 12528f6c2f2SEnji Cooper 12628f6c2f2SEnji Cooper def testGoogletestFlag(self): 12728f6c2f2SEnji Cooper txt, _ = RunAndReturnOutput(test_suite='HasSimpleTest', fail_fast=True) 12828f6c2f2SEnji Cooper self.assertIn('1 FAILED TEST', txt) 12928f6c2f2SEnji Cooper self.assertIn('[ SKIPPED ] 3 tests', txt) 13028f6c2f2SEnji Cooper 13128f6c2f2SEnji Cooper txt, _ = RunAndReturnOutput(test_suite='HasSimpleTest', fail_fast=False) 13228f6c2f2SEnji Cooper self.assertIn('4 FAILED TEST', txt) 13328f6c2f2SEnji Cooper self.assertNotIn('[ SKIPPED ]', txt) 13428f6c2f2SEnji Cooper 13528f6c2f2SEnji Cooper def testGoogletestEnvVar(self): 13628f6c2f2SEnji Cooper """Tests the behavior of specifying fail_fast via Googletest env var.""" 13728f6c2f2SEnji Cooper 13828f6c2f2SEnji Cooper try: 13928f6c2f2SEnji Cooper SetEnvVar(FAIL_FAST_ENV_VAR, '1') 14028f6c2f2SEnji Cooper txt, _ = RunAndReturnOutput('HasSimpleTest') 14128f6c2f2SEnji Cooper self.assertIn('1 FAILED TEST', txt) 14228f6c2f2SEnji Cooper self.assertIn('[ SKIPPED ] 3 tests', txt) 14328f6c2f2SEnji Cooper 14428f6c2f2SEnji Cooper SetEnvVar(FAIL_FAST_ENV_VAR, '0') 14528f6c2f2SEnji Cooper txt, _ = RunAndReturnOutput('HasSimpleTest') 14628f6c2f2SEnji Cooper self.assertIn('4 FAILED TEST', txt) 14728f6c2f2SEnji Cooper self.assertNotIn('[ SKIPPED ]', txt) 14828f6c2f2SEnji Cooper finally: 14928f6c2f2SEnji Cooper SetEnvVar(FAIL_FAST_ENV_VAR, None) 15028f6c2f2SEnji Cooper 15128f6c2f2SEnji Cooper def testBazelEnvVar(self): 15228f6c2f2SEnji Cooper """Tests the behavior of specifying fail_fast via Bazel testbridge.""" 15328f6c2f2SEnji Cooper 15428f6c2f2SEnji Cooper try: 15528f6c2f2SEnji Cooper SetEnvVar(BAZEL_FAIL_FAST_ENV_VAR, '1') 15628f6c2f2SEnji Cooper txt, _ = RunAndReturnOutput('HasSimpleTest') 15728f6c2f2SEnji Cooper self.assertIn('1 FAILED TEST', txt) 15828f6c2f2SEnji Cooper self.assertIn('[ SKIPPED ] 3 tests', txt) 15928f6c2f2SEnji Cooper 16028f6c2f2SEnji Cooper SetEnvVar(BAZEL_FAIL_FAST_ENV_VAR, '0') 16128f6c2f2SEnji Cooper txt, _ = RunAndReturnOutput('HasSimpleTest') 16228f6c2f2SEnji Cooper self.assertIn('4 FAILED TEST', txt) 16328f6c2f2SEnji Cooper self.assertNotIn('[ SKIPPED ]', txt) 16428f6c2f2SEnji Cooper finally: 16528f6c2f2SEnji Cooper SetEnvVar(BAZEL_FAIL_FAST_ENV_VAR, None) 16628f6c2f2SEnji Cooper 16728f6c2f2SEnji Cooper def testFlagOverridesEnvVar(self): 16828f6c2f2SEnji Cooper """Tests precedence of flag over env var.""" 16928f6c2f2SEnji Cooper 17028f6c2f2SEnji Cooper try: 17128f6c2f2SEnji Cooper SetEnvVar(FAIL_FAST_ENV_VAR, '0') 17228f6c2f2SEnji Cooper txt, _ = RunAndReturnOutput('HasSimpleTest', True) 17328f6c2f2SEnji Cooper self.assertIn('1 FAILED TEST', txt) 17428f6c2f2SEnji Cooper self.assertIn('[ SKIPPED ] 3 tests', txt) 17528f6c2f2SEnji Cooper finally: 17628f6c2f2SEnji Cooper SetEnvVar(FAIL_FAST_ENV_VAR, None) 17728f6c2f2SEnji Cooper 17828f6c2f2SEnji Cooper def testGoogletestEnvVarOverridesBazelEnvVar(self): 17928f6c2f2SEnji Cooper """Tests that the Googletest native env var over Bazel testbridge.""" 18028f6c2f2SEnji Cooper 18128f6c2f2SEnji Cooper try: 18228f6c2f2SEnji Cooper SetEnvVar(BAZEL_FAIL_FAST_ENV_VAR, '0') 18328f6c2f2SEnji Cooper SetEnvVar(FAIL_FAST_ENV_VAR, '1') 18428f6c2f2SEnji Cooper txt, _ = RunAndReturnOutput('HasSimpleTest') 18528f6c2f2SEnji Cooper self.assertIn('1 FAILED TEST', txt) 18628f6c2f2SEnji Cooper self.assertIn('[ SKIPPED ] 3 tests', txt) 18728f6c2f2SEnji Cooper finally: 18828f6c2f2SEnji Cooper SetEnvVar(FAIL_FAST_ENV_VAR, None) 18928f6c2f2SEnji Cooper SetEnvVar(BAZEL_FAIL_FAST_ENV_VAR, None) 19028f6c2f2SEnji Cooper 19128f6c2f2SEnji Cooper def testEventListener(self): 19228f6c2f2SEnji Cooper txt, _ = RunAndReturnOutput(test_suite='HasSkipTest', fail_fast=True) 19328f6c2f2SEnji Cooper self.assertIn('1 FAILED TEST', txt) 19428f6c2f2SEnji Cooper self.assertIn('[ SKIPPED ] 3 tests', txt) 19528f6c2f2SEnji Cooper for expected_count, callback in [ 19628f6c2f2SEnji Cooper (1, 'OnTestSuiteStart'), 19728f6c2f2SEnji Cooper (5, 'OnTestStart'), 19828f6c2f2SEnji Cooper (5, 'OnTestEnd'), 19928f6c2f2SEnji Cooper (5, 'OnTestPartResult'), 20028f6c2f2SEnji Cooper (1, 'OnTestSuiteEnd'), 20128f6c2f2SEnji Cooper ]: 20228f6c2f2SEnji Cooper self.assertEqual( 20328f6c2f2SEnji Cooper expected_count, 20428f6c2f2SEnji Cooper txt.count(callback), 20528f6c2f2SEnji Cooper 'Expected %d calls to callback %s match count on output: %s ' 20628f6c2f2SEnji Cooper % (expected_count, callback, txt), 20728f6c2f2SEnji Cooper ) 20828f6c2f2SEnji Cooper 20928f6c2f2SEnji Cooper txt, _ = RunAndReturnOutput(test_suite='HasSkipTest', fail_fast=False) 21028f6c2f2SEnji Cooper self.assertIn('3 FAILED TEST', txt) 21128f6c2f2SEnji Cooper self.assertIn('[ SKIPPED ] 1 test', txt) 21228f6c2f2SEnji Cooper for expected_count, callback in [ 21328f6c2f2SEnji Cooper (1, 'OnTestSuiteStart'), 21428f6c2f2SEnji Cooper (5, 'OnTestStart'), 21528f6c2f2SEnji Cooper (5, 'OnTestEnd'), 21628f6c2f2SEnji Cooper (5, 'OnTestPartResult'), 21728f6c2f2SEnji Cooper (1, 'OnTestSuiteEnd'), 21828f6c2f2SEnji Cooper ]: 21928f6c2f2SEnji Cooper self.assertEqual( 22028f6c2f2SEnji Cooper expected_count, 22128f6c2f2SEnji Cooper txt.count(callback), 22228f6c2f2SEnji Cooper 'Expected %d calls to callback %s match count on output: %s ' 22328f6c2f2SEnji Cooper % (expected_count, callback, txt), 22428f6c2f2SEnji Cooper ) 22528f6c2f2SEnji Cooper 22628f6c2f2SEnji Cooper def assertXmlResultCount(self, result, count, xml): 22728f6c2f2SEnji Cooper self.assertEqual( 22828f6c2f2SEnji Cooper count, 22928f6c2f2SEnji Cooper xml.count('result="%s"' % result), 23028f6c2f2SEnji Cooper 'Expected \'result="%s"\' match count of %s: %s ' 23128f6c2f2SEnji Cooper % (result, count, xml), 23228f6c2f2SEnji Cooper ) 23328f6c2f2SEnji Cooper 23428f6c2f2SEnji Cooper def assertXmlStatusCount(self, status, count, xml): 23528f6c2f2SEnji Cooper self.assertEqual( 23628f6c2f2SEnji Cooper count, 23728f6c2f2SEnji Cooper xml.count('status="%s"' % status), 23828f6c2f2SEnji Cooper 'Expected \'status="%s"\' match count of %s: %s ' 23928f6c2f2SEnji Cooper % (status, count, xml), 24028f6c2f2SEnji Cooper ) 24128f6c2f2SEnji Cooper 24228f6c2f2SEnji Cooper def assertFailFastXmlAndTxtOutput( 24328f6c2f2SEnji Cooper self, 24428f6c2f2SEnji Cooper fail_fast, 24528f6c2f2SEnji Cooper test_suite, 24628f6c2f2SEnji Cooper passed_count, 24728f6c2f2SEnji Cooper failure_count, 24828f6c2f2SEnji Cooper skipped_count, 24928f6c2f2SEnji Cooper suppressed_count, 25028f6c2f2SEnji Cooper run_disabled=False, 25128f6c2f2SEnji Cooper ): 25228f6c2f2SEnji Cooper """Assert XML and text output of a test execution.""" 25328f6c2f2SEnji Cooper 25428f6c2f2SEnji Cooper txt, xml = RunAndReturnOutput(test_suite, fail_fast, run_disabled) 25528f6c2f2SEnji Cooper if failure_count > 0: 25628f6c2f2SEnji Cooper self.assertIn('%s FAILED TEST' % failure_count, txt) 25728f6c2f2SEnji Cooper if suppressed_count > 0: 25828f6c2f2SEnji Cooper self.assertIn('%s DISABLED TEST' % suppressed_count, txt) 25928f6c2f2SEnji Cooper if skipped_count > 0: 26028f6c2f2SEnji Cooper self.assertIn('[ SKIPPED ] %s tests' % skipped_count, txt) 26128f6c2f2SEnji Cooper self.assertXmlStatusCount( 26228f6c2f2SEnji Cooper 'run', passed_count + failure_count + skipped_count, xml 26328f6c2f2SEnji Cooper ) 26428f6c2f2SEnji Cooper self.assertXmlStatusCount('notrun', suppressed_count, xml) 26528f6c2f2SEnji Cooper self.assertXmlResultCount('completed', passed_count + failure_count, xml) 26628f6c2f2SEnji Cooper self.assertXmlResultCount('skipped', skipped_count, xml) 26728f6c2f2SEnji Cooper self.assertXmlResultCount('suppressed', suppressed_count, xml) 26828f6c2f2SEnji Cooper 26928f6c2f2SEnji Cooper def assertFailFastBehavior( 27028f6c2f2SEnji Cooper self, 27128f6c2f2SEnji Cooper test_suite, 27228f6c2f2SEnji Cooper passed_count, 27328f6c2f2SEnji Cooper failure_count, 27428f6c2f2SEnji Cooper skipped_count, 27528f6c2f2SEnji Cooper suppressed_count, 27628f6c2f2SEnji Cooper run_disabled=False, 27728f6c2f2SEnji Cooper ): 27828f6c2f2SEnji Cooper """Assert --fail_fast via flag.""" 27928f6c2f2SEnji Cooper 28028f6c2f2SEnji Cooper for fail_fast in ('true', '1', 't', True): 28128f6c2f2SEnji Cooper self.assertFailFastXmlAndTxtOutput( 28228f6c2f2SEnji Cooper fail_fast, 28328f6c2f2SEnji Cooper test_suite, 28428f6c2f2SEnji Cooper passed_count, 28528f6c2f2SEnji Cooper failure_count, 28628f6c2f2SEnji Cooper skipped_count, 28728f6c2f2SEnji Cooper suppressed_count, 28828f6c2f2SEnji Cooper run_disabled, 28928f6c2f2SEnji Cooper ) 29028f6c2f2SEnji Cooper 29128f6c2f2SEnji Cooper def assertNotFailFastBehavior( 29228f6c2f2SEnji Cooper self, 29328f6c2f2SEnji Cooper test_suite, 29428f6c2f2SEnji Cooper passed_count, 29528f6c2f2SEnji Cooper failure_count, 29628f6c2f2SEnji Cooper skipped_count, 29728f6c2f2SEnji Cooper suppressed_count, 29828f6c2f2SEnji Cooper run_disabled=False, 29928f6c2f2SEnji Cooper ): 30028f6c2f2SEnji Cooper """Assert --nofail_fast via flag.""" 30128f6c2f2SEnji Cooper 30228f6c2f2SEnji Cooper for fail_fast in ('false', '0', 'f', False): 30328f6c2f2SEnji Cooper self.assertFailFastXmlAndTxtOutput( 30428f6c2f2SEnji Cooper fail_fast, 30528f6c2f2SEnji Cooper test_suite, 30628f6c2f2SEnji Cooper passed_count, 30728f6c2f2SEnji Cooper failure_count, 30828f6c2f2SEnji Cooper skipped_count, 30928f6c2f2SEnji Cooper suppressed_count, 31028f6c2f2SEnji Cooper run_disabled, 31128f6c2f2SEnji Cooper ) 31228f6c2f2SEnji Cooper 31328f6c2f2SEnji Cooper def testFlag_HasFixtureTest(self): 31428f6c2f2SEnji Cooper """Tests the behavior of fail_fast and TEST_F.""" 31528f6c2f2SEnji Cooper self.assertFailFastBehavior( 31628f6c2f2SEnji Cooper test_suite='HasFixtureTest', 31728f6c2f2SEnji Cooper passed_count=1, 31828f6c2f2SEnji Cooper failure_count=1, 31928f6c2f2SEnji Cooper skipped_count=3, 32028f6c2f2SEnji Cooper suppressed_count=0, 32128f6c2f2SEnji Cooper ) 32228f6c2f2SEnji Cooper self.assertNotFailFastBehavior( 32328f6c2f2SEnji Cooper test_suite='HasFixtureTest', 32428f6c2f2SEnji Cooper passed_count=1, 32528f6c2f2SEnji Cooper failure_count=4, 32628f6c2f2SEnji Cooper skipped_count=0, 32728f6c2f2SEnji Cooper suppressed_count=0, 32828f6c2f2SEnji Cooper ) 32928f6c2f2SEnji Cooper 33028f6c2f2SEnji Cooper def testFlag_HasSimpleTest(self): 33128f6c2f2SEnji Cooper """Tests the behavior of fail_fast and TEST.""" 33228f6c2f2SEnji Cooper self.assertFailFastBehavior( 33328f6c2f2SEnji Cooper test_suite='HasSimpleTest', 33428f6c2f2SEnji Cooper passed_count=1, 33528f6c2f2SEnji Cooper failure_count=1, 33628f6c2f2SEnji Cooper skipped_count=3, 33728f6c2f2SEnji Cooper suppressed_count=0, 33828f6c2f2SEnji Cooper ) 33928f6c2f2SEnji Cooper self.assertNotFailFastBehavior( 34028f6c2f2SEnji Cooper test_suite='HasSimpleTest', 34128f6c2f2SEnji Cooper passed_count=1, 34228f6c2f2SEnji Cooper failure_count=4, 34328f6c2f2SEnji Cooper skipped_count=0, 34428f6c2f2SEnji Cooper suppressed_count=0, 34528f6c2f2SEnji Cooper ) 34628f6c2f2SEnji Cooper 34728f6c2f2SEnji Cooper def testFlag_HasParametersTest(self): 34828f6c2f2SEnji Cooper """Tests the behavior of fail_fast and TEST_P.""" 34928f6c2f2SEnji Cooper self.assertFailFastBehavior( 35028f6c2f2SEnji Cooper test_suite='HasParametersSuite/HasParametersTest', 35128f6c2f2SEnji Cooper passed_count=0, 35228f6c2f2SEnji Cooper failure_count=1, 35328f6c2f2SEnji Cooper skipped_count=3, 35428f6c2f2SEnji Cooper suppressed_count=0, 35528f6c2f2SEnji Cooper ) 35628f6c2f2SEnji Cooper self.assertNotFailFastBehavior( 35728f6c2f2SEnji Cooper test_suite='HasParametersSuite/HasParametersTest', 35828f6c2f2SEnji Cooper passed_count=0, 35928f6c2f2SEnji Cooper failure_count=4, 36028f6c2f2SEnji Cooper skipped_count=0, 36128f6c2f2SEnji Cooper suppressed_count=0, 36228f6c2f2SEnji Cooper ) 36328f6c2f2SEnji Cooper 36428f6c2f2SEnji Cooper def testFlag_HasDisabledTest(self): 36528f6c2f2SEnji Cooper """Tests the behavior of fail_fast and Disabled test cases.""" 36628f6c2f2SEnji Cooper self.assertFailFastBehavior( 36728f6c2f2SEnji Cooper test_suite='HasDisabledTest', 36828f6c2f2SEnji Cooper passed_count=1, 36928f6c2f2SEnji Cooper failure_count=1, 37028f6c2f2SEnji Cooper skipped_count=2, 37128f6c2f2SEnji Cooper suppressed_count=1, 37228f6c2f2SEnji Cooper run_disabled=False, 37328f6c2f2SEnji Cooper ) 37428f6c2f2SEnji Cooper self.assertNotFailFastBehavior( 37528f6c2f2SEnji Cooper test_suite='HasDisabledTest', 37628f6c2f2SEnji Cooper passed_count=1, 37728f6c2f2SEnji Cooper failure_count=3, 37828f6c2f2SEnji Cooper skipped_count=0, 37928f6c2f2SEnji Cooper suppressed_count=1, 38028f6c2f2SEnji Cooper run_disabled=False, 38128f6c2f2SEnji Cooper ) 38228f6c2f2SEnji Cooper 38328f6c2f2SEnji Cooper def testFlag_HasDisabledRunDisabledTest(self): 38428f6c2f2SEnji Cooper """Tests the behavior of fail_fast and Disabled test cases enabled.""" 38528f6c2f2SEnji Cooper self.assertFailFastBehavior( 38628f6c2f2SEnji Cooper test_suite='HasDisabledTest', 38728f6c2f2SEnji Cooper passed_count=1, 38828f6c2f2SEnji Cooper failure_count=1, 38928f6c2f2SEnji Cooper skipped_count=3, 39028f6c2f2SEnji Cooper suppressed_count=0, 39128f6c2f2SEnji Cooper run_disabled=True, 39228f6c2f2SEnji Cooper ) 39328f6c2f2SEnji Cooper self.assertNotFailFastBehavior( 39428f6c2f2SEnji Cooper test_suite='HasDisabledTest', 39528f6c2f2SEnji Cooper passed_count=1, 39628f6c2f2SEnji Cooper failure_count=4, 39728f6c2f2SEnji Cooper skipped_count=0, 39828f6c2f2SEnji Cooper suppressed_count=0, 39928f6c2f2SEnji Cooper run_disabled=True, 40028f6c2f2SEnji Cooper ) 40128f6c2f2SEnji Cooper 40228f6c2f2SEnji Cooper def testFlag_HasDisabledSuiteTest(self): 40328f6c2f2SEnji Cooper """Tests the behavior of fail_fast and Disabled test suites.""" 40428f6c2f2SEnji Cooper self.assertFailFastBehavior( 40528f6c2f2SEnji Cooper test_suite='DISABLED_HasDisabledSuite', 40628f6c2f2SEnji Cooper passed_count=0, 40728f6c2f2SEnji Cooper failure_count=0, 40828f6c2f2SEnji Cooper skipped_count=0, 40928f6c2f2SEnji Cooper suppressed_count=5, 41028f6c2f2SEnji Cooper run_disabled=False, 41128f6c2f2SEnji Cooper ) 41228f6c2f2SEnji Cooper self.assertNotFailFastBehavior( 41328f6c2f2SEnji Cooper test_suite='DISABLED_HasDisabledSuite', 41428f6c2f2SEnji Cooper passed_count=0, 41528f6c2f2SEnji Cooper failure_count=0, 41628f6c2f2SEnji Cooper skipped_count=0, 41728f6c2f2SEnji Cooper suppressed_count=5, 41828f6c2f2SEnji Cooper run_disabled=False, 41928f6c2f2SEnji Cooper ) 42028f6c2f2SEnji Cooper 42128f6c2f2SEnji Cooper def testFlag_HasDisabledSuiteRunDisabledTest(self): 42228f6c2f2SEnji Cooper """Tests the behavior of fail_fast and Disabled test suites enabled.""" 42328f6c2f2SEnji Cooper self.assertFailFastBehavior( 42428f6c2f2SEnji Cooper test_suite='DISABLED_HasDisabledSuite', 42528f6c2f2SEnji Cooper passed_count=1, 42628f6c2f2SEnji Cooper failure_count=1, 42728f6c2f2SEnji Cooper skipped_count=3, 42828f6c2f2SEnji Cooper suppressed_count=0, 42928f6c2f2SEnji Cooper run_disabled=True, 43028f6c2f2SEnji Cooper ) 43128f6c2f2SEnji Cooper self.assertNotFailFastBehavior( 43228f6c2f2SEnji Cooper test_suite='DISABLED_HasDisabledSuite', 43328f6c2f2SEnji Cooper passed_count=1, 43428f6c2f2SEnji Cooper failure_count=4, 43528f6c2f2SEnji Cooper skipped_count=0, 43628f6c2f2SEnji Cooper suppressed_count=0, 43728f6c2f2SEnji Cooper run_disabled=True, 43828f6c2f2SEnji Cooper ) 43928f6c2f2SEnji Cooper 44028f6c2f2SEnji Cooper if SUPPORTS_DEATH_TESTS: 44128f6c2f2SEnji Cooper 44228f6c2f2SEnji Cooper def testFlag_HasDeathTest(self): 44328f6c2f2SEnji Cooper """Tests the behavior of fail_fast and death tests.""" 44428f6c2f2SEnji Cooper self.assertFailFastBehavior( 44528f6c2f2SEnji Cooper test_suite='HasDeathTest', 44628f6c2f2SEnji Cooper passed_count=1, 44728f6c2f2SEnji Cooper failure_count=1, 44828f6c2f2SEnji Cooper skipped_count=3, 44928f6c2f2SEnji Cooper suppressed_count=0, 45028f6c2f2SEnji Cooper ) 45128f6c2f2SEnji Cooper self.assertNotFailFastBehavior( 45228f6c2f2SEnji Cooper test_suite='HasDeathTest', 45328f6c2f2SEnji Cooper passed_count=1, 45428f6c2f2SEnji Cooper failure_count=4, 45528f6c2f2SEnji Cooper skipped_count=0, 45628f6c2f2SEnji Cooper suppressed_count=0, 45728f6c2f2SEnji Cooper ) 45828f6c2f2SEnji Cooper 45928f6c2f2SEnji Cooper 46028f6c2f2SEnji Cooperif __name__ == '__main__': 46128f6c2f2SEnji Cooper gtest_test_utils.Main() 462