Skip to content

Commit d187625

Browse files
authored
Merge pull request #18918 from github/redsun82/rust-tweak-qltest-logs
Rust: tweak qltest logs
2 parents b945466 + 4d10c41 commit d187625

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

rust/tools/qltest.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set "RUST_BACKTRACE=full"
44
set "QLTEST_LOG=%CODEQL_EXTRACTOR_RUST_LOG_DIR%/qltest.log"
55

6-
type NUL && "%CODEQL_EXTRACTOR_RUST_ROOT%/tools/%CODEQL_PLATFORM%/extractor" --qltest >"%QLTEST_LOG%" 2>&1
6+
type NUL && "%CODEQL_EXTRACTOR_RUST_ROOT%/tools/%CODEQL_PLATFORM%/extractor" --qltest --logging-verbosity=progress+ >"%QLTEST_LOG%" 2>&1
77

88
if %ERRORLEVEL% neq 0 (
99
type "%QLTEST_LOG%"

rust/tools/qltest.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
#!/bin/bash
22

33
set -eu
4+
set -o pipefail
45

56
export RUST_BACKTRACE=full
67
QLTEST_LOG="$CODEQL_EXTRACTOR_RUST_LOG_DIR"/qltest.log
7-
if ! "$CODEQL_EXTRACTOR_RUST_ROOT/tools/$CODEQL_PLATFORM/extractor" --qltest >> "$QLTEST_LOG" 2>&1; then
8-
cat "$QLTEST_LOG"
8+
mkdir -p "$CODEQL_EXTRACTOR_RUST_SCRATCH_DIR"
9+
TMP_OUT="$(mktemp --tmpdir="$CODEQL_EXTRACTOR_RUST_SCRATCH_DIR" qltest-XXXXXX.log))"
10+
trap 'rm -f "$TMP_OUT"' EXIT
11+
# put full-color output on the side, but remove the color codes from the log file
12+
# also, print (colored) output only in case of failure
13+
if ! "$CODEQL_EXTRACTOR_RUST_ROOT/tools/$CODEQL_PLATFORM/extractor" \
14+
--qltest \
15+
--logging-verbosity=progress+ \
16+
2>&1 \
17+
| tee "$TMP_OUT" \
18+
| sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' \
19+
> "$QLTEST_LOG"; then
20+
cat "$TMP_OUT"
921
exit 1
1022
fi

0 commit comments

Comments
 (0)