diff --git a/rust/tools/qltest.sh b/rust/tools/qltest.sh index 1d586826314..6f7370df610 100755 --- a/rust/tools/qltest.sh +++ b/rust/tools/qltest.sh @@ -1,10 +1,21 @@ #!/bin/bash set -eu +set -o pipefail export RUST_BACKTRACE=full QLTEST_LOG="$CODEQL_EXTRACTOR_RUST_LOG_DIR"/qltest.log -if ! "$CODEQL_EXTRACTOR_RUST_ROOT/tools/$CODEQL_PLATFORM/extractor" --qltest >> "$QLTEST_LOG" 2>&1; then - cat "$QLTEST_LOG" +TMP_OUT="$(mktemp)" +trap 'rm -f "$TMP_OUT"' EXIT +# put full-color output on the side, but remove the color codes from the log file +# also, print (colored) output only in case of failure +if ! "$CODEQL_EXTRACTOR_RUST_ROOT/tools/$CODEQL_PLATFORM/extractor" \ + --qltest \ + --logging-verbosity=progress+ \ + 2>&1 \ + | tee "$TMP_OUT" \ + | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' \ + > "$QLTEST_LOG"; then + cat "$TMP_OUT" exit 1 fi