@@ -56,20 +56,27 @@ What tests to run:
56
56
57
57
Extra things to do:
58
58
--fix Fix issues found, where possible.
59
+
60
+ Modifying this script's output:
61
+ --verbose Print more details about everything.
59
62
EOF
60
63
exit 2
61
64
}
62
65
66
+ orig_cmdline=" $0 $* "
67
+
63
68
opt_files=branch
64
69
opt_all=
65
70
opt_fix=
71
+ opt_verbose=
66
72
opt_suites=()
67
73
while (( $# )) ; do
68
74
case " $1 " in
69
75
--diff) shift ; opt_files=diff:" $1 " ; shift ;;
70
76
--all-files) opt_files=all; shift ;;
71
77
--all) opt_files=all; opt_all=1; shift ;;
72
78
--fix) opt_fix=1; shift ;;
79
+ --verbose) opt_verbose=1; shift ;;
73
80
analyze|test|build_runner|drift|icons|shellcheck)
74
81
opt_suites+=(" $1 " ); shift ;;
75
82
* ) usage;;
98
105
rootdir=$( git rev-parse --show-toplevel)
99
106
cd " $rootdir "
100
107
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
+
101
122
# True just if $opt_files intersects the given set of paths.
102
123
#
103
124
# On what paths to include in this check (and more generally, how to write
@@ -169,10 +190,12 @@ check_no_changes() {
169
190
}
170
191
171
192
run_analyze () {
193
+ # no `flutter analyze --verbose` even when $opt_verbose; it's *very* verbose
172
194
flutter analyze
173
195
}
174
196
175
197
run_test () {
198
+ # no `flutter test --verbose` even when $opt_verbose; it's *very* verbose
176
199
flutter test
177
200
}
178
201
@@ -206,16 +229,25 @@ run_build_runner() {
206
229
check_no_uncommitted_or_untracked ' *.g.dart' \
207
230
|| return
208
231
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
219
251
220
252
check_no_changes " updates to *.g.dart files" ' *.g.dart'
221
253
}
@@ -283,11 +315,45 @@ EOF
283
315
return 1
284
316
fi
285
317
318
+ if_verbose shellcheck --version
286
319
shellcheck -x --shell=bash -- " ${targets[@]} "
287
320
}
288
321
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
289
354
failed=()
290
355
for suite in " ${opt_suites[@]} " ; do
356
+ if_verbose echo " ${divider_line} "
291
357
echo " Running $suite ..."
292
358
case " $suite " in
293
359
analyze) run_analyze ;;
@@ -299,6 +365,7 @@ for suite in "${opt_suites[@]}"; do
299
365
* ) echo >&2 " Internal error: unknown suite $suite " ;;
300
366
esac || failed+=( " $suite " )
301
367
done
368
+ if_verbose echo " ${divider_line} "
302
369
303
370
if (( ${# failed[@]} )) ; then
304
371
cat >&2 << EOF
0 commit comments