1f92157deSopenharmony_ci#!/usr/bin/env python 2f92157deSopenharmony_ci# 3f92157deSopenharmony_ci# Copyright 2019 Google LLC. 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"""Tests Google Test's gtest skip in environment setup behavior. 31f92157deSopenharmony_ci 32f92157deSopenharmony_ciThis script invokes gtest_skip_in_environment_setup_test_ and verifies its 33f92157deSopenharmony_cioutput. 34f92157deSopenharmony_ci""" 35f92157deSopenharmony_ci 36f92157deSopenharmony_ciimport re 37f92157deSopenharmony_ci 38f92157deSopenharmony_cifrom googletest.test import gtest_test_utils 39f92157deSopenharmony_ci 40f92157deSopenharmony_ci# Path to the gtest_skip_in_environment_setup_test binary 41f92157deSopenharmony_ciEXE_PATH = gtest_test_utils.GetTestExecutablePath('gtest_skip_test') 42f92157deSopenharmony_ci 43f92157deSopenharmony_ciOUTPUT = gtest_test_utils.Subprocess([EXE_PATH]).output 44f92157deSopenharmony_ci 45f92157deSopenharmony_ci 46f92157deSopenharmony_ci# Test. 47f92157deSopenharmony_ciclass SkipEntireEnvironmentTest(gtest_test_utils.TestCase): 48f92157deSopenharmony_ci 49f92157deSopenharmony_ci def testSkipEntireEnvironmentTest(self): 50f92157deSopenharmony_ci self.assertIn('Skipped\nskipping single test\n', OUTPUT) 51f92157deSopenharmony_ci skip_fixture = 'Skipped\nskipping all tests for this fixture\n' 52f92157deSopenharmony_ci self.assertIsNotNone( 53f92157deSopenharmony_ci re.search(skip_fixture + '.*' + skip_fixture, OUTPUT, flags=re.DOTALL), 54f92157deSopenharmony_ci repr(OUTPUT)) 55f92157deSopenharmony_ci self.assertNotIn('FAILED', OUTPUT) 56f92157deSopenharmony_ci 57f92157deSopenharmony_ci 58f92157deSopenharmony_ciif __name__ == '__main__': 59f92157deSopenharmony_ci gtest_test_utils.Main() 60