1f92157deSopenharmony_ci#!/usr/bin/env python 2f92157deSopenharmony_ci# 3f92157deSopenharmony_ci# Copyright 2020 Google Inc. All Rights Reserved. 4f92157deSopenharmony_ci# 5f92157deSopenharmony_ci# Redistribution and use in source and binary forms, with or without 6f92157deSopenharmony_ci# modification, are permitted provided that the following conditions are 7f92157deSopenharmony_ci# met: 8f92157deSopenharmony_ci# 9f92157deSopenharmony_ci# * Redistributions of source code must retain the above copyright 10f92157deSopenharmony_ci# notice, this list of conditions and the following disclaimer. 11f92157deSopenharmony_ci# * Redistributions in binary form must reproduce the above 12f92157deSopenharmony_ci# copyright notice, this list of conditions and the following disclaimer 13f92157deSopenharmony_ci# in the documentation and/or other materials provided with the 14f92157deSopenharmony_ci# distribution. 15f92157deSopenharmony_ci# * Neither the name of Google Inc. nor the names of its 16f92157deSopenharmony_ci# contributors may be used to endorse or promote products derived from 17f92157deSopenharmony_ci# this software without specific prior written permission. 18f92157deSopenharmony_ci# 19f92157deSopenharmony_ci# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20f92157deSopenharmony_ci# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21f92157deSopenharmony_ci# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22f92157deSopenharmony_ci# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23f92157deSopenharmony_ci# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24f92157deSopenharmony_ci# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25f92157deSopenharmony_ci# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26f92157deSopenharmony_ci# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27f92157deSopenharmony_ci# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28f92157deSopenharmony_ci# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29f92157deSopenharmony_ci# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30f92157deSopenharmony_ci 31f92157deSopenharmony_ci"""Unit test for Google Test fail_fast. 32f92157deSopenharmony_ci 33f92157deSopenharmony_ciA user can specify if a Google Test program should continue test execution 34f92157deSopenharmony_ciafter a test failure via the GTEST_FAIL_FAST environment variable or the 35f92157deSopenharmony_ci--gtest_fail_fast flag. The default value of the flag can also be changed 36f92157deSopenharmony_ciby Bazel fail fast environment variable TESTBRIDGE_TEST_RUNNER_FAIL_FAST. 37f92157deSopenharmony_ci 38f92157deSopenharmony_ciThis script tests such functionality by invoking googletest-failfast-unittest_ 39f92157deSopenharmony_ci(a program written with Google Test) with different environments and command 40f92157deSopenharmony_ciline flags. 41f92157deSopenharmony_ci""" 42f92157deSopenharmony_ci 43f92157deSopenharmony_ciimport os 44f92157deSopenharmony_cifrom googletest.test import gtest_test_utils 45f92157deSopenharmony_ci 46f92157deSopenharmony_ci# Constants. 47f92157deSopenharmony_ci 48f92157deSopenharmony_ci# Bazel testbridge environment variable for fail fast 49f92157deSopenharmony_ciBAZEL_FAIL_FAST_ENV_VAR = 'TESTBRIDGE_TEST_RUNNER_FAIL_FAST' 50f92157deSopenharmony_ci 51f92157deSopenharmony_ci# The environment variable for specifying fail fast. 52f92157deSopenharmony_ciFAIL_FAST_ENV_VAR = 'GTEST_FAIL_FAST' 53f92157deSopenharmony_ci 54f92157deSopenharmony_ci# The command line flag for specifying fail fast. 55f92157deSopenharmony_ciFAIL_FAST_FLAG = 'gtest_fail_fast' 56f92157deSopenharmony_ci 57f92157deSopenharmony_ci# The command line flag to run disabled tests. 58f92157deSopenharmony_ciRUN_DISABLED_FLAG = 'gtest_also_run_disabled_tests' 59f92157deSopenharmony_ci 60f92157deSopenharmony_ci# The command line flag for specifying a filter. 61f92157deSopenharmony_ciFILTER_FLAG = 'gtest_filter' 62f92157deSopenharmony_ci 63f92157deSopenharmony_ci# Command to run the googletest-failfast-unittest_ program. 64f92157deSopenharmony_ciCOMMAND = gtest_test_utils.GetTestExecutablePath( 65f92157deSopenharmony_ci 'googletest-failfast-unittest_') 66f92157deSopenharmony_ci 67f92157deSopenharmony_ci# The command line flag to tell Google Test to output the list of tests it 68f92157deSopenharmony_ci# will run. 69f92157deSopenharmony_ciLIST_TESTS_FLAG = '--gtest_list_tests' 70f92157deSopenharmony_ci 71f92157deSopenharmony_ci# Indicates whether Google Test supports death tests. 72f92157deSopenharmony_ciSUPPORTS_DEATH_TESTS = 'HasDeathTest' in gtest_test_utils.Subprocess( 73f92157deSopenharmony_ci [COMMAND, LIST_TESTS_FLAG]).output 74f92157deSopenharmony_ci 75f92157deSopenharmony_ci# Utilities. 76f92157deSopenharmony_ci 77f92157deSopenharmony_cienviron = os.environ.copy() 78f92157deSopenharmony_ci 79f92157deSopenharmony_ci 80f92157deSopenharmony_cidef SetEnvVar(env_var, value): 81f92157deSopenharmony_ci """Sets the env variable to 'value'; unsets it when 'value' is None.""" 82f92157deSopenharmony_ci 83f92157deSopenharmony_ci if value is not None: 84f92157deSopenharmony_ci environ[env_var] = value 85f92157deSopenharmony_ci elif env_var in environ: 86f92157deSopenharmony_ci del environ[env_var] 87f92157deSopenharmony_ci 88f92157deSopenharmony_ci 89f92157deSopenharmony_cidef RunAndReturnOutput(test_suite=None, fail_fast=None, run_disabled=False): 90f92157deSopenharmony_ci """Runs the test program and returns its output.""" 91f92157deSopenharmony_ci 92f92157deSopenharmony_ci args = [] 93f92157deSopenharmony_ci xml_path = os.path.join(gtest_test_utils.GetTempDir(), 94f92157deSopenharmony_ci '.GTestFailFastUnitTest.xml') 95f92157deSopenharmony_ci args += ['--gtest_output=xml:' + xml_path] 96f92157deSopenharmony_ci if fail_fast is not None: 97f92157deSopenharmony_ci if isinstance(fail_fast, str): 98f92157deSopenharmony_ci args += ['--%s=%s' % (FAIL_FAST_FLAG, fail_fast)] 99f92157deSopenharmony_ci elif fail_fast: 100f92157deSopenharmony_ci args += ['--%s' % FAIL_FAST_FLAG] 101f92157deSopenharmony_ci else: 102f92157deSopenharmony_ci args += ['--no%s' % FAIL_FAST_FLAG] 103f92157deSopenharmony_ci if test_suite: 104f92157deSopenharmony_ci args += ['--%s=%s.*' % (FILTER_FLAG, test_suite)] 105f92157deSopenharmony_ci if run_disabled: 106f92157deSopenharmony_ci args += ['--%s' % RUN_DISABLED_FLAG] 107f92157deSopenharmony_ci txt_out = gtest_test_utils.Subprocess([COMMAND] + args, env=environ).output 108f92157deSopenharmony_ci with open(xml_path) as xml_file: 109f92157deSopenharmony_ci return txt_out, xml_file.read() 110f92157deSopenharmony_ci 111f92157deSopenharmony_ci 112f92157deSopenharmony_ci# The unit test. 113f92157deSopenharmony_ciclass GTestFailFastUnitTest(gtest_test_utils.TestCase): 114f92157deSopenharmony_ci """Tests the env variable or the command line flag for fail_fast.""" 115f92157deSopenharmony_ci 116f92157deSopenharmony_ci def testDefaultBehavior(self): 117f92157deSopenharmony_ci """Tests the behavior of not specifying the fail_fast.""" 118f92157deSopenharmony_ci 119f92157deSopenharmony_ci txt, _ = RunAndReturnOutput() 120f92157deSopenharmony_ci self.assertIn('22 FAILED TEST', txt) 121f92157deSopenharmony_ci 122f92157deSopenharmony_ci def testGoogletestFlag(self): 123f92157deSopenharmony_ci txt, _ = RunAndReturnOutput(test_suite='HasSimpleTest', fail_fast=True) 124f92157deSopenharmony_ci self.assertIn('1 FAILED TEST', txt) 125f92157deSopenharmony_ci self.assertIn('[ SKIPPED ] 3 tests', txt) 126f92157deSopenharmony_ci 127f92157deSopenharmony_ci txt, _ = RunAndReturnOutput(test_suite='HasSimpleTest', fail_fast=False) 128f92157deSopenharmony_ci self.assertIn('4 FAILED TEST', txt) 129f92157deSopenharmony_ci self.assertNotIn('[ SKIPPED ]', txt) 130f92157deSopenharmony_ci 131f92157deSopenharmony_ci def testGoogletestEnvVar(self): 132f92157deSopenharmony_ci """Tests the behavior of specifying fail_fast via Googletest env var.""" 133f92157deSopenharmony_ci 134f92157deSopenharmony_ci try: 135f92157deSopenharmony_ci SetEnvVar(FAIL_FAST_ENV_VAR, '1') 136f92157deSopenharmony_ci txt, _ = RunAndReturnOutput('HasSimpleTest') 137f92157deSopenharmony_ci self.assertIn('1 FAILED TEST', txt) 138f92157deSopenharmony_ci self.assertIn('[ SKIPPED ] 3 tests', txt) 139f92157deSopenharmony_ci 140f92157deSopenharmony_ci SetEnvVar(FAIL_FAST_ENV_VAR, '0') 141f92157deSopenharmony_ci txt, _ = RunAndReturnOutput('HasSimpleTest') 142f92157deSopenharmony_ci self.assertIn('4 FAILED TEST', txt) 143f92157deSopenharmony_ci self.assertNotIn('[ SKIPPED ]', txt) 144f92157deSopenharmony_ci finally: 145f92157deSopenharmony_ci SetEnvVar(FAIL_FAST_ENV_VAR, None) 146f92157deSopenharmony_ci 147f92157deSopenharmony_ci def testBazelEnvVar(self): 148f92157deSopenharmony_ci """Tests the behavior of specifying fail_fast via Bazel testbridge.""" 149f92157deSopenharmony_ci 150f92157deSopenharmony_ci try: 151f92157deSopenharmony_ci SetEnvVar(BAZEL_FAIL_FAST_ENV_VAR, '1') 152f92157deSopenharmony_ci txt, _ = RunAndReturnOutput('HasSimpleTest') 153f92157deSopenharmony_ci self.assertIn('1 FAILED TEST', txt) 154f92157deSopenharmony_ci self.assertIn('[ SKIPPED ] 3 tests', txt) 155f92157deSopenharmony_ci 156f92157deSopenharmony_ci SetEnvVar(BAZEL_FAIL_FAST_ENV_VAR, '0') 157f92157deSopenharmony_ci txt, _ = RunAndReturnOutput('HasSimpleTest') 158f92157deSopenharmony_ci self.assertIn('4 FAILED TEST', txt) 159f92157deSopenharmony_ci self.assertNotIn('[ SKIPPED ]', txt) 160f92157deSopenharmony_ci finally: 161f92157deSopenharmony_ci SetEnvVar(BAZEL_FAIL_FAST_ENV_VAR, None) 162f92157deSopenharmony_ci 163f92157deSopenharmony_ci def testFlagOverridesEnvVar(self): 164f92157deSopenharmony_ci """Tests precedence of flag over env var.""" 165f92157deSopenharmony_ci 166f92157deSopenharmony_ci try: 167f92157deSopenharmony_ci SetEnvVar(FAIL_FAST_ENV_VAR, '0') 168f92157deSopenharmony_ci txt, _ = RunAndReturnOutput('HasSimpleTest', True) 169f92157deSopenharmony_ci self.assertIn('1 FAILED TEST', txt) 170f92157deSopenharmony_ci self.assertIn('[ SKIPPED ] 3 tests', txt) 171f92157deSopenharmony_ci finally: 172f92157deSopenharmony_ci SetEnvVar(FAIL_FAST_ENV_VAR, None) 173f92157deSopenharmony_ci 174f92157deSopenharmony_ci def testGoogletestEnvVarOverridesBazelEnvVar(self): 175f92157deSopenharmony_ci """Tests that the Googletest native env var over Bazel testbridge.""" 176f92157deSopenharmony_ci 177f92157deSopenharmony_ci try: 178f92157deSopenharmony_ci SetEnvVar(BAZEL_FAIL_FAST_ENV_VAR, '0') 179f92157deSopenharmony_ci SetEnvVar(FAIL_FAST_ENV_VAR, '1') 180f92157deSopenharmony_ci txt, _ = RunAndReturnOutput('HasSimpleTest') 181f92157deSopenharmony_ci self.assertIn('1 FAILED TEST', txt) 182f92157deSopenharmony_ci self.assertIn('[ SKIPPED ] 3 tests', txt) 183f92157deSopenharmony_ci finally: 184f92157deSopenharmony_ci SetEnvVar(FAIL_FAST_ENV_VAR, None) 185f92157deSopenharmony_ci SetEnvVar(BAZEL_FAIL_FAST_ENV_VAR, None) 186f92157deSopenharmony_ci 187f92157deSopenharmony_ci def testEventListener(self): 188f92157deSopenharmony_ci txt, _ = RunAndReturnOutput(test_suite='HasSkipTest', fail_fast=True) 189f92157deSopenharmony_ci self.assertIn('1 FAILED TEST', txt) 190f92157deSopenharmony_ci self.assertIn('[ SKIPPED ] 3 tests', txt) 191f92157deSopenharmony_ci for expected_count, callback in [(1, 'OnTestSuiteStart'), 192f92157deSopenharmony_ci (5, 'OnTestStart'), 193f92157deSopenharmony_ci (5, 'OnTestEnd'), 194f92157deSopenharmony_ci (5, 'OnTestPartResult'), 195f92157deSopenharmony_ci (1, 'OnTestSuiteEnd')]: 196f92157deSopenharmony_ci self.assertEqual( 197f92157deSopenharmony_ci expected_count, txt.count(callback), 198f92157deSopenharmony_ci 'Expected %d calls to callback %s match count on output: %s ' % 199f92157deSopenharmony_ci (expected_count, callback, txt)) 200f92157deSopenharmony_ci 201f92157deSopenharmony_ci txt, _ = RunAndReturnOutput(test_suite='HasSkipTest', fail_fast=False) 202f92157deSopenharmony_ci self.assertIn('3 FAILED TEST', txt) 203f92157deSopenharmony_ci self.assertIn('[ SKIPPED ] 1 test', txt) 204f92157deSopenharmony_ci for expected_count, callback in [(1, 'OnTestSuiteStart'), 205f92157deSopenharmony_ci (5, 'OnTestStart'), 206f92157deSopenharmony_ci (5, 'OnTestEnd'), 207f92157deSopenharmony_ci (5, 'OnTestPartResult'), 208f92157deSopenharmony_ci (1, 'OnTestSuiteEnd')]: 209f92157deSopenharmony_ci self.assertEqual( 210f92157deSopenharmony_ci expected_count, txt.count(callback), 211f92157deSopenharmony_ci 'Expected %d calls to callback %s match count on output: %s ' % 212f92157deSopenharmony_ci (expected_count, callback, txt)) 213f92157deSopenharmony_ci 214f92157deSopenharmony_ci def assertXmlResultCount(self, result, count, xml): 215f92157deSopenharmony_ci self.assertEqual( 216f92157deSopenharmony_ci count, xml.count('result="%s"' % result), 217f92157deSopenharmony_ci 'Expected \'result="%s"\' match count of %s: %s ' % 218f92157deSopenharmony_ci (result, count, xml)) 219f92157deSopenharmony_ci 220f92157deSopenharmony_ci def assertXmlStatusCount(self, status, count, xml): 221f92157deSopenharmony_ci self.assertEqual( 222f92157deSopenharmony_ci count, xml.count('status="%s"' % status), 223f92157deSopenharmony_ci 'Expected \'status="%s"\' match count of %s: %s ' % 224f92157deSopenharmony_ci (status, count, xml)) 225f92157deSopenharmony_ci 226f92157deSopenharmony_ci def assertFailFastXmlAndTxtOutput(self, 227f92157deSopenharmony_ci fail_fast, 228f92157deSopenharmony_ci test_suite, 229f92157deSopenharmony_ci passed_count, 230f92157deSopenharmony_ci failure_count, 231f92157deSopenharmony_ci skipped_count, 232f92157deSopenharmony_ci suppressed_count, 233f92157deSopenharmony_ci run_disabled=False): 234f92157deSopenharmony_ci """Assert XML and text output of a test execution.""" 235f92157deSopenharmony_ci 236f92157deSopenharmony_ci txt, xml = RunAndReturnOutput(test_suite, fail_fast, run_disabled) 237f92157deSopenharmony_ci if failure_count > 0: 238f92157deSopenharmony_ci self.assertIn('%s FAILED TEST' % failure_count, txt) 239f92157deSopenharmony_ci if suppressed_count > 0: 240f92157deSopenharmony_ci self.assertIn('%s DISABLED TEST' % suppressed_count, txt) 241f92157deSopenharmony_ci if skipped_count > 0: 242f92157deSopenharmony_ci self.assertIn('[ SKIPPED ] %s tests' % skipped_count, txt) 243f92157deSopenharmony_ci self.assertXmlStatusCount('run', 244f92157deSopenharmony_ci passed_count + failure_count + skipped_count, xml) 245f92157deSopenharmony_ci self.assertXmlStatusCount('notrun', suppressed_count, xml) 246f92157deSopenharmony_ci self.assertXmlResultCount('completed', passed_count + failure_count, xml) 247f92157deSopenharmony_ci self.assertXmlResultCount('skipped', skipped_count, xml) 248f92157deSopenharmony_ci self.assertXmlResultCount('suppressed', suppressed_count, xml) 249f92157deSopenharmony_ci 250f92157deSopenharmony_ci def assertFailFastBehavior(self, 251f92157deSopenharmony_ci test_suite, 252f92157deSopenharmony_ci passed_count, 253f92157deSopenharmony_ci failure_count, 254f92157deSopenharmony_ci skipped_count, 255f92157deSopenharmony_ci suppressed_count, 256f92157deSopenharmony_ci run_disabled=False): 257f92157deSopenharmony_ci """Assert --fail_fast via flag.""" 258f92157deSopenharmony_ci 259f92157deSopenharmony_ci for fail_fast in ('true', '1', 't', True): 260f92157deSopenharmony_ci self.assertFailFastXmlAndTxtOutput(fail_fast, test_suite, passed_count, 261f92157deSopenharmony_ci failure_count, skipped_count, 262f92157deSopenharmony_ci suppressed_count, run_disabled) 263f92157deSopenharmony_ci 264f92157deSopenharmony_ci def assertNotFailFastBehavior(self, 265f92157deSopenharmony_ci test_suite, 266f92157deSopenharmony_ci passed_count, 267f92157deSopenharmony_ci failure_count, 268f92157deSopenharmony_ci skipped_count, 269f92157deSopenharmony_ci suppressed_count, 270f92157deSopenharmony_ci run_disabled=False): 271f92157deSopenharmony_ci """Assert --nofail_fast via flag.""" 272f92157deSopenharmony_ci 273f92157deSopenharmony_ci for fail_fast in ('false', '0', 'f', False): 274f92157deSopenharmony_ci self.assertFailFastXmlAndTxtOutput(fail_fast, test_suite, passed_count, 275f92157deSopenharmony_ci failure_count, skipped_count, 276f92157deSopenharmony_ci suppressed_count, run_disabled) 277f92157deSopenharmony_ci 278f92157deSopenharmony_ci def testFlag_HasFixtureTest(self): 279f92157deSopenharmony_ci """Tests the behavior of fail_fast and TEST_F.""" 280f92157deSopenharmony_ci self.assertFailFastBehavior( 281f92157deSopenharmony_ci test_suite='HasFixtureTest', 282f92157deSopenharmony_ci passed_count=1, 283f92157deSopenharmony_ci failure_count=1, 284f92157deSopenharmony_ci skipped_count=3, 285f92157deSopenharmony_ci suppressed_count=0) 286f92157deSopenharmony_ci self.assertNotFailFastBehavior( 287f92157deSopenharmony_ci test_suite='HasFixtureTest', 288f92157deSopenharmony_ci passed_count=1, 289f92157deSopenharmony_ci failure_count=4, 290f92157deSopenharmony_ci skipped_count=0, 291f92157deSopenharmony_ci suppressed_count=0) 292f92157deSopenharmony_ci 293f92157deSopenharmony_ci def testFlag_HasSimpleTest(self): 294f92157deSopenharmony_ci """Tests the behavior of fail_fast and TEST.""" 295f92157deSopenharmony_ci self.assertFailFastBehavior( 296f92157deSopenharmony_ci test_suite='HasSimpleTest', 297f92157deSopenharmony_ci passed_count=1, 298f92157deSopenharmony_ci failure_count=1, 299f92157deSopenharmony_ci skipped_count=3, 300f92157deSopenharmony_ci suppressed_count=0) 301f92157deSopenharmony_ci self.assertNotFailFastBehavior( 302f92157deSopenharmony_ci test_suite='HasSimpleTest', 303f92157deSopenharmony_ci passed_count=1, 304f92157deSopenharmony_ci failure_count=4, 305f92157deSopenharmony_ci skipped_count=0, 306f92157deSopenharmony_ci suppressed_count=0) 307f92157deSopenharmony_ci 308f92157deSopenharmony_ci def testFlag_HasParametersTest(self): 309f92157deSopenharmony_ci """Tests the behavior of fail_fast and TEST_P.""" 310f92157deSopenharmony_ci self.assertFailFastBehavior( 311f92157deSopenharmony_ci test_suite='HasParametersSuite/HasParametersTest', 312f92157deSopenharmony_ci passed_count=0, 313f92157deSopenharmony_ci failure_count=1, 314f92157deSopenharmony_ci skipped_count=3, 315f92157deSopenharmony_ci suppressed_count=0) 316f92157deSopenharmony_ci self.assertNotFailFastBehavior( 317f92157deSopenharmony_ci test_suite='HasParametersSuite/HasParametersTest', 318f92157deSopenharmony_ci passed_count=0, 319f92157deSopenharmony_ci failure_count=4, 320f92157deSopenharmony_ci skipped_count=0, 321f92157deSopenharmony_ci suppressed_count=0) 322f92157deSopenharmony_ci 323f92157deSopenharmony_ci def testFlag_HasDisabledTest(self): 324f92157deSopenharmony_ci """Tests the behavior of fail_fast and Disabled test cases.""" 325f92157deSopenharmony_ci self.assertFailFastBehavior( 326f92157deSopenharmony_ci test_suite='HasDisabledTest', 327f92157deSopenharmony_ci passed_count=1, 328f92157deSopenharmony_ci failure_count=1, 329f92157deSopenharmony_ci skipped_count=2, 330f92157deSopenharmony_ci suppressed_count=1, 331f92157deSopenharmony_ci run_disabled=False) 332f92157deSopenharmony_ci self.assertNotFailFastBehavior( 333f92157deSopenharmony_ci test_suite='HasDisabledTest', 334f92157deSopenharmony_ci passed_count=1, 335f92157deSopenharmony_ci failure_count=3, 336f92157deSopenharmony_ci skipped_count=0, 337f92157deSopenharmony_ci suppressed_count=1, 338f92157deSopenharmony_ci run_disabled=False) 339f92157deSopenharmony_ci 340f92157deSopenharmony_ci def testFlag_HasDisabledRunDisabledTest(self): 341f92157deSopenharmony_ci """Tests the behavior of fail_fast and Disabled test cases enabled.""" 342f92157deSopenharmony_ci self.assertFailFastBehavior( 343f92157deSopenharmony_ci test_suite='HasDisabledTest', 344f92157deSopenharmony_ci passed_count=1, 345f92157deSopenharmony_ci failure_count=1, 346f92157deSopenharmony_ci skipped_count=3, 347f92157deSopenharmony_ci suppressed_count=0, 348f92157deSopenharmony_ci run_disabled=True) 349f92157deSopenharmony_ci self.assertNotFailFastBehavior( 350f92157deSopenharmony_ci test_suite='HasDisabledTest', 351f92157deSopenharmony_ci passed_count=1, 352f92157deSopenharmony_ci failure_count=4, 353f92157deSopenharmony_ci skipped_count=0, 354f92157deSopenharmony_ci suppressed_count=0, 355f92157deSopenharmony_ci run_disabled=True) 356f92157deSopenharmony_ci 357f92157deSopenharmony_ci def testFlag_HasDisabledSuiteTest(self): 358f92157deSopenharmony_ci """Tests the behavior of fail_fast and Disabled test suites.""" 359f92157deSopenharmony_ci self.assertFailFastBehavior( 360f92157deSopenharmony_ci test_suite='DISABLED_HasDisabledSuite', 361f92157deSopenharmony_ci passed_count=0, 362f92157deSopenharmony_ci failure_count=0, 363f92157deSopenharmony_ci skipped_count=0, 364f92157deSopenharmony_ci suppressed_count=5, 365f92157deSopenharmony_ci run_disabled=False) 366f92157deSopenharmony_ci self.assertNotFailFastBehavior( 367f92157deSopenharmony_ci test_suite='DISABLED_HasDisabledSuite', 368f92157deSopenharmony_ci passed_count=0, 369f92157deSopenharmony_ci failure_count=0, 370f92157deSopenharmony_ci skipped_count=0, 371f92157deSopenharmony_ci suppressed_count=5, 372f92157deSopenharmony_ci run_disabled=False) 373f92157deSopenharmony_ci 374f92157deSopenharmony_ci def testFlag_HasDisabledSuiteRunDisabledTest(self): 375f92157deSopenharmony_ci """Tests the behavior of fail_fast and Disabled test suites enabled.""" 376f92157deSopenharmony_ci self.assertFailFastBehavior( 377f92157deSopenharmony_ci test_suite='DISABLED_HasDisabledSuite', 378f92157deSopenharmony_ci passed_count=1, 379f92157deSopenharmony_ci failure_count=1, 380f92157deSopenharmony_ci skipped_count=3, 381f92157deSopenharmony_ci suppressed_count=0, 382f92157deSopenharmony_ci run_disabled=True) 383f92157deSopenharmony_ci self.assertNotFailFastBehavior( 384f92157deSopenharmony_ci test_suite='DISABLED_HasDisabledSuite', 385f92157deSopenharmony_ci passed_count=1, 386f92157deSopenharmony_ci failure_count=4, 387f92157deSopenharmony_ci skipped_count=0, 388f92157deSopenharmony_ci suppressed_count=0, 389f92157deSopenharmony_ci run_disabled=True) 390f92157deSopenharmony_ci 391f92157deSopenharmony_ci if SUPPORTS_DEATH_TESTS: 392f92157deSopenharmony_ci 393f92157deSopenharmony_ci def testFlag_HasDeathTest(self): 394f92157deSopenharmony_ci """Tests the behavior of fail_fast and death tests.""" 395f92157deSopenharmony_ci self.assertFailFastBehavior( 396f92157deSopenharmony_ci test_suite='HasDeathTest', 397f92157deSopenharmony_ci passed_count=1, 398f92157deSopenharmony_ci failure_count=1, 399f92157deSopenharmony_ci skipped_count=3, 400f92157deSopenharmony_ci suppressed_count=0) 401f92157deSopenharmony_ci self.assertNotFailFastBehavior( 402f92157deSopenharmony_ci test_suite='HasDeathTest', 403f92157deSopenharmony_ci passed_count=1, 404f92157deSopenharmony_ci failure_count=4, 405f92157deSopenharmony_ci skipped_count=0, 406f92157deSopenharmony_ci suppressed_count=0) 407f92157deSopenharmony_ci 408f92157deSopenharmony_ci 409f92157deSopenharmony_ciif __name__ == '__main__': 410f92157deSopenharmony_ci gtest_test_utils.Main() 411