11
22import glob
33import os
4+ import shutil
45import subprocess
56import sys
67
@@ -13,6 +14,22 @@ 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+ os .environ ["PATH" ] = os .getcwd () + os .pathsep + os .environ ["PATH" ]
28+ SIMPLECPP_EXE = shutil .which ('simplecpp' )
29+ if not SIMPLECPP_EXE :
30+ sys .exit ('Failed to run tests: simplecpp compiler not found' )
31+
32+
1633commands = []
1734
1835for f in sorted (glob .glob (os .path .expanduser ('testsuite/clang-preprocessor-tests/*.c*' ))):
@@ -102,12 +119,12 @@ def run(compiler_executable, compiler_args):
102119 numberOfSkipped = numberOfSkipped + 1
103120 continue
104121
105- clang_output = run ('clang' , cmd .split (' ' ))[1 ]
122+ clang_output = run (CLANG_EXE , cmd .split (' ' ))[1 ]
106123
107- gcc_output = run ('gcc' , cmd .split (' ' ))[1 ]
124+ gcc_output = run (GCC_EXE , cmd .split (' ' ))[1 ]
108125
109126 # -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 (' ' ))
127+ simplecpp_ec , simplecpp_output , simplecpp_err = run (SIMPLECPP_EXE , cmd .replace ('-E ' , '' , 1 ).split (' ' ))
111128
112129 if simplecpp_output != clang_output and simplecpp_output != gcc_output :
113130 filename = cmd [cmd .rfind ('/' )+ 1 :]
0 commit comments