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`.
This commit is contained in:
Paolo Tranquilli
2025-03-04 12:33:14 +01:00
parent 0d1865d718
commit e0d0dc9a80

View File

@@ -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