1#!/bin/sh
2#
3#	aegis - project change supervisor
4#	Copyright (C) 1999, 2000, 2002, 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}/$$
32
33here=`pwd`
34if test $? -ne 0 ; then exit 2; fi
35
36if test "$1" != "" ; then bin="$here/$1/bin"; else bin="$here/bin"; fi
37
38check_it()
39{
40	sed	-e "s|$work|...|g" \
41		-e 's|= [0-9][0-9]*; /.*|= TIME;|' \
42		-e "s/\"$USER\"/\"USER\"/g" \
43		-e 's/19[0-9][0-9]/YYYY/' \
44		-e 's/20[0-9][0-9]/YYYY/' \
45		-e 's/node = ".*"/node = "NODE"/' \
46		-e 's/crypto = ".*"/crypto = "GUNK"/' \
47		< $2 > $work/sed.out
48	if test $? -ne 0; then no_result; fi
49	diff $1 $work/sed.out
50	if test $? -ne 0; then fail; fi
51}
52
53no_result()
54{
55	set +x
56	echo "NO RESULT for test of new change -o 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 new change -o 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 1>&2
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
82#
83# some variable to make things earier to read
84#
85PAGER=cat
86export PAGER
87
88AEGIS_FLAGS="delete_file_preference = no_keep; \
89	lock_wait_preference = always; \
90	diff_preference = automatic_merge; \
91	pager_preference = never; \
92	persevere_preference = all; \
93	log_file_preference = never;"
94export AEGIS_FLAGS
95AEGIS_THROTTLE=-1
96export AEGIS_THROTTLE
97
98worklib=$work/lib
99workproj=$work/foo.proj
100workchan=$work/foo.chan
101tmp=$work/tmp
102AEGIS_PATH=$worklib ; export AEGIS_PATH
103AEGIS_PROJECT=foo ; export AEGIS_PROJECT
104
105#
106# make the directories
107#
108activity="working directory 81"
109mkdir $work $work/lib
110if test $? -ne 0 ; then no_result; fi
111chmod 777 $work/lib
112if test $? -ne 0 ; then no_result; fi
113cd $work
114if test $? -ne 0 ; then no_result; fi
115
116#
117# use the built-in error messages
118#
119AEGIS_MESSAGE_LIBRARY=$work/no-such-dir
120export AEGIS_MESSAGE_LIBRARY
121unset LANG
122unset LANGUAGE
123
124#
125# make a new project
126#
127activity="new project 161"
128$bin/aegis -npr foo -vers "" -dir $workproj > log 2>&1
129if test $? -ne 0 ; then cat log; no_result; fi
130
131#
132# change project attributes
133#
134activity="project attributes 168"
135cat > $tmp << 'end'
136description = "A bogus project created to test the new change -o functionality.";
137developer_may_review = true;
138developer_may_integrate = true;
139reviewer_may_integrate = true;
140default_test_exemption = true;
141end
142if test $? -ne 0 ; then no_result; fi
143$bin/aegis -pa -f $tmp > log 2>&1
144if test $? -ne 0 ; then cat log; no_result; fi
145
146#
147# add the staff
148#
149activity="staff 207"
150$bin/aegis -nd $USER > log 2>&1
151if test $? -ne 0 ; then cat log; no_result; fi
152$bin/aegis -nrv $USER > log 2>&1
153if test $? -ne 0 ; then cat log; no_result; fi
154$bin/aegis -ni $USER > log 2>&1
155if test $? -ne 0 ; then cat log; no_result; fi
156
157$bin/aegis -nbr -p foo 4 > log 2>&1
158if test $? -ne 0 ; then cat log; no_result; fi
159
160$bin/aegis -nbr -p foo.4 2 > log 2>&1
161if test $? -ne 0 ; then cat log; no_result; fi
162
163AEGIS_PROJECT=foo.4.2 ; export AEGIS_PROJECT
164
165#
166# create a new change
167#
168activity="new change 183"
169cat > $tmp << 'end'
170brief_description = "The first change";
171cause = internal_bug;
172end
173if test $? -ne 0 ; then no_result; fi
174$bin/aegis -nc -o $work/NUM -f $tmp -p foo.4.2 > log 2>&1
175if test $? -ne 0 ; then cat log; fail; fi
176
177NUM=`cat $work/NUM`
178if test $? -ne 0 ; then fail; fi
179
180#
181# begin development of a change
182#
183$bin/aegis -db $NUM -dir $workchan > log 2>&1
184if test $? -ne 0 ; then cat log; no_result; fi
185
186#
187# the things tested in this test, worked
188#
189pass
190