@@ -76,8 +76,8 @@ step() {
7676# readme NAME: run the README block NAME as written, with NAME=config-repo.
7777readme () {
7878 cmds=" $( sh " $here /readme-block.sh" " $1 " " $top /README.md" ) " || die " README.md has no install-test:$1 block"
79- echo " $cmds " | sed ' s/^/README> /'
80- echo " $cmds " | sed " s/NAME/$name /g" | sh -eu || die " the README block install-test:$1 failed (see the output above)"
79+ printf ' %s\n ' " $cmds " | sed ' s/^/README> /'
80+ printf ' %s\n ' " $cmds " | sed " s/NAME/$name /g" | sh -eu || die " the README block install-test:$1 failed (see the output above)"
8181}
8282
8383# wait_text TEXT SECONDS: wait until the fake Telegram got a message with TEXT.
@@ -109,6 +109,10 @@ outbox_empty() {
109109# unit_quiet UNIT: the unit logged no error and no warning.
110110unit_quiet () {
111111 journalctl --sync || true
112+ # No log line at all would make the check below pass without checking.
113+ if ! journalctl --no-pager -o cat -u " $1 " | grep -q ' level=INFO' ; then
114+ err " $1 : no log line found in the journal, so its errors cannot be checked"
115+ fi
112116 if journalctl --no-pager -o cat -u " $1 " | grep -E ' level=(ERROR|WARN)' ; then
113117 err " $1 logged an error or a warning (above)"
114118 fi
@@ -126,6 +130,22 @@ listener_read_all() {
126130 fi
127131}
128132
133+ # run_until_tip SHA: start runs until one has fetched SHA. A run that the
134+ # timer started before the push is joined by `systemctl start` and does
135+ # not see the new commit, so one start is not enough.
136+ run_until_tip () {
137+ i=0
138+ while [ " $i " -lt 10 ]; do
139+ systemctl start " pullgate-run@$name .service" || err " pullgate-run@$name .service failed"
140+ if pullgate status " $name " | grep -q " ^last tip: *$1 \$ " ; then
141+ return 0
142+ fi
143+ i=$(( i + 1 ))
144+ sleep 1
145+ done
146+ die " after 10 runs, pullgate status does not show the last tip $1 "
147+ }
148+
129149# applied_sha: the applied SHA that `pullgate status` shows.
130150applied_sha () {
131151 pullgate status " $name " | sed -n ' s/^applied: *//p'
@@ -263,7 +283,7 @@ readme start
263283
264284step " 5. A good commit: ask, tap, apply"
265285# The timer may have started a run already; start waits for it.
266- systemctl start " pullgate-run@ $name .service " || err " pullgate-run@ $name .service failed "
286+ run_until_tip " $sha1 "
267287if ! wait_text " ✅ Applied" 90; then
268288 journalctl --no-pager -o cat -u " pullgate-run@$name .service" -u pullgate-listen.service -u " pullgate-apply@$name .service" || true
269289 die " no 'Applied' message reached the fake Telegram"
@@ -296,7 +316,7 @@ systemctl is-active --quiet pullgate-listen.service || err "the listener is not
296316
297317step " 7. A commit whose apply fails: rollback"
298318sha2=" $( commit ' fail = true' ' a commit whose apply fails' ) "
299- systemctl start " pullgate-run@ $name .service " || err " pullgate-run@ $name .service failed "
319+ run_until_tip " $sha2 "
300320if ! wait_text " Rolled back to" 90; then
301321 journalctl --no-pager -o cat -u " pullgate-run@$name .service" -u pullgate-listen.service -u " pullgate-apply@$name .service" || true
302322 die " no 'Rolled back' notice reached the fake Telegram"
0 commit comments