blob: 9c5339c577ac3fd50090baf0d84caf6d62df0697 [file] [log] [blame]
Johannes Schindelin0f5ae592022-05-21 22:18:51 +00001# Library of functions to mark up test scripts' output suitable for
2# pretty-printing it in GitHub workflows.
3#
4# Copyright (c) 2022 Johannes Schindelin
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see http://www.gnu.org/licenses/ .
18#
19# The idea is for `test-lib.sh` to source this file when run in GitHub
20# workflows; these functions will then override (empty) functions
21# that are are called at the appropriate times during the test runs.
22
Victoria Dye110e9112022-05-21 22:18:53 +000023test_skip_test_preamble=t
24
Johannes Schindelin0f5ae592022-05-21 22:18:51 +000025start_test_output () {
26 test -n "$GIT_TEST_TEE_OUTPUT_FILE" ||
27 die "--github-workflow-markup requires --verbose-log"
28 github_markup_output="${GIT_TEST_TEE_OUTPUT_FILE%.out}.markup"
29 >$github_markup_output
30 GIT_TEST_TEE_OFFSET=0
31}
32
33# No need to override start_test_case_output
34
35finalize_test_case_output () {
36 test_case_result=$1
37 shift
38 case "$test_case_result" in
39 failure)
40 echo >>$github_markup_output "::error::failed: $this_test.$test_count $1"
41 ;;
42 fixed)
43 echo >>$github_markup_output "::notice::fixed: $this_test.$test_count $1"
44 ;;
Johannes Schindelin448de902022-05-21 22:18:52 +000045 ok)
46 # Exit without printing the "ok" tests
47 return
48 ;;
Johannes Schindelin0f5ae592022-05-21 22:18:51 +000049 esac
50 echo >>$github_markup_output "::group::$test_case_result: $this_test.$test_count $*"
51 test-tool >>$github_markup_output path-utils skip-n-bytes \
52 "$GIT_TEST_TEE_OUTPUT_FILE" $GIT_TEST_TEE_OFFSET
53 echo >>$github_markup_output "::endgroup::"
54}
55
56# No need to override finalize_test_output