Files
codeql/swift/tools/qltest.sh
Paolo Tranquilli 2311e1c5ab Swift: remove test sdk
The test sdk that we were prebuilding to run ql tests is actually not
needed, as the `resource-dir` we package for cross-version compatibility
is enough for running qltests as well.
2024-02-19 13:28:48 +01:00

29 lines
1002 B
Bash
Executable File

#!/bin/bash
mkdir -p "$CODEQL_EXTRACTOR_SWIFT_TRAP_DIR"
QLTEST_LOG="$CODEQL_EXTRACTOR_SWIFT_LOG_DIR"/qltest.log
EXTRACTOR="$CODEQL_EXTRACTOR_SWIFT_ROOT/tools/$CODEQL_PLATFORM/extractor"
RESOURCE_DIR="$CODEQL_EXTRACTOR_SWIFT_ROOT/resource-dir/$CODEQL_PLATFORM"
export CODEQL_EXTRACTOR_SWIFT_LOG_LEVELS=${CODEQL_EXTRACTOR_SWIFT_LOG_LEVELS:-out:text:no_logs,out:console:info}
for src in *.swift; do
env=()
opts=(-resource-dir "$RESOURCE_DIR" -c -primary-file "$src")
opts+=($(sed -n '1 s=//codeql-extractor-options:==p' $src))
expected_status=$(sed -n 's=//codeql-extractor-expected-status:[[:space:]]*==p' $src)
expected_status=${expected_status:-0}
env+=($(sed -n '1 s=//codeql-extractor-env:==p' $src))
echo >> $QLTEST_LOG
env "${env[@]}" "$EXTRACTOR" "${opts[@]}" >> $QLTEST_LOG 2>&1
actual_status=$?
if [[ $actual_status != $expected_status ]]; then
FAILED=1
fi
done
if [ -n "$FAILED" ]; then
cat "$QLTEST_LOG" # Show compiler errors on extraction failure
exit 1
fi