From e0d0dc9a80d76a32bdceabdb463a3e5f43e300ab Mon Sep 17 00:00:00 2001 From: Paolo Tranquilli Date: Tue, 4 Mar 2025 12:33:14 +0100 Subject: [PATCH] Rust: tweak qltest logs * verbosity is raised to DEBUG to have more information in the logs * color codes are now skipped in the `qltest.log` file * they are still printed out on the console when running with `--show-extractor-output`. --- rust/tools/qltest.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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