Debian Codegraph @

scripts/test-driver-verbose

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
•1 #! /bin/sh
2 # test-driver - testsuite driver script inherited from Automake's basic, but with verbose output.
3 # Verbosity patch by Didier Raboud <[email protected]>
4
5 scriptversion=2018-03-07.03; # UTC
6
7 # Copyright (C) 2011-2018 Free Software Foundation, Inc.
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option)
12 # any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <https://www.gnu.org/licenses/>.
21
22 # As a special exception to the GNU General Public License, if you
23 # distribute this file as part of a program that contains a
24 # configuration script generated by Autoconf, you may include it under
25 # the same distribution terms that you use for the rest of that program.
26
27 # Make unconditional expansion of undefined variables an error. This
28 # helps a lot in preventing typo-related bugs.
29 set -u
30
31 usage_error ()
32 {
33 echo "$0: $*" >&2
34 print_usage >&2
35 exit 2
36 }
37
38 print_usage ()
39 {
40 cat <<END
41 Usage:
42 test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
43 [--expect-failure={yes|no}] [--color-tests={yes|no}]
44 [--enable-hard-errors={yes|no}] [--]
45 TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
46 The '--test-name', '--log-file' and '--trs-file' options are mandatory.
47 END
48 }
49
50 test_name= # Used for reporting.
51 log_file= # Where to save the output of the test script.
52 trs_file= # Where to save the metadata of the test run.
53 expect_failure=no
54 color_tests=no
55 enable_hard_errors=yes
56 while test $# -gt 0; do
57 case $1 in
58 --help) print_usage; exit $?;;
59 --version) echo "test-driver $scriptversion"; exit $?;;
60 --test-name) test_name=$2; shift;;
61 --log-file) log_file=$2; shift;;
62 --trs-file) trs_file=$2; shift;;
63 --color-tests) color_tests=$2; shift;;
64 --expect-failure) expect_failure=$2; shift;;
65 --enable-hard-errors) enable_hard_errors=$2; shift;;
66 --) shift; break;;
67 -*) usage_error "invalid option: '$1'";;
68 *) break;;
69 esac
70 shift
71 done
72
73 missing_opts=
74 test x"$test_name" = x && missing_opts="$missing_opts --test-name"
75 test x"$log_file" = x && missing_opts="$missing_opts --log-file"
76 test x"$trs_file" = x && missing_opts="$missing_opts --trs-file"
77 if test x"$missing_opts" != x; then
78 usage_error "the following mandatory options are missing:$missing_opts"
79 fi
80
81 if test $# -eq 0; then
82 usage_error "missing argument"
83 fi
84
85 if test $color_tests = yes; then
86 # Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
87 red='' # Red.
88 grn='' # Green.
89 lgn='' # Light green.
90 blu='' # Blue.
91 mgn='' # Magenta.
92 std='' # No color.
93 else
94 red= grn= lgn= blu= mgn= std=
95 fi
96
97 do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
98 trap "st=129; $do_exit" 1
99 trap "st=130; $do_exit" 2
100 trap "st=141; $do_exit" 13
101 trap "st=143; $do_exit" 15
102
103 # Test script is run here.
104 # OdyX: Make it verbose by using tee
105 "$@" 2>&1 | tee -a $log_file
106 estatus=$?
107
108 if test $enable_hard_errors = no && test $estatus -eq 99; then
109 tweaked_estatus=1
110 else
111 tweaked_estatus=$estatus
112 fi
113
114 case $tweaked_estatus:$expect_failure in
115 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
116 0:*) col=$grn res=PASS recheck=no gcopy=no;;
117 77:*) col=$blu res=SKIP recheck=no gcopy=yes;;
118 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;;
119 *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;;
120 *:*) col=$red res=FAIL recheck=yes gcopy=yes;;
121 esac
122
123 # Report the test outcome and exit status in the logs, so that one can
124 # know whether the test passed or failed simply by looking at the '.log'
125 # file, without the need of also peaking into the corresponding '.trs'
126 # file (automake bug#11814).
127 echo "$res $test_name (exit status: $estatus)" >>$log_file
128
129 # Report outcome to console.
130 echo "${col}${res}${std}: $test_name"
131
132 # Register the test result, and other relevant metadata.
133 echo ":test-result: $res" > $trs_file
134 echo ":global-test-result: $res" >> $trs_file
135 echo ":recheck: $recheck" >> $trs_file
136 echo ":copy-in-global-log: $gcopy" >> $trs_file
137
138 # Local Variables:
139 # mode: shell-script
140 # sh-indentation: 2
141 # eval: (add-hook 'before-save-hook 'time-stamp)
142 # time-stamp-start: "scriptversion="
143 # time-stamp-format: "%:y-%02m-%02d.%02H"
144 # time-stamp-time-zone: "UTC0"
145 # time-stamp-end: "; # UTC"
146 # End: