11
22import glob
33import os
4+ import shutil
45import subprocess
56import sys
67
@@ -13,6 +14,19 @@ def cleanup(out):
1314 ret = ret + s
1415 return ret
1516
17+
18+ # Check for required compilers and exit if any are missing
19+ CLANG_EXE = shutil .which ('clang' )
20+ if not CLANG_EXE :
21+ sys .exit ('Failed to run tests: clang compiler not found' )
22+
23+ GCC_EXE = shutil .which ('gcc' )
24+ if not GCC_EXE :
25+ sys .exit ('Failed to run tests: gcc compiler not found' )
26+
27+ SIMPLECPP_EXE = './simplecpp'
28+
29+
1630commands = []
1731
1832for f in sorted (glob .glob (os .path .expanduser ('testsuite/clang-preprocessor-tests/*.c*' ))):
@@ -102,12 +116,12 @@ def run(compiler_executable, compiler_args):
102116 numberOfSkipped = numberOfSkipped + 1
103117 continue
104118
105- clang_output = run ('clang' , cmd .split (' ' ))[1 ]
119+ clang_output = run (CLANG_EXE , cmd .split (' ' ))[1 ]
106120
107- gcc_output = run ('gcc' , cmd .split (' ' ))[1 ]
121+ gcc_output = run (GCC_EXE , cmd .split (' ' ))[1 ]
108122
109123 # -E is not supported and we bail out on unknown options
110- simplecpp_ec , simplecpp_output , simplecpp_err = run ('./simplecpp' , cmd .replace ('-E ' , '' , 1 ).split (' ' ))
124+ simplecpp_ec , simplecpp_output , simplecpp_err = run (SIMPLECPP_EXE , cmd .replace ('-E ' , '' , 1 ).split (' ' ))
111125
112126 if simplecpp_output != clang_output and simplecpp_output != gcc_output :
113127 filename = cmd [cmd .rfind ('/' )+ 1 :]
0 commit comments