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