1#!/bin/sh
2#
3#	aegis - project change supervisor
4#	Copyright (C) 1995-1998, 2006-2008 Peter Miller
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 3 of the License, or
9#	(at your option) 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
18#	<http://www.gnu.org/licenses/>.
19#
20
21unset AEGIS_PROJECT
22unset AEGIS_CHANGE
23unset AEGIS_PATH
24unset AEGIS
25unset LINES
26unset COLS
27umask 022
28
29USER=${USER:-${LOGNAME:-`whoami`}}
30
31work=${AEGIS_TMP:-/tmp}/$$
32PAGER=cat
33export PAGER
34AEGIS_FLAGS="delete_file_preference = no_keep; \
35	lock_wait_preference = always; \
36	diff_preference = automatic_merge; \
37	pager_preference = never; \
38	persevere_preference = all; \
39	log_file_preference = never;"
40export AEGIS_FLAGS
41AEGIS_THROTTLE=-1
42export AEGIS_THROTTLE
43
44here=`pwd`
45if test $? -ne 0 ; then exit 2; fi
46
47if test "$1" != "" ; then bin="$here/$1/bin"; else bin="$here/bin"; fi
48
49no_result()
50{
51	set +x
52	echo 'NO RESULT for test of the report wrap() functionality' 1>&2
53	cd $here
54	find $work -type d -user $USER -exec chmod u+w {} \;
55	rm -rf $work
56	exit 2
57}
58fail()
59{
60	set +x
61	echo 'FAILED test of the report wrap() functionality' 1>&2
62	cd $here
63	find $work -type d -user $USER -exec chmod u+w {} \;
64	rm -rf $work
65	exit 1
66}
67pass()
68{
69	set +x
70	echo PASSED 1>&2
71	cd $here
72	find $work -type d -user $USER -exec chmod u+w {} \;
73	rm -rf $work
74	exit 0
75}
76trap \"no_result\" 1 2 3 15
77
78mkdir $work
79if test $? -ne 0 ; then no_result; fi
80cd $work
81if test $? -ne 0 ; then no_result; fi
82
83#
84# test the report wrap() functionality
85#
86cat > test.in << 'fubar'
87columns(80);
88auto x, y;
89x = "This is a long line which needs to be wrapped.\nAnd this is another line.";
90y = wrap(x, 20);
91for (x in y)
92	print(x);
93fubar
94if test $? -ne 0 ; then no_result; fi
95
96cat > test.ok << 'fubar'
97This is a long line
98which needs to be
99wrapped.
100And this is another
101line.
102fubar
103if test $? -ne 0 ; then no_result; fi
104
105$bin/aegis -report -f test.in -unf > test.out
106if test $? -ne 0 ; then fail; fi
107
108diff test.ok test.out
109if test $? -ne 0 ; then fail; fi
110
111#
112# Only definite negatives are possible.
113# The functionality exercised by this test appears to work,
114# no other guarantees are made.
115#
116pass
117