xref: /freebsd/contrib/dialog/run_test.sh (revision bbd421cdf6d8c6102e6fd3979c5bec21ace3c2e3)
1#!/bin/sh
2# $Id: run_test.sh,v 1.1 2020/03/20 12:08:00 tom Exp $
3##############################################################################
4# Copyright (c) 2020 Thomas E. Dickey                                        #
5#                                                                            #
6# Permission is hereby granted, free of charge, to any person obtaining a    #
7# copy of this software and associated documentation files (the "Software"), #
8# to deal in the Software without restriction, including without limitation  #
9# the rights to use, copy, modify, merge, publish, distribute, distribute    #
10# with modifications, sublicense, and/or sell copies of the Software, and to #
11# permit persons to whom the Software is furnished to do so, subject to the  #
12# following conditions:                                                      #
13#                                                                            #
14# The above copyright notice and this permission notice shall be included in #
15# all copies or substantial portions of the Software.                        #
16#                                                                            #
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
20# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
22# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
23# DEALINGS IN THE SOFTWARE.                                                  #
24#                                                                            #
25# Except as contained in this notice, the name(s) of the above copyright     #
26# holders shall not be used in advertising or otherwise to promote the sale, #
27# use or other dealings in this Software without prior written               #
28# authorization.                                                             #
29##############################################################################
30
31failed() {
32	echo "? $*" >&2
33	exit 1
34}
35
36: ${DIALOG=./dialog}
37CONFIG=samples
38INPUTS=inputs.rc
39OUTPUT=output.rc
40
41[ $# != 0 ] && CONFIG="$1"
42
43[ -f "$DIALOG" ] || failed "no such file: $DIALOG"
44[ -d "$CONFIG" ] || failed "no such directory: $CONFIG"
45
46for rcfile in $CONFIG/*.rc
47do
48	echo "** $rcfile"
49	DIALOGRC="$rcfile" $DIALOG --create-rc $OUTPUT
50	sed -e '/^#/d' "$OUTPUT" >"$INPUTS"
51	mv -f $INPUTS $OUTPUT
52	sed -e '/^#/d' "$rcfile" >"$INPUTS"
53	diff -u $INPUTS $OUTPUT | \
54		sed	-e "s,$INPUTS,$rcfile," \
55			-e "s,$OUTPUT,$rcfile-test,"
56done
57
58rm -f $INPUTS $OUTPUT
59