[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [chutney/master] Make warnings summary mode even quieter



commit 9936947b6dee8035c29ca596db310a5e3c0142b6
Author: teor <teor2345@xxxxxxxxx>
Date:   Mon Feb 27 16:56:02 2017 +1100

    Make warnings summary mode even quieter
    
    Follow-up to #21371.
---
 tools/warnings.sh | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/tools/warnings.sh b/tools/warnings.sh
index dfe5de7..761375e 100755
--- a/tools/warnings.sh
+++ b/tools/warnings.sh
@@ -22,27 +22,43 @@ if [ -d "$PWD/$CHUTNEY_PATH" -a -x "$PWD/$CHUTNEY_PATH/chutney" ]; then
 fi
 
 function show_warnings() {
+    # Work out the file and filter settings
     if [ "$CHUTNEY_WARNINGS_SUMMARY" = true ]; then
-        echo "${GREEN}All `basename $1`:${NC}"
         FILE="$1/*/$LOG_FILE"
     else
-        echo "${GREEN}Node `basename $1`:${NC}"
         FILE="$1/$LOG_FILE"
     fi
     if [ "$CHUTNEY_WARNINGS_IGNORE_EXPECTED" = true -a \
         -e "$IGNORE_FILE" ]; then
         CAT="grep -v -f"
-        echo " ${GREEN}(Ignoring expected warnings, run chutney/tools/warnings.sh to see all warnings)${NC}"
     else
         CAT=cat
         IGNORE_FILE=
     fi
-    # Label errs as "Warning:", they're infrequent enough it doesn't matter
-    $CAT $IGNORE_FILE $FILE | \
-    sed -n -E 's/^.*\[(warn|err)\]//p' | sort | uniq -c | \
-    sed -e 's/^\s*//' -e "s/ *\([0-9][0-9]*\) *\(.*\)/ ${YELLOW}Warning:${NC} \2${YELLOW} Number: \1${NC}/"
+    # Silence any messages if we are in summary mode, and there are no warnings
+    # must be kept in sync with the filter commands below
+    if [ `$CAT $IGNORE_FILE $FILE | $SED_E "$FILTER" | wc -c` -eq 0 -a \
+        "$CHUTNEY_WARNINGS_SUMMARY" = true ]; then
+        ECHO=true
+    else
+        ECHO=echo
+    fi
+    # Give context to the warnings we're about to display
+    if [ "$CHUTNEY_WARNINGS_SUMMARY" = true ]; then
+        $ECHO "${GREEN}All `basename $1`:${NC}"
+    else
+        $ECHO "${GREEN}Node `basename $1`:${NC}"
+    fi
+    if [ "$CHUTNEY_WARNINGS_IGNORE_EXPECTED" = true -a \
+        -e "$IGNORE_FILE" ]; then
+        $ECHO " ${GREEN}(Ignoring expected warnings, run chutney/tools/warnings.sh to see all warnings)${NC}"
+    fi
+    # Display the warnings, after filtering and counting occurrences
+    # must be kept in sync with the filter commands above
+    $CAT $IGNORE_FILE $FILE | $SED_E "$FILTER" | sort | uniq -c | \
+    sed -e 's/^\s*//' -e "s/ *\([0-9][0-9]*\) *\(.*\)/${YELLOW}Warning:${NC} \2${YELLOW} Number: \1${NC}/"
     if [ "$CHUTNEY_WARNINGS_SUMMARY" != true ]; then
-        echo ""
+        $ECHO ""
     fi
 }
 
@@ -67,6 +83,9 @@ CHUTNEY_WARNINGS_IGNORE_EXPECTED=${CHUTNEY_WARNINGS_IGNORE_EXPECTED:-0}
 IGNORE_FILE="$CHUTNEY_PATH/tools/ignore.warnings"
 # merge all log files into one before counting entries
 CHUTNEY_WARNINGS_SUMMARY=${CHUTNEY_WARNINGS_SUMMARY:-0}
+SED_E='sed -n -E'
+# Label errs as "Warning:", they're infrequent enough it doesn't matter
+FILTER='s/^.*\[(warn|err)\]//p'
 
 [ -d "$DEST" ] || { echo "$NAME: no logs available"; exit 1; }
 if [ $# -eq 0 ];

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits