From 63c43d7fb463529219a4de4d1fddb8953056346d Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 23 Oct 2023 13:00:51 -0400 Subject: tests: Clean up verbose logging a bit --- tests/run.sh | 56 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 20 deletions(-) (limited to 'tests') diff --git a/tests/run.sh b/tests/run.sh index d581476..f93cb4b 100644 --- a/tests/run.sh +++ b/tests/run.sh @@ -239,25 +239,41 @@ bfs_verbose() { } bfs_verbose_impl() { - printf "${GRN}%q${RST} " "${BFS[@]}" + printf "${GRN}%q${RST}" "${BFS[0]}" + if ((${#BFS[@]} > 1)); then + printf " ${GRN}%q${RST}" "${BFS[1:]}" + fi - local expr_started= + local expr_started=0 color for arg; do - if [[ $arg == -[A-Z]* ]]; then - printf "${CYN}%q${RST} " "$arg" - elif [[ $arg == [\(!] || $arg == -[ao] || $arg == -and || $arg == -or || $arg == -not ]]; then - expr_started=yes - printf "${RED}%q${RST} " "$arg" - elif [[ $expr_started && $arg == [\),] ]]; then - printf "${RED}%q${RST} " "$arg" - elif [[ $arg == -?* ]]; then - expr_started=yes - printf "${BLU}%q${RST} " "$arg" - elif [ "$expr_started" ]; then - printf "${BLD}%q${RST} " "$arg" - else - printf "${MAG}%q${RST} " "$arg" - fi + case "$arg" in + -[A-Z]*|-[dsxf]|-j*) + color="${CYN}" + ;; + \(|!|-[ao]|-and|-or|-not|-exclude) + expr_started=1 + color="${RED}" + ;; + \)|,) + if ((expr_started)); then + color="${RED}" + else + color="${MAG}" + fi + ;; + -?*) + expr_started=1 + color="${BLU}" + ;; + *) + if ((expr_started)); then + color="${BLD}" + else + color="${MAG}" + fi + ;; + esac + printf " ${color}%q${RST}" "$arg" done printf '\n' @@ -336,8 +352,8 @@ make_xattrs() { EX_DIFF=20 # Detect colored diff support -if ((COLOR_STDERR)) && diff --color=always /dev/null /dev/null 2>/dev/null; then - DIFF="diff --color=always" +if diff --color /dev/null /dev/null 2>/dev/null; then + DIFF="diff --color" else DIFF="diff" fi @@ -354,7 +370,7 @@ diff_output() { if ((UPDATE)); then cp "$OUT" "$GOLD" else - $DIFF -u "$GOLD" "$OUT" >&2 + $DIFF -u "$GOLD" "$OUT" >&4 fi } -- cgit v1.2.3