diff --git a/tests/run.sh b/tests/run.sh index 0bc1457..52f3ecc 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -1,21 +1,27 @@ #!/bin/bash set -ueo pipefail -# Top-level test runner. Usage is "run.sh " where is a -# WASI-capable runtime. +# Top-level test runner. Usage is "run.sh" to run tests in compile-only mode, +# or "run.sh " where is a WASI-capable runtime to run the +# tests in full compile and execute mode. -runwasi="$1" +# Determine the wasm runtime to use, if one is provided. +if [ $# -gt 0 ]; then + runwasi="$1" +else + runwasi="" +fi cd compile-only for options in -O0 -O2 "-O2 -flto"; do echo "===== Testing compile-only with $options =====" for file in *.c; do echo "Testing compile-only $file..." - ../testcase.sh true clang "$options" "$file" + ../testcase.sh "" clang "$options" "$file" done for file in *.cc; do echo "Testing compile-only $file..." - ../testcase.sh true clang++ "$options" "$file" + ../testcase.sh "" clang++ "$options" "$file" done done cd - >/dev/null diff --git a/tests/testcase.sh b/tests/testcase.sh index eee2b85..61deefb 100755 --- a/tests/testcase.sh +++ b/tests/testcase.sh @@ -26,8 +26,15 @@ fi echo "Testing $input..." -# Determine the input file to write to stdin. +# Compile the testcase. "$clang" $options $file_options "$input" -o "$wasm" + +# If we don't have a runwasi command, we're just doing compile-only testing. +if [ "$runwasi" == "" ]; then + exit 0 +fi + +# Determine the input file to write to stdin. if [ -e "$input.stdin" ]; then stdin="$input.stdin" else