Skip to content

Commit 37fc8cb

Browse files
szedergitster
authored andcommitted
ci: fix AsciiDoc/Asciidoctor stderr check in the documentation build job
In 'ci/test-documentation.sh' we save the standard error of 'make doc', and, in an attempt to make sure that neither AsciiDoc nor Asciidoctor printed any warnings, we check the emptiness of the resulting file with '! test -s stderr.log'. This check has never actually worked, because in our 'ci/*' build scripts we rely on 'set -e' aborting the build job when a command exits with error, and, unfortunately, the combination of the two doesn't work as intended. According to POSIX [1]: "The -e setting shall be ignored when executing [...] a pipeline beginning with the ! reserved word" [2] Watch and learn: $ echo unexpected >file $ ( set -e; ! test -s file ; echo "should not reach this" ) ; echo $? should not reach this 0 This is why we haven't noticed the warnings from Asciidoctor that were fixed in the first patches of this patch series, though some of them were already there in the build of v2.18.0-rc0 [3]. Check the emptiness of that file with 'test ! -s' instead, which works properly with 'set -e': $ ( set -e; test ! -s file ; echo "should not reach this" ) ; echo $? 1 Furthermore, dump the contents of that file to the log for our convenience, so if it were to unexpectedly end up being non-empty, then we wouldn't have to scroll through all that long build log looking for warnings, but could see them right away near the end of the log. Note that we are only really interested in the standard error of AsciiDoc and Asciidoctor, but by saving the stderr of 'make doc' we also save any error output from the make rules. Currently there is only one such line: we build the docs with Asciidoctor right after a 'make clean', meaning that 'make USE_ASCIIDOCTOR=1 doc' always starts with running 'GIT-VERSION-GEN', which in turn prints the version to stderr. A 'sed' command was supposed to remove this version line to prevent it from triggering that (previously defunct) emptiness check, but, unfortunately, this command doesn't work as intended, either, because it leaves the file to be checked intact, but that defunct emptiness check hid this issue, too... Furthermore, in the near future there will be an other line on stderr, because commit 9a71722 (Doc: auto-detect changed build flags, 2019-03-17) in the currently cooking branch 'ma/doc-diff-doc-vs-doctor-comparison' will print "* new asciidoc flags" at the beginning of both 'make doc' invokations. Extend that 'sed' command to remove this line, too, wrap it in a helper function so the output of both 'make doc' is filtered the same way, and change its invokation to actually write the logfile to be checked. [1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#set [2] POSIX doesn't discuss the meaning of '! cmd' in case of simple commands, but it defines that "A pipeline is a sequence of one or more commands separated by the control operator '|'", so apparently a simple command is considered as pipeline as well. http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_02 [3] https://travis-ci.org/git/git/jobs/385932007#L1463 Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 615a6c3 commit 37fc8cb

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

ci/test-documentation.sh

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,38 @@
55

66
. ${0%/*}/lib.sh
77

8+
filter_log () {
9+
sed -e '/^GIT_VERSION = /d' \
10+
-e '/^ \* new asciidoc flags$/d' \
11+
"$1"
12+
}
13+
814
make check-builtins
915
make check-docs
1016

1117
# Build docs with AsciiDoc
12-
make doc > >(tee stdout.log) 2> >(tee stderr.log >&2)
13-
! test -s stderr.log
18+
make doc > >(tee stdout.log) 2> >(tee stderr.raw >&2)
19+
cat stderr.raw
20+
filter_log stderr.raw >stderr.log
21+
test ! -s stderr.log
1422
test -s Documentation/git.html
1523
test -s Documentation/git.xml
1624
test -s Documentation/git.1
1725
grep '<meta name="generator" content="AsciiDoc ' Documentation/git.html
1826

19-
rm -f stdout.log stderr.log
27+
rm -f stdout.log stderr.log stderr.raw
2028
check_unignored_build_artifacts
2129

2230
# Build docs with AsciiDoctor
2331
make clean
24-
make USE_ASCIIDOCTOR=1 doc > >(tee stdout.log) 2> >(tee stderr.log >&2)
25-
sed '/^GIT_VERSION = / d' stderr.log
26-
! test -s stderr.log
32+
make USE_ASCIIDOCTOR=1 doc > >(tee stdout.log) 2> >(tee stderr.raw >&2)
33+
cat stderr.raw
34+
filter_log stderr.raw >stderr.log
35+
test ! -s stderr.log
2736
test -s Documentation/git.html
2837
grep '<meta name="generator" content="Asciidoctor ' Documentation/git.html
2938

30-
rm -f stdout.log stderr.log
39+
rm -f stdout.log stderr.log stderr.raw
3140
check_unignored_build_artifacts
3241

3342
save_good_tree

0 commit comments

Comments
 (0)