Skip to content

Commit 22eb2de

Browse files
committed
Fix GTestHelpTest.TestHelpFlag on FreeBSD
The test supported a variety of BSDs, including kFreeBSD, but not FreeBSD. Move the BSD checks to a separate function and support checking for FreeBSD, in addition to kFreeBSD. Signed-off-by: Enji Cooper <[email protected]>
1 parent 6abc9e3 commit 22eb2de

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

googletest/test/gtest_help_test.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,21 @@
4343
from googletest.test import gtest_test_utils
4444

4545

46+
FREEBSD = ('FreeBSD', 'GNU/kFreeBSD')
47+
NETBSD = ('NetBSD', )
48+
OPENBSD = ('OpenBSD', )
49+
50+
def is_bsd_based_os() -> bool:
51+
"""Determine whether or not the OS is BSD-based."""
52+
if os.name != 'posix':
53+
return False
54+
55+
return os.uname()[0] in (FREEBSD + NETBSD + OPENBSD)
56+
57+
4658
IS_DARWIN = os.name == 'posix' and os.uname()[0] == 'Darwin'
4759
IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
4860
IS_GNUHURD = os.name == 'posix' and os.uname()[0] == 'GNU'
49-
IS_GNUKFREEBSD = os.name == 'posix' and os.uname()[0] == 'GNU/kFreeBSD'
50-
IS_OPENBSD = os.name == 'posix' and os.uname()[0] == 'OpenBSD'
5161
IS_WINDOWS = os.name == 'nt'
5262

5363
PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_help_test_')
@@ -136,7 +146,7 @@ def TestHelpFlag(self, flag):
136146

137147
self.assertTrue(HELP_REGEX.search(output), output)
138148

139-
if IS_DARWIN or IS_LINUX or IS_GNUHURD or IS_GNUKFREEBSD or IS_OPENBSD:
149+
if IS_DARWIN or IS_LINUX or IS_GNUHURD or is_bsd_based_os():
140150
self.assertIn(STREAM_RESULT_TO_FLAG, output)
141151
else:
142152
self.assertNotIn(STREAM_RESULT_TO_FLAG, output)

0 commit comments

Comments
 (0)