1#!/bin/sh
2#
3#	aegis - project change supervisor
4#	Copyright (C) 2002, 2004-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
27LINES=24
28export LINES
29COLS=80
30export COLS
31
32USER=${USER:-${LOGNAME:-`whoami`}}
33
34work=${AEGIS_TMP:-/tmp}/$$
35worklib=$work/lib
36workproj=$work/foo.proj
37workchan=$work/foo.chan
38tmp=$work/tmp
39AEGIS_PATH=$worklib ; export AEGIS_PATH
40AEGIS_PROJECT=foo ; export AEGIS_PROJECT
41PAGER=cat
42export PAGER
43AEGIS_FLAGS="delete_file_preference = no_keep; \
44	lock_wait_preference = always; \
45	diff_preference = automatic_merge; \
46	pager_preference = never; \
47	persevere_preference = all; \
48	log_file_preference = never;"
49export AEGIS_FLAGS
50AEGIS_THROTTLE=-1
51export AEGIS_THROTTLE
52
53here=`pwd`
54if test $? -ne 0 ; then exit 2; fi
55
56bin=$here/${1-.}/bin
57
58if test "$EXEC_SEARCH_PATH" != ""
59then
60    tpath=
61    hold="$IFS"
62    IFS=":$IFS"
63    for tpath2 in $EXEC_SEARCH_PATH
64    do
65	tpath=${tpath}${tpath2}/${1-.}/bin:
66    done
67    IFS="$hold"
68    PATH=${tpath}${PATH}
69else
70    PATH=${bin}:${PATH}
71fi
72export PATH
73
74pass()
75{
76	set +x
77	echo PASSED 1>&2
78	cd $here
79	find $work -type d -user $USER -exec chmod u+w {} \;
80	rm -rf $work
81	exit 0
82}
83fail()
84{
85	set +x
86	echo "FAILED test of the minimum synchronisation functionality " 1>&2
87	cd $here
88	find $work -type d -user $USER -exec chmod u+w {} \;
89	rm -rf $work
90	exit 1
91}
92no_result()
93{
94	set +x
95	echo "NO RESULT when testing the minimum synchronisation functionality ($activity)" 1>&2
96	cd $here
97	find $work -type d -user $USER -exec chmod u+w {} \;
98	rm -rf $work
99	exit 2
100}
101trap \"no_result\" 1 2 3 15
102
103mkdir $work $work/lib
104if test $? -ne 0 ; then no_result; fi
105chmod 777 $work/lib
106if test $? -ne 0 ; then no_result; fi
107cd $work
108if test $? -ne 0 ; then no_result; fi
109
110#
111# use the built-in error messages
112#
113AEGIS_MESSAGE_LIBRARY=$work/no-such-dir
114export AEGIS_MESSAGE_LIBRARY
115unset LANG
116unset LANGUAGE
117
118#
119# test the minimum synchronisation functionality
120#
121#
122# make a new project
123#
124activity="new project 111"
125$bin/aegis -npr foo -vers "" -dir $workproj  > log 2>&1
126if test $? -ne 0 ; then cat log; no_result; fi
127
128#
129# change project attributes
130#
131activity="project attributes 118"
132cat > $tmp << 'end'
133description = "A bogus project created to test the minimum synchronisation functionality.";
134developer_may_review = true;
135developer_may_integrate = true;
136reviewer_may_integrate = true;
137end
138if test $? -ne 0 ; then no_result; fi
139$bin/aegis -pa -f $tmp > log 2>&1
140if test $? -ne 0 ; then cat log; no_result; fi
141
142#
143# create a new change
144#
145activity="new change 132"
146cat > $tmp << 'end'
147brief_description = "The first change";
148cause = internal_bug;
149test_exempt = true;
150test_baseline_exempt = true ;
151regression_test_exempt = true;
152end
153if test $? -ne 0 ; then no_result; fi
154
155$bin/aegis -nc 10 -f $tmp -p foo > log 2>&1
156if test $? -ne 0 ; then cat log; no_result; fi
157
158#
159# add the staff
160#
161activity="staff 148"
162$bin/aegis -nd $USER > log 2>&1
163if test $? -ne 0 ; then cat log; no_result; fi
164$bin/aegis -nrv $USER > log 2>&1
165if test $? -ne 0 ; then cat log; no_result; fi
166$bin/aegis -ni $USER > log 2>&1
167if test $? -ne 0 ; then cat log; no_result; fi
168
169#
170# begin development of a change
171#
172$bin/aegis -db 10 -dir $workchan > log 2>&1
173if test $? -ne 0 ; then cat log; no_result; fi
174
175cat > $workchan/aegis.conf << 'end'
176build_command = "echo Hello > non-source-file && exit 0";
177link_integration_directory = true;
178
179history_get_command = "aesvt -check-out -edit ${quote $edit} "
180    "-history ${quote $history} -f ${quote $output}";
181history_put_command = "aesvt -check-in -history ${quote $history} "
182    "-f ${quote $input}";
183history_query_command = "aesvt -query -history ${quote $history}";
184history_content_limitation = binary_capable;
185
186diff_command = "set +e; diff $orig $i > $out; test $$? -le 1";
187diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \
188	echo '1,$$p' ) | ed - $mr > $out";
189create_symlinks_before_build = true;
190remove_symlinks_after_integration_build = false;
191end
192if test $? -ne 0 ; then no_result; fi
193
194activity="New file 181"
195$bin/aegis -nf $workchan/aegis.conf > log 2>&1
196if test $? -ne 0 ; then cat log; no_result; fi
197
198activity="Build 185"
199$bin/aegis -b > log 2>&1
200if test $? -ne 0 ; then cat log; no_result; fi
201
202activity="Diff 189"
203$bin/aegis -diff > log 2>&1
204if test $? -ne 0 ; then cat log; no_result; fi
205
206
207activity="Develop end 194"
208$bin/aegis -de > log 2>&1
209if test $? -ne 0 ; then cat log; no_result; fi
210
211activity="Review Pass 198"
212$bin/aegis -rpass 10 > log 2>&1
213if test $? -ne 0 ; then cat log; no_result; fi
214
215activity="Integrate Begin 202"
216$bin/aegis -ib  10 > log 2>&1
217if test $? -ne 0 ; then cat log; no_result; fi
218
219activity="Integrate Build 206"
220$bin/aegis -b 10 > log 2>&1
221if test $? -ne 0 ; then cat log; no_result; fi
222
223activity="Integrate Pass 210"
224$bin/aegis -ipass 10 > log 2>&1
225if test $? -ne 0 ; then cat log; no_result; fi
226
227
228activity="new branch 215"
229$bin/aegis -nbr  1 -p foo > log 2>&1
230if test $? -ne 0 ; then cat log; no_result; fi
231
232
233# The second change
234activity="new change 221"
235cat > $tmp << 'end'
236brief_description = "The second change";
237cause = internal_bug;
238test_exempt = true;
239test_baseline_exempt = true ;
240regression_test_exempt = true;
241end
242if test $? -ne 0 ; then no_result; fi
243
244
245activity="new change 232"
246$bin/aegis -nc 11 -f $tmp -p foo.1 > log 2>&1
247if test $? -ne 0 ; then cat log; no_result; fi
248
249activity="Develop Begin 236"
250$bin/aegis -db 11 -dir $workchan -p foo.1 > log 2>&1
251if test $? -ne 0 ; then cat log; no_result; fi
252
253activity="Change Dir 240"
254devdir=`$bin/aegis -cd 11  -p foo.1`
255if test $? -ne 0 ; then no_result; fi
256cd $devdir
257if test $? -ne 0 ; then no_result; fi
258
259activity="Copy File 246"
260$bin/aegis -cp aegis.conf  -p foo.1 > log 2>&1
261if test $? -ne 0 ; then cat log; no_result; fi
262
263# Change the build command to not create any non source files
264activity="Mutate aegis.conf 251"
265grep -v 'build_command' aegis.conf > tmpConfig
266if test $? -ne 0 ; then cat log; no_result; fi
267echo 'build_command = "exit 0";' >> tmpConfig
268if test $? -ne 0 ; then cat log; no_result; fi
269mv tmpConfig aegis.conf
270if test $? -ne 0 ; then cat log; no_result; fi
271
272activity="Build 259"
273$bin/aegis -b 11  -p foo.1 > log 2>&1
274if test $? -ne 0 ; then cat log; no_result; fi
275
276activity="Diff 263"
277$bin/aegis -diff 11  -p foo.1 > log 2>&1
278if test $? -ne 0 ; then cat log; no_result; fi
279
280activity="Develop End 267"
281$bin/aegis -de 11  -p foo.1 > log 2>&1
282if test $? -ne 0 ; then cat log; no_result; fi
283
284activity="Review Pass 271"
285$bin/aegis -rpass 11  -p foo.1 > log 2>&1
286if test $? -ne 0 ; then cat log; no_result; fi
287
288activity="Integrate Begin 275"
289$bin/aegis -ib -minimum 11  -p foo.1 > log 2>&1
290if test $? -ne 0 ; then cat log; no_result; fi
291
292activity="Aesub  279"
293intdir=`$bin/aesub '$intdir' -c 11 -p foo.1`
294if test $? -ne 0 ; then cat log; no_result; fi
295
296# This build is implicitly minimum
297activity="Integrate Build 284"
298$bin/aegis -b  11  -p foo.1 > log 2>&1
299if test $? -ne 0 ; then cat log; no_result; fi
300
301# Non source files should not be present after a -minimum
302test ! -h $intdir/non-source-file
303if test $? -ne 0 ; then  fail ; fi
304
305activity="Integrate Begin Undo 292"
306$bin/aegis -ibu 11  -p foo.1 > log 2>&1
307if test $? -ne 0 ; then cat log; no_result; fi
308
309activity="Integrate Begin 296"
310$bin/aegis -ib  11  -p foo.1 > log 2>&1
311if test $? -ne 0 ; then cat log; no_result; fi
312
313activity="Aesub  300"
314intdir=`$bin/aesub '$intdir' -c 11 -p foo.1`
315if test $? -ne 0 ; then cat log; no_result; fi
316
317# This build is NOT minimum
318activity="Integrate Build 305"
319$bin/aegis -b  11  -p foo.1 > log 2>&1
320if test $? -ne 0 ; then cat log; no_result; fi
321
322# Non source files *should*  now be present
323test -h $intdir/non-source-file
324if test $? -ne 0 ; then  fail ; fi
325
326
327#
328# Only definite negatives are possible.
329# The functionality exercised by this test appears to work,
330# no other guarantees are made.
331#
332pass
333