Skip to content

Commit 91466cd

Browse files
committed
tests: Update test runner to fail early if prerequisites are missing
This change updates the test runner script to check for the presence of required compilers (clang, gcc) before running tests.
1 parent 7249120 commit 91466cd

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

run-tests.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
import glob
33
import os
4+
import shutil
45
import subprocess
56
import 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+
1630
commands = []
1731

1832
for 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

Comments
 (0)