Files
pipelines/app/tool/analyze.sh
T
alan 941d2a7148 memwatch: quiet bounded test summary off a terminal; bounded analyze wrapper
run.sh now records flutter's JSON results beside the log and prints a
summary from tool/memwatch/summary.dart: one verdict line (pass/fail/skip
counts, peak MB, duration, exit status), only failing tests with their
error and app stack frames (framework frames dropped, per-test and total
caps, tail of printed output), the tests still running when killed, and
the log and JSON paths. Quiet is the default when stdout is not a
terminal; MEMWATCH_OUTPUT=full also prints the whole log. The watchdog
loop and exit status are unchanged.

tool/analyze.sh bounds flutter analyze to a verdict line and the first
40 issues. Tests: test/tool/memwatch/summary_test.dart and the
end-to-end tool/memwatch/quiet_test.sh over fixture suites.
2026-11-04 13:10:21 +00:00

28 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Bounded `flutter analyze` for agents (from app/): tool/analyze.sh [paths...]
# Prints one verdict line with error/warning/info counts and the duration, at
# most ANALYZE_MAX_ISSUES (default 40) issue lines, and the full log path.
# Exits with flutter analyze's own status.
FLUTTER=${FLUTTER:-/Users/alan/development/flutter/bin/flutter}
max=${ANALYZE_MAX_ISSUES:-40}
[ -f pubspec.yaml ] || cd "$(dirname "$0")/.." || exit 1
tmp=${TMPDIR:-/tmp}
log=$(mktemp "${tmp%/}/flutter-analyze.XXXXXX") || exit 1
start=$SECONDS
"$FLUTTER" analyze "$@" > "$log" 2>&1; status=$?
issues=$(grep -cE '^ *(error|warning|info) • ' "$log")
count() { grep -cE "^ *$1 • " "$log"; }
if [ "$status" = 0 ] && [ "$issues" = 0 ]; then
echo "analyze: clean; $((SECONDS-start))s; exit 0"
else
echo "analyze: $(count error) errors, $(count warning) warnings, $(count info) infos; $((SECONDS-start))s; exit $status"
if [ "$issues" = 0 ]; then
tail -20 "$log" | cut -c1-300
else
grep -E '^ *(error|warning|info) • ' "$log" | head -n "$max" | cut -c1-300
[ "$issues" -gt "$max" ] && echo "... and $((issues-max)) more issues"
fi
fi
echo "full output: $log"
exit $status