From fdd4d8510fcec17ff29477e7b243dadd8e7435f7 Mon Sep 17 00:00:00 2001 From: Nick Terrell Date: Wed, 23 May 2018 18:46:38 -0700 Subject: [PATCH] Improve compiler detection to work on Mac --- tests/fuzz/fuzz.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/fuzz/fuzz.py b/tests/fuzz/fuzz.py index bc6611fd..04d9c600 100755 --- a/tests/fuzz/fuzz.py +++ b/tests/fuzz/fuzz.py @@ -147,15 +147,18 @@ def compiler_version(cc, cxx): """ cc_version_bytes = subprocess.check_output([cc, "--version"]) cxx_version_bytes = subprocess.check_output([cxx, "--version"]) - if cc_version_bytes.startswith(b'clang'): - assert(cxx_version_bytes.startswith(b'clang')) + compiler = None + version = None + if b'clang' in cc_version_bytes: + assert(b'clang' in cxx_version_bytes) compiler = 'clang' - if cc_version_bytes.startswith(b'gcc'): - assert(cxx_version_bytes.startswith(b'g++')) + elif b'gcc' in cc_version_bytes: + assert(b'gcc' in cxx_version_bytes) compiler = 'gcc' - version_regex = b'([0-9])+\.([0-9])+\.([0-9])+' - version_match = re.search(version_regex, cc_version_bytes) - version = tuple(int(version_match.group(i)) for i in range(1, 4)) + if compiler is not None: + version_regex = b'([0-9])+\.([0-9])+\.([0-9])+' + version_match = re.search(version_regex, cc_version_bytes) + version = tuple(int(version_match.group(i)) for i in range(1, 4)) return compiler, version