Sun, 28 Aug 2016 20:43:17 -0400
Remove AC_HEADER_STDC and related C89 tests.
AC_HEADER_STDC is obsolescent because all current systems have
conforming header files. As we also claim to depend on C89, there's
no need to check for any headers defined in that standard.
|
37593
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | #! /bin/sh |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | # Copyright (C) 2011-2013 Free Software Foundation, Inc. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | # |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | # This program is free software; you can redistribute it and/or modify |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | # it under the terms of the GNU General Public License as published by |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | # the Free Software Foundation; either version 2, or (at your option) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | # any later version. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | # |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | # This program is distributed in the hope that it will be useful, |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | # GNU General Public License for more details. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | # |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | # You should have received a copy of the GNU General Public License |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | # As a special exception to the GNU General Public License, if you |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | # distribute this file as part of a program that contains a |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | # configuration script generated by Autoconf, you may include it under |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | # the same distribution terms that you use for the rest of that program. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | # This file is maintained in Automake, please report |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | # bugs to <bug-automake@gnu.org> or send patches to |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | # <automake-patches@gnu.org>. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | scriptversion=2011-12-27.17; # UTC |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | # Make unconditional expansion of undefined variables an error. This |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | # helps a lot in preventing typo-related bugs. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | set -u |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | me=tap-driver.sh |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | fatal () |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | echo "$me: fatal: $*" >&2 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | exit 1 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | usage_error () |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | echo "$me: $*" >&2 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | print_usage >&2 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | exit 2 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | print_usage () |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | cat <<END |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | Usage: |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | tap-driver.sh --test-name=NAME --log-file=PATH --trs-file=PATH |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | [--expect-failure={yes|no}] [--color-tests={yes|no}] |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | [--enable-hard-errors={yes|no}] [--ignore-exit] |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | [--diagnostic-string=STRING] [--merge|--no-merge] |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | [--comments|--no-comments] [--] TEST-COMMAND |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | The \`--test-name', \`--log-file' and \`--trs-file' options are mandatory. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | END |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | # TODO: better error handling in option parsing (in particular, ensure |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | # TODO: $log_file, $trs_file and $test_name are defined). |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | test_name= # Used for reporting. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | log_file= # Where to save the result and output of the test script. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | trs_file= # Where to save the metadata of the test run. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | expect_failure=0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | color_tests=0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | merge=0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | ignore_exit=0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | comments=0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | diag_string='#' |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | while test $# -gt 0; do |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | case $1 in |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | --help) print_usage; exit $?;; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | --version) echo "$me $scriptversion"; exit $?;; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | --test-name) test_name=$2; shift;; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | --log-file) log_file=$2; shift;; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | --trs-file) trs_file=$2; shift;; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | --color-tests) color_tests=$2; shift;; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | --expect-failure) expect_failure=$2; shift;; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | --enable-hard-errors) shift;; # No-op. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | --merge) merge=1;; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | --no-merge) merge=0;; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | --ignore-exit) ignore_exit=1;; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | --comments) comments=1;; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | --no-comments) comments=0;; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | --diagnostic-string) diag_string=$2; shift;; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | --) shift; break;; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | -*) usage_error "invalid option: '$1'";; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | esac |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | shift |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | done |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | test $# -gt 0 || usage_error "missing test command" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | case $expect_failure in |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | yes) expect_failure=1;; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | *) expect_failure=0;; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | esac |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | if test $color_tests = yes; then |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | init_colors=' |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | color_map["red"]="[0;31m" # Red. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | color_map["grn"]="[0;32m" # Green. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
104 | color_map["lgn"]="[1;32m" # Light green. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | color_map["blu"]="[1;34m" # Blue. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | color_map["mgn"]="[0;35m" # Magenta. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | color_map["std"]="[m" # No color. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | color_for_result["ERROR"] = "mgn" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | color_for_result["PASS"] = "grn" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | color_for_result["XPASS"] = "red" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | color_for_result["FAIL"] = "red" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | color_for_result["XFAIL"] = "lgn" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | color_for_result["SKIP"] = "blu"' |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | else |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | init_colors='' |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | fi |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | # :; is there to work around a bug in bash 3.2 (and earlier) which |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | # does not always set '$?' properly on redirection failure. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | # See the Autoconf manual for more details. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | :;{ |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | ( |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | # Ignore common signals (in this subshell only!), to avoid potential |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | # problems with Korn shells. Some Korn shells are known to propagate |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | # to themselves signals that have killed a child process they were |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | # waiting for; this is done at least for SIGINT (and usually only for |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | # it, in truth). Without the `trap' below, such a behaviour could |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | # cause a premature exit in the current subshell, e.g., in case the |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | # test command it runs gets terminated by a SIGINT. Thus, the awk |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | # script we are piping into would never seen the exit status it |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | # expects on its last input line (which is displayed below by the |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | # last `echo $?' statement), and would thus die reporting an internal |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | # error. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
134 | # For more information, see the Autoconf manual and the threads: |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
135 | # <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html> |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | # <http://mail.opensolaris.org/pipermail/ksh93-integration-discuss/2009-February/004121.html> |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | trap : 1 3 2 13 15 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | if test $merge -gt 0; then |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | exec 2>&1 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
140 | else |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
141 | exec 2>&3 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
142 | fi |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
143 | "$@" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | echo $? |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | ) | LC_ALL=C ${AM_TAP_AWK-awk} \ |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
146 | -v me="$me" \ |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
147 | -v test_script_name="$test_name" \ |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
148 | -v log_file="$log_file" \ |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
149 | -v trs_file="$trs_file" \ |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
150 | -v expect_failure="$expect_failure" \ |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | -v merge="$merge" \ |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | -v ignore_exit="$ignore_exit" \ |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
153 | -v comments="$comments" \ |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | -v diag_string="$diag_string" \ |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
155 | ' |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
156 | # FIXME: the usages of "cat >&3" below could be optimized when using |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | # FIXME: GNU awk, and/on on systems that supports /dev/fd/. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | # Implementation note: in what follows, `result_obj` will be an |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | # associative array that (partly) simulates a TAP result object |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | # from the `TAP::Parser` perl module. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | ## ----------- ## |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | ## FUNCTIONS ## |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | ## ----------- ## |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | function fatal(msg) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
169 | print me ": " msg | "cat >&2" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | exit 1 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
171 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
172 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
173 | function abort(where) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
174 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
175 | fatal("internal error " where) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
176 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
177 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
178 | # Convert a boolean to a "yes"/"no" string. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
179 | function yn(bool) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
180 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
181 | return bool ? "yes" : "no"; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
183 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
184 | function add_test_result(result) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
185 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
186 | if (!test_results_index) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | test_results_index = 0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | test_results_list[test_results_index] = result |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
189 | test_results_index += 1 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
190 | test_results_seen[result] = 1; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
191 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
192 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
193 | # Whether the test script should be re-run by "make recheck". |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | function must_recheck() |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | for (k in test_results_seen) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
197 | if (k != "XFAIL" && k != "PASS" && k != "SKIP") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
198 | return 1 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | return 0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
200 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
201 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
202 | # Whether the content of the log file associated to this test should |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
203 | # be copied into the "global" test-suite.log. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
204 | function copy_in_global_log() |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
205 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
206 | for (k in test_results_seen) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
207 | if (k != "PASS") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
208 | return 1 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
209 | return 0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
210 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
212 | # FIXME: this can certainly be improved ... |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
213 | function get_global_test_result() |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
214 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
215 | if ("ERROR" in test_results_seen) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
216 | return "ERROR" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
217 | if ("FAIL" in test_results_seen || "XPASS" in test_results_seen) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
218 | return "FAIL" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
219 | all_skipped = 1 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
220 | for (k in test_results_seen) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
221 | if (k != "SKIP") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
222 | all_skipped = 0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
223 | if (all_skipped) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
224 | return "SKIP" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
225 | return "PASS"; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
226 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
227 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
228 | function stringify_result_obj(result_obj) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
229 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
230 | if (result_obj["is_unplanned"] || result_obj["number"] != testno) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
231 | return "ERROR" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
232 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
233 | if (plan_seen == LATE_PLAN) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
234 | return "ERROR" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
235 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
236 | if (result_obj["directive"] == "TODO") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
237 | return result_obj["is_ok"] ? "XPASS" : "XFAIL" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
238 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
239 | if (result_obj["directive"] == "SKIP") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
240 | return result_obj["is_ok"] ? "SKIP" : COOKED_FAIL; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
241 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
242 | if (length(result_obj["directive"])) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
243 | abort("in function stringify_result_obj()") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
244 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
245 | return result_obj["is_ok"] ? COOKED_PASS : COOKED_FAIL |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
246 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
247 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
248 | function decorate_result(result) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
249 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
250 | color_name = color_for_result[result] |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
251 | if (color_name) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
252 | return color_map[color_name] "" result "" color_map["std"] |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
253 | # If we are not using colorized output, or if we do not know how |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
254 | # to colorize the given result, we should return it unchanged. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | return result |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
256 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
257 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
258 | function report(result, details) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
259 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
260 | if (result ~ /^(X?(PASS|FAIL)|SKIP|ERROR)/) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
261 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
262 | msg = ": " test_script_name |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
263 | add_test_result(result) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
264 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
265 | else if (result == "#") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
266 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
267 | msg = " " test_script_name ":" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
268 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
269 | else |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
270 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
271 | abort("in function report()") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
272 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
273 | if (length(details)) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
274 | msg = msg " " details |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
275 | # Output on console might be colorized. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
276 | print decorate_result(result) msg |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
277 | # Log the result in the log file too, to help debugging (this is |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
278 | # especially true when said result is a TAP error or "Bail out!"). |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
279 | print result msg | "cat >&3"; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
280 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
281 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
282 | function testsuite_error(error_message) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
283 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
284 | report("ERROR", "- " error_message) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
285 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
286 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
287 | function handle_tap_result() |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
288 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
289 | details = result_obj["number"]; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
290 | if (length(result_obj["description"])) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
291 | details = details " " result_obj["description"] |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
292 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
293 | if (plan_seen == LATE_PLAN) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
294 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
295 | details = details " # AFTER LATE PLAN"; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
296 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
297 | else if (result_obj["is_unplanned"]) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
298 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
299 | details = details " # UNPLANNED"; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
300 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
301 | else if (result_obj["number"] != testno) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
302 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
303 | details = sprintf("%s # OUT-OF-ORDER (expecting %d)", |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
304 | details, testno); |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
305 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
306 | else if (result_obj["directive"]) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
307 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
308 | details = details " # " result_obj["directive"]; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
309 | if (length(result_obj["explanation"])) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
310 | details = details " " result_obj["explanation"] |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
311 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
312 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
313 | report(stringify_result_obj(result_obj), details) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
314 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
315 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
316 | # `skip_reason` should be empty whenever planned > 0. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
317 | function handle_tap_plan(planned, skip_reason) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
318 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
319 | planned += 0 # Avoid getting confused if, say, `planned` is "00" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
320 | if (length(skip_reason) && planned > 0) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
321 | abort("in function handle_tap_plan()") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
322 | if (plan_seen) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
323 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
324 | # Error, only one plan per stream is acceptable. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
325 | testsuite_error("multiple test plans") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
326 | return; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
327 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
328 | planned_tests = planned |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
329 | # The TAP plan can come before or after *all* the TAP results; we speak |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
330 | # respectively of an "early" or a "late" plan. If we see the plan line |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
331 | # after at least one TAP result has been seen, assume we have a late |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
332 | # plan; in this case, any further test result seen after the plan will |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
333 | # be flagged as an error. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
334 | plan_seen = (testno >= 1 ? LATE_PLAN : EARLY_PLAN) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
335 | # If testno > 0, we have an error ("too many tests run") that will be |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
336 | # automatically dealt with later, so do not worry about it here. If |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
337 | # $plan_seen is true, we have an error due to a repeated plan, and that |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
338 | # has already been dealt with above. Otherwise, we have a valid "plan |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
339 | # with SKIP" specification, and should report it as a particular kind |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
340 | # of SKIP result. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
341 | if (planned == 0 && testno == 0) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
342 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
343 | if (length(skip_reason)) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
344 | skip_reason = "- " skip_reason; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
345 | report("SKIP", skip_reason); |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
346 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
347 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
348 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
349 | function extract_tap_comment(line) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
350 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
351 | if (index(line, diag_string) == 1) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
352 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
353 | # Strip leading `diag_string` from `line`. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
354 | line = substr(line, length(diag_string) + 1) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
355 | # And strip any leading and trailing whitespace left. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
356 | sub("^[ \t]*", "", line) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
357 | sub("[ \t]*$", "", line) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
358 | # Return what is left (if any). |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
359 | return line; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
360 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
361 | return ""; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
362 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
363 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
364 | # When this function is called, we know that line is a TAP result line, |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
365 | # so that it matches the (perl) RE "^(not )?ok\b". |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
366 | function setup_result_obj(line) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
367 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
368 | # Get the result, and remove it from the line. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
369 | result_obj["is_ok"] = (substr(line, 1, 2) == "ok" ? 1 : 0) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
370 | sub("^(not )?ok[ \t]*", "", line) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
371 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
372 | # If the result has an explicit number, get it and strip it; otherwise, |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
373 | # automatically assing the next progresive number to it. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
374 | if (line ~ /^[0-9]+$/ || line ~ /^[0-9]+[^a-zA-Z0-9_]/) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
375 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
376 | match(line, "^[0-9]+") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
377 | # The final `+ 0` is to normalize numbers with leading zeros. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
378 | result_obj["number"] = substr(line, 1, RLENGTH) + 0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
379 | line = substr(line, RLENGTH + 1) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
380 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
381 | else |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
382 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
383 | result_obj["number"] = testno |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
384 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
385 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
386 | if (plan_seen == LATE_PLAN) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
387 | # No further test results are acceptable after a "late" TAP plan |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
388 | # has been seen. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
389 | result_obj["is_unplanned"] = 1 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
390 | else if (plan_seen && testno > planned_tests) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
391 | result_obj["is_unplanned"] = 1 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
392 | else |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
393 | result_obj["is_unplanned"] = 0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
394 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
395 | # Strip trailing and leading whitespace. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
396 | sub("^[ \t]*", "", line) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
397 | sub("[ \t]*$", "", line) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
398 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
399 | # This will have to be corrected if we have a "TODO"/"SKIP" directive. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
400 | result_obj["description"] = line |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
401 | result_obj["directive"] = "" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
402 | result_obj["explanation"] = "" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
403 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
404 | if (index(line, "#") == 0) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
405 | return # No possible directive, nothing more to do. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
406 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
407 | # Directives are case-insensitive. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
408 | rx = "[ \t]*#[ \t]*([tT][oO][dD][oO]|[sS][kK][iI][pP])[ \t]*" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
409 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
410 | # See whether we have the directive, and if yes, where. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
411 | pos = match(line, rx "$") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
412 | if (!pos) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
413 | pos = match(line, rx "[^a-zA-Z0-9_]") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
414 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
415 | # If there was no TAP directive, we have nothing more to do. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
416 | if (!pos) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
417 | return |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
418 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
419 | # Let`s now see if the TAP directive has been escaped. For example: |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
420 | # escaped: ok \# SKIP |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
421 | # not escaped: ok \\# SKIP |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
422 | # escaped: ok \\\\\# SKIP |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
423 | # not escaped: ok \ # SKIP |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
424 | if (substr(line, pos, 1) == "#") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
425 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
426 | bslash_count = 0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
427 | for (i = pos; i > 1 && substr(line, i - 1, 1) == "\\"; i--) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
428 | bslash_count += 1 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
429 | if (bslash_count % 2) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
430 | return # Directive was escaped. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
431 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
432 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
433 | # Strip the directive and its explanation (if any) from the test |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
434 | # description. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
435 | result_obj["description"] = substr(line, 1, pos - 1) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
436 | # Now remove the test description from the line, that has been dealt |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
437 | # with already. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
438 | line = substr(line, pos) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
439 | # Strip the directive, and save its value (normalized to upper case). |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
440 | sub("^[ \t]*#[ \t]*", "", line) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
441 | result_obj["directive"] = toupper(substr(line, 1, 4)) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
442 | line = substr(line, 5) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
443 | # Now get the explanation for the directive (if any), with leading |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
444 | # and trailing whitespace removed. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
445 | sub("^[ \t]*", "", line) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
446 | sub("[ \t]*$", "", line) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
447 | result_obj["explanation"] = line |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
448 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
449 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
450 | function get_test_exit_message(status) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
451 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
452 | if (status == 0) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
453 | return "" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
454 | if (status !~ /^[1-9][0-9]*$/) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
455 | abort("getting exit status") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
456 | if (status < 127) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
457 | exit_details = "" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
458 | else if (status == 127) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
459 | exit_details = " (command not found?)" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
460 | else if (status >= 128 && status <= 255) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
461 | exit_details = sprintf(" (terminated by signal %d?)", status - 128) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
462 | else if (status > 256 && status <= 384) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
463 | # We used to report an "abnormal termination" here, but some Korn |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
464 | # shells, when a child process die due to signal number n, can leave |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
465 | # in $? an exit status of 256+n instead of the more standard 128+n. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
466 | # Apparently, both behaviours are allowed by POSIX (2008), so be |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
467 | # prepared to handle them both. See also Austing Group report ID |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
468 | # 0000051 <http://www.austingroupbugs.net/view.php?id=51> |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
469 | exit_details = sprintf(" (terminated by signal %d?)", status - 256) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
470 | else |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
471 | # Never seen in practice. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
472 | exit_details = " (abnormal termination)" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
473 | return sprintf("exited with status %d%s", status, exit_details) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
474 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
475 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
476 | function write_test_results() |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
477 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
478 | print ":global-test-result: " get_global_test_result() > trs_file |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
479 | print ":recheck: " yn(must_recheck()) > trs_file |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
480 | print ":copy-in-global-log: " yn(copy_in_global_log()) > trs_file |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
481 | for (i = 0; i < test_results_index; i += 1) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
482 | print ":test-result: " test_results_list[i] > trs_file |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
483 | close(trs_file); |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
484 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
485 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
486 | BEGIN { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
487 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
488 | ## ------- ## |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
489 | ## SETUP ## |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
490 | ## ------- ## |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
491 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
492 | '"$init_colors"' |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
493 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
494 | # Properly initialized once the TAP plan is seen. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
495 | planned_tests = 0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
496 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
497 | COOKED_PASS = expect_failure ? "XPASS": "PASS"; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
498 | COOKED_FAIL = expect_failure ? "XFAIL": "FAIL"; |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
499 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
500 | # Enumeration-like constants to remember which kind of plan (if any) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
501 | # has been seen. It is important that NO_PLAN evaluates "false" as |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
502 | # a boolean. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
503 | NO_PLAN = 0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
504 | EARLY_PLAN = 1 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
505 | LATE_PLAN = 2 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
506 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
507 | testno = 0 # Number of test results seen so far. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
508 | bailed_out = 0 # Whether a "Bail out!" directive has been seen. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
509 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
510 | # Whether the TAP plan has been seen or not, and if yes, which kind |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
511 | # it is ("early" is seen before any test result, "late" otherwise). |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
512 | plan_seen = NO_PLAN |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
513 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
514 | ## --------- ## |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
515 | ## PARSING ## |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
516 | ## --------- ## |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
517 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
518 | is_first_read = 1 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
519 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
520 | while (1) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
521 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
522 | # Involutions required so that we are able to read the exit status |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
523 | # from the last input line. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
524 | st = getline |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
525 | if (st < 0) # I/O error. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
526 | fatal("I/O error while reading from input stream") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
527 | else if (st == 0) # End-of-input |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
528 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
529 | if (is_first_read) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
530 | abort("in input loop: only one input line") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
531 | break |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
532 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
533 | if (is_first_read) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
534 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
535 | is_first_read = 0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
536 | nextline = $0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
537 | continue |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
538 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
539 | else |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
540 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
541 | curline = nextline |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
542 | nextline = $0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
543 | $0 = curline |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
544 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
545 | # Copy any input line verbatim into the log file. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
546 | print | "cat >&3" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
547 | # Parsing of TAP input should stop after a "Bail out!" directive. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
548 | if (bailed_out) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
549 | continue |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
550 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
551 | # TAP test result. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
552 | if ($0 ~ /^(not )?ok$/ || $0 ~ /^(not )?ok[^a-zA-Z0-9_]/) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
553 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
554 | testno += 1 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
555 | setup_result_obj($0) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
556 | handle_tap_result() |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
557 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
558 | # TAP plan (normal or "SKIP" without explanation). |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
559 | else if ($0 ~ /^1\.\.[0-9]+[ \t]*$/) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
560 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
561 | # The next two lines will put the number of planned tests in $0. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
562 | sub("^1\\.\\.", "") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
563 | sub("[^0-9]*$", "") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
564 | handle_tap_plan($0, "") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
565 | continue |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
566 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
567 | # TAP "SKIP" plan, with an explanation. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
568 | else if ($0 ~ /^1\.\.0+[ \t]*#/) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
569 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
570 | # The next lines will put the skip explanation in $0, stripping |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
571 | # any leading and trailing whitespace. This is a little more |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
572 | # tricky in truth, since we want to also strip a potential leading |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
573 | # "SKIP" string from the message. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
574 | sub("^[^#]*#[ \t]*(SKIP[: \t][ \t]*)?", "") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
575 | sub("[ \t]*$", ""); |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
576 | handle_tap_plan(0, $0) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
577 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
578 | # "Bail out!" magic. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
579 | # Older versions of prove and TAP::Harness (e.g., 3.17) did not |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
580 | # recognize a "Bail out!" directive when preceded by leading |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
581 | # whitespace, but more modern versions (e.g., 3.23) do. So we |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
582 | # emulate the latter, "more modern" behaviour. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
583 | else if ($0 ~ /^[ \t]*Bail out!/) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
584 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
585 | bailed_out = 1 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
586 | # Get the bailout message (if any), with leading and trailing |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
587 | # whitespace stripped. The message remains stored in `$0`. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
588 | sub("^[ \t]*Bail out![ \t]*", ""); |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
589 | sub("[ \t]*$", ""); |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
590 | # Format the error message for the |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
591 | bailout_message = "Bail out!" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
592 | if (length($0)) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
593 | bailout_message = bailout_message " " $0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
594 | testsuite_error(bailout_message) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
595 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
596 | # Maybe we have too look for dianogtic comments too. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
597 | else if (comments != 0) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
598 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
599 | comment = extract_tap_comment($0); |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
600 | if (length(comment)) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
601 | report("#", comment); |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
602 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
603 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
604 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
605 | ## -------- ## |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
606 | ## FINISH ## |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
607 | ## -------- ## |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
608 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
609 | # A "Bail out!" directive should cause us to ignore any following TAP |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
610 | # error, as well as a non-zero exit status from the TAP producer. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
611 | if (!bailed_out) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
612 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
613 | if (!plan_seen) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
614 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
615 | testsuite_error("missing test plan") |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
616 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
617 | else if (planned_tests != testno) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
618 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
619 | bad_amount = testno > planned_tests ? "many" : "few" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
620 | testsuite_error(sprintf("too %s tests run (expected %d, got %d)", |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
621 | bad_amount, planned_tests, testno)) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
622 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
623 | if (!ignore_exit) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
624 | { |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
625 | # Fetch exit status from the last line. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
626 | exit_message = get_test_exit_message(nextline) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
627 | if (exit_message) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
628 | testsuite_error(exit_message) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
629 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
630 | } |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
631 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
632 | write_test_results() |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
633 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
634 | exit 0 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
635 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
636 | } # End of "BEGIN" block. |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
637 | ' |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
638 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
639 | # TODO: document that we consume the file descriptor 3 :-( |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
640 | } 3>"$log_file" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
641 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
642 | test $? -eq 0 || fatal "I/O or internal error" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
643 | |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
644 | # Local Variables: |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
645 | # mode: shell-script |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
646 | # sh-indentation: 2 |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
647 | # eval: (add-hook 'write-file-hooks 'time-stamp) |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
648 | # time-stamp-start: "scriptversion=" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
649 | # time-stamp-format: "%:y-%02m-%02d.%02H" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
650 | # time-stamp-time-zone: "UTC" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
651 | # time-stamp-end: "; # UTC" |
|
17c34d87c5b3
Initial conversion to gtester
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
652 | # End: |