1#!/bin/sh
2#
3#	aegis - project change supervisor
4#	Copyright (C) 1994-1998, 2005-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
25umask 022
26
27USER=${USER:-${LOGNAME:-`whoami`}}
28
29work=${AEGIS_TMP:-/tmp}/$$
30PAGER=cat
31export PAGER
32
33AEGIS_FLAGS="delete_file_preference = no_keep; \
34	lock_wait_preference = always; \
35	diff_preference = automatic_merge; \
36	pager_preference = never; \
37	persevere_preference = all; \
38	log_file_preference = never;"
39export AEGIS_FLAGS
40AEGIS_THROTTLE=-1
41export AEGIS_THROTTLE
42
43LINES=66
44export LINES
45COLS=80
46export COLS
47
48here=`pwd`
49if test $? -ne 0 ; then exit 2; fi
50
51if test "$1" != "" ; then bin="$here/$1/bin"; else bin="$here/bin"; fi
52
53no_result()
54{
55	set +x
56	echo "NO RESULT for test of the report generator functionality ($activity)" 1>&2
57	cd $here
58	find $work -type d -user $USER -exec chmod u+w {} \;
59	rm -rf $work
60	exit 2
61}
62fail()
63{
64	set +x
65	echo "FAILED test of the report generator functionality ($activity)" 1>&2
66	cd $here
67	find $work -type d -user $USER -exec chmod u+w {} \;
68	rm -rf $work
69	exit 1
70}
71pass()
72{
73	set +x
74	echo PASSED
75	cd $here
76	find $work -type d -user $USER -exec chmod u+w {} \;
77	rm -rf $work
78	exit 0
79}
80trap \"no_result\" 1 2 3 15
81
82activity="working directory 75"
83mkdir $work $work/lib $work/lib/report
84if test $? -ne 0 ; then no_result; fi
85cd $work
86if test $? -ne 0 ; then no_result; fi
87chmod a+rwx $work/lib
88if test $? -ne 0 ; then no_result; fi
89
90AEGIS_PATH=$work/lib
91export AEGIS_PATH
92
93#
94# use the built-in error messages
95#
96AEGIS_MESSAGE_LIBRARY=$work/no-such-dir
97export AEGIS_MESSAGE_LIBRARY
98unset LANG
99unset LANGUAGE
100
101#
102# create project and changes
103#
104activity="working directory 111"
105$bin/aegis -npr foo -vers "" -dir $work/proj
106if test $? -ne 0 ; then no_result; fi
107
108activity="new change 115"
109cat > $work/fred << 'fubar'
110brief_description = "just an example";
111cause = internal_bug;
112fubar
113if test $? -ne 0 ; then no_result; fi
114$bin/aegis -nc 1 -f $work/fred -p foo
115if test $? -ne 0 ; then no_result; fi
116
117activity="new change 124"
118cat > $work/fred << 'fubar'
119brief_description = "another example";
120cause = internal_enhancement;
121fubar
122if test $? -ne 0 ; then no_result; fi
123$bin/aegis -nc 2 -f $work/fred -p foo
124if test $? -ne 0 ; then no_result; fi
125
126#
127# test do and while loops
128#
129activity="while 136"
130cat > test.in << 'fubar'
131title("Change State", "delete this line");
132columns
133(
134	{ name = "Number\n------"; width = 6; },
135	{ name = "Description\n-----------"; right = 0; }
136);
137auto ps, cn, cs;
138ps = project["foo"].state.branch;
139for (cn in sort(keys(ps.change)))
140{
141	cs = ps.change[cn];
142	print(sprintf("%4d", cs.change_number), cs.description);
143}
144fubar
145if test $? -ne 0 ; then no_result; fi
146cat > test.ok << 'fubar'
1471 just an example
1482 another example
149fubar
150if test $? -ne 0 ; then no_result; fi
151$bin/aegis -rpt -f test.in -o test.out -unf
152if test $? -ne 0 ; then cat test.out; fail; fi
153diff -b test.ok test.out
154if test $? -ne 0 ; then fail; fi
155
156#
157# Only definite negatives are possible.
158# The functionality exercised by this test appears to work,
159# no other guarantees are made.
160#
161pass
162