Debian Codegraph @

tests/common

raw
1 # common variables / subroutines / load-time actions
2
3 # Copyright (C) 2010-2022 Thien-Thi Nguyen
4 #
5 # This file is part of GNU RCS.
6 #
7 # GNU RCS is free software: you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # GNU RCS is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty
14 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 # See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 # (shell-script-mode)
21
22 # variables
23
24 PATH="${PATHPREFIX}:$PATH"
25 RCSINIT=
26 stem=`basename $0`
27 wd=${stem}.d
28 w=$wd/x
29 v=$wd/x,v
30 TMPDIR=$wd ; export TMPDIR
31
32 result=
33
34 if [ x"$VERBOSE" = x1 ]
35 then hey= ; shh=':' ; KEEPD=1
36 else shh= ; hey=':'
37 fi
38
39 # subroutines
40
41 split_std_out_err ()
42 {
43 exec 1>${wd}/out
44 if [ "x$1" = xno ]
45 then exec 2>&1
46 else exec 2>${wd}/err
47 fi
48 }
49
50 bundled_commav ()
51 {
52 echo $srcdir/fake/$1
53 }
54
55 problem ()
56 {
57 echo >&2 PROBLEM: "$@"
58 exit 1
59 }
60
61 must ()
62 {
63 eval "$@" || problem command failed: "$@"
64 }
65
66 say_what ()
67 {
68 problem unexpected output for: "$@"
69 }
70
71 noiselessness_rules ()
72 {
73 # $1 -- filename
74 # $2 -- shell command
75 test -s $1 && say_what "$2"
76 }
77
78 silence_means_death ()
79 {
80 # $1 -- filename
81 # $2 -- shell command
82 test -s $1 || problem "no output for: $2"
83 }
84
85 bad_RCSfile ()
86 {
87 # $1 -- description in the form of ADJECTIVE-PHRASE
88 problem "$v $1"
89 }
90
91 # load-time actions
92
93 rm -rf $wd && mkdir $wd || exit 1
94 test x"$KEEPD" = x1 \
95 || trap 'result=$? ; test 0 = $result && rm -rf $wd' 0
96
97 # common ends here