Skip to content

Commit 800231e

Browse files
authored
Honor $CC and $CXX in test runner (#132)
1 parent 5531968 commit 800231e

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

tests/run.sh

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ set -ueo pipefail
44
# Top-level test runner. Usage is "run.sh" to run tests in compile-only mode,
55
# or "run.sh <runwasi>" where <runwasi> is a WASI-capable runtime to run the
66
# tests in full compile and execute mode.
7+
#
8+
# By default this script will look for `clang` and `clang++` in $PATH and
9+
# assume that they are correctly configured with the sysroot in the default
10+
# location. Alternatively, exporting $CC and $CXX allow more flexibility. e.g:
11+
#
12+
# export CXX="<wasi-sdk>/bin/clang++ --sysroot <wasi-sdk>/share/wasi-sysroot"
13+
# export CCC="<wasi-sdk>/bin/clang --sysroot <wasi-sdk>/share/wasi-sysroot"
14+
#
715

816
# Determine the wasm runtime to use, if one is provided.
917
if [ $# -gt 0 ]; then
@@ -12,30 +20,37 @@ else
1220
runwasi=""
1321
fi
1422

15-
cd compile-only
23+
testdir=$(dirname $0)
24+
CC=${CC:=clang}
25+
CXX=${CXX:=clang++}
26+
27+
echo $CC
28+
echo $CXX
29+
30+
cd $testdir/compile-only
1631
for options in -O0 -O2 "-O2 -flto"; do
1732
echo "===== Testing compile-only with $options ====="
1833
for file in *.c; do
1934
echo "Testing compile-only $file..."
20-
../testcase.sh "" clang "$options" "$file"
35+
../testcase.sh "" "$CC" "$options" "$file"
2136
done
2237
for file in *.cc; do
2338
echo "Testing compile-only $file..."
24-
../testcase.sh "" clang++ "$options" "$file"
39+
../testcase.sh "" "$CXX" "$options" "$file"
2540
done
2641
done
2742
cd - >/dev/null
2843

29-
cd general
44+
cd $testdir/general
3045
for options in -O0 -O2 "-O2 -flto"; do
3146
echo "===== Testing with $options ====="
3247
for file in *.c; do
3348
echo "Testing $file..."
34-
../testcase.sh "$runwasi" clang "$options" "$file"
49+
../testcase.sh "$runwasi" "$CC" "$options" "$file"
3550
done
3651
for file in *.cc; do
3752
echo "Testing $file..."
38-
../testcase.sh "$runwasi" clang++ "$options" "$file"
53+
../testcase.sh "$runwasi" "$CXX" "$options" "$file"
3954
done
4055
done
4156
cd - >/dev/null

tests/testcase.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set -ueo pipefail
77
# Command-line parsing; this script is meant to be run from a higher-level
88
# script, so don't do anything fancy.
99
runwasi="$1"
10-
clang="$2"
10+
compiler="$2"
1111
options="$3"
1212
input="$4"
1313

@@ -27,7 +27,7 @@ fi
2727
echo "Testing $input..."
2828

2929
# Compile the testcase.
30-
"$clang" $options $file_options "$input" -o "$wasm"
30+
$compiler $options $file_options "$input" -o "$wasm"
3131

3232
# If we don't have a runwasi command, we're just doing compile-only testing.
3333
if [ "$runwasi" == "" ]; then

0 commit comments

Comments
 (0)