@@ -56,20 +56,27 @@ What tests to run:
5656
5757Extra things to do:
5858 --fix Fix issues found, where possible.
59+
60+ Modifying this script's output:
61+ --verbose Print more details about everything.
5962EOF
6063 exit 2
6164}
6265
66+ orig_cmdline=" $0 $* "
67+
6368opt_files=branch
6469opt_all=
6570opt_fix=
71+ opt_verbose=
6672opt_suites=()
6773while (( $# )) ; do
6874 case " $1 " in
6975 --diff) shift ; opt_files=diff:" $1 " ; shift ;;
7076 --all-files) opt_files=all; shift ;;
7177 --all) opt_files=all; opt_all=1; shift ;;
7278 --fix) opt_fix=1; shift ;;
79+ --verbose) opt_verbose=1; shift ;;
7380 analyze|test|build_runner|drift|icons|shellcheck)
7481 opt_suites+=(" $1 " ); shift ;;
7582 * ) usage;;
98105rootdir=$( git rev-parse --show-toplevel)
99106cd " $rootdir "
100107
108+ divider_line=' ================================================================'
109+
110+ # usage: if_verbose COMMAND...
111+ #
112+ # Run the given command just if $opt_verbose; else do nothing.
113+ #
114+ # This is a convenience shorthand for simple commands. For more complex logic,
115+ # write `if [ -n "${opt_verbose}" ]` directly.
116+ if_verbose () {
117+ if [ -n " ${opt_verbose} " ]; then
118+ " $@ "
119+ fi
120+ }
121+
101122# True just if $opt_files intersects the given set of paths.
102123#
103124# On what paths to include in this check (and more generally, how to write
@@ -169,10 +190,12 @@ check_no_changes() {
169190}
170191
171192run_analyze () {
193+ # no `flutter analyze --verbose` even when $opt_verbose; it's *very* verbose
172194 flutter analyze
173195}
174196
175197run_test () {
198+ # no `flutter test --verbose` even when $opt_verbose; it's *very* verbose
176199 flutter test
177200}
178201
@@ -206,16 +229,25 @@ run_build_runner() {
206229 check_no_uncommitted_or_untracked ' *.g.dart' \
207230 || return
208231
209- # build_runner has a --verbose, but lacks a --quiet.
210- # So we filter out "[INFO]" messages ourselves.
211- dart run build_runner build --delete-conflicting-outputs \
212- | perl -lne '
213- BEGIN { my $silence = 0 }
214- if (/^\[INFO\]/) { $silence = 1 }
215- elsif (/^\[[A-Z]/) { $silence = 0 }
216- print if (!$silence)
217- ' \
218- || return
232+ local build_runner_cmd=(
233+ dart run build_runner build --delete-conflicting-outputs
234+ )
235+ if [ -n " ${opt_verbose} " ]; then
236+ # No --verbose needed; build_runner is verbose enough by default.
237+ " ${build_runner_cmd[@]} " \
238+ || return
239+ else
240+ # build_runner lacks a --quiet, and is fairly verbose to begin with.
241+ # So we filter out "[INFO]" messages ourselves.
242+ " ${build_runner_cmd[@]} " \
243+ | perl -lne '
244+ BEGIN { my $silence = 0 }
245+ if (/^\[INFO\]/) { $silence = 1 }
246+ elsif (/^\[[A-Z]/) { $silence = 0 }
247+ print if (!$silence)
248+ ' \
249+ || return
250+ fi
219251
220252 check_no_changes " updates to *.g.dart files" ' *.g.dart'
221253}
@@ -283,11 +315,45 @@ EOF
283315 return 1
284316 fi
285317
318+ if_verbose shellcheck --version
286319 shellcheck -x --shell=bash -- " ${targets[@]} "
287320}
288321
322+ describe_git_head () {
323+ local name=" $1 " repo_path=" $2 "
324+ local commit_data
325+ commit_data=$(
326+ TZ=UTC \
327+ git --git-dir " ${repo_path} " \
328+ log -1 --format=" %h • %cd" \
329+ --abbrev=9 --date=iso8601-local
330+ )
331+ echo " ${name} ${commit_data} "
332+ }
333+
334+ print_header () {
335+ local flutter_executable flutter_tree
336+
337+ echo " Test command: ${orig_cmdline} "
338+
339+ echo " Time now: $( date --utc +' %F %T %z' ) "
340+
341+ describe_git_head " zulip-flutter" .git/
342+
343+ # We avoid `flutter --version` because, weirdly, when run in a
344+ # GitHub Actions step it takes about 30 seconds. (The first time;
345+ # it's fast subsequent times.) That's even after `flutter precache`.
346+ flutter_executable=$( readlink -f " $( type -p flutter) " )
347+ flutter_tree=${flutter_executable%/ bin/ flutter}
348+ describe_git_head " flutter/flutter" " ${flutter_tree} " /.git
349+
350+ dart --version
351+ }
352+
353+ if_verbose print_header
289354failed=()
290355for suite in " ${opt_suites[@]} " ; do
356+ if_verbose echo " ${divider_line} "
291357 echo " Running $suite ..."
292358 case " $suite " in
293359 analyze) run_analyze ;;
@@ -299,6 +365,7 @@ for suite in "${opt_suites[@]}"; do
299365 * ) echo >&2 " Internal error: unknown suite $suite " ;;
300366 esac || failed+=( " $suite " )
301367done
368+ if_verbose echo " ${divider_line} "
302369
303370if (( ${# failed[@]} )) ; then
304371 cat >&2 << EOF
0 commit comments