1#!/bin/sh
2#
3#       aegis - project change supervisor
4#       Copyright (C) 1998, 2005-2008, 2012 Peter Miller
5#       Copyright (C) 2006, 2008 Walter Franzini
6#
7#       This program is free software; you can redistribute it and/or modify
8#       it under the terms of the GNU General Public License as published by
9#       the Free Software Foundation; either version 3 of the License, or
10#       (at your option) any later version.
11#
12#       This program is distributed in the hope that it will be useful,
13#       but WITHOUT ANY WARRANTY; without even the implied warranty of
14#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15#       GNU General Public License for more details.
16#
17#       You should have received a copy of the GNU General Public License
18#       along with this program. If not, see
19#       <http://www.gnu.org/licenses/>.
20#
21
22unset AEGIS_PROJECT
23unset AEGIS_CHANGE
24unset AEGIS_PATH
25unset AEGIS
26unset LINES
27unset COOK
28umask 022
29
30USER=${USER:-${LOGNAME:-`whoami`}}
31
32PAGER=cat
33export PAGER
34
35AEGIS_FLAGS="delete_file_preference = no_keep; \
36        lock_wait_preference = always; \
37        diff_preference = automatic_merge; \
38        pager_preference = never; \
39        persevere_preference = all; \
40        log_file_preference = never;"
41export AEGIS_FLAGS
42AEGIS_THROTTLE=-1
43export AEGIS_THROTTLE
44
45COLS=65
46export COLS
47work=${AEGIS_TMP:-/tmp}/$$
48
49here=`pwd`
50if test $? -ne 0 ; then exit 2; fi
51
52if test "$1" != "" ; then bin="$here/$1/bin"; else bin="$here/bin"; fi
53
54no_result()
55{
56        set +x
57        echo "NO RESULT for test of aeclean ($activity)" 1>&2
58        cd $here
59        find $work -type d -user $USER -exec chmod u+w {} \;
60        rm -rf $work
61        exit 2
62}
63fail()
64{
65        set +x
66        echo "FAILED test of aeclean ($activity)" 1>&2
67        cd $here
68        find $work -type d -user $USER -exec chmod u+w {} \;
69        rm -rf $work
70        exit 1
71}
72pass()
73{
74        set +x
75        echo PASSED 1>&2
76        cd $here
77        find $work -type d -user $USER -exec chmod u+w {} \;
78        rm -rf $work
79        exit 0
80}
81trap "no_result" 1 2 3 15
82
83#
84# some variable to make things earier to read
85#
86worklib=$work/lib
87workproj=$work/example.proj
88workchan=$work/example.chan
89tmp=$work/tmp
90
91#
92# make the directories
93#
94activity="working directory 94"
95mkdir $work $work/lib
96if test $? -ne 0 ; then no_result; fi
97chmod 777 $work/lib
98if test $? -ne 0 ; then no_result; fi
99cd $work
100if test $? -ne 0 ; then no_result; fi
101
102AEGIS_PATH=$worklib
103export AEGIS_PATH
104PATH=$bin:$PATH
105export PATH
106AEGIS_PROJECT=example
107export AEGIS_PROJECT
108
109#
110# use the built-in error messages
111#
112AEGIS_MESSAGE_LIBRARY=$work/no-such-dir
113export AEGIS_MESSAGE_LIBRARY
114unset LANG
115unset LANGUAGE
116
117#
118# make a new project
119#
120activity="new project 120"
121$bin/aegis -newpro example -version "" -dir $workproj -v -lib $worklib > log 2>&1
122if test $? -ne 0 ; then cat log; fail; fi
123
124#
125# change project attributes
126#
127activity="project attributes 127"
128cat > $tmp << 'TheEnd'
129description = "aegis user's guide";
130developer_may_review = true;
131developer_may_integrate = true;
132reviewer_may_integrate = true;
133TheEnd
134if test $? -ne 0 ; then no_result; fi
135
136$bin/aegis -proatt -f $tmp -proj example -v > log 2>&1
137if test $? -ne 0 ; then cat log; fail; fi
138
139#
140# create a new change
141#
142activity="new change 142"
143cat > $tmp << 'TheEnd'
144brief_description = "Place under aegis";
145description = "A simple calculator using native floating point precision.  \
146The four basic arithmetic operators to be provided, \
147using conventional infix notation.  \
148Parentheses and negation also required.";
149cause = internal_enhancement;
150TheEnd
151if test $? -ne 0 ; then no_result; fi
152
153$bin/aegis -new_change 1 -f $tmp -project example -v > log 2>&1
154if test $? -ne 0 ; then cat log; fail; fi
155
156#
157# add a new developer
158#
159activity="new developer 159"
160$bin/aegis -newdev $USER -v > log 2>&1
161if test $? -ne 0 ; then cat log; fail; fi
162
163#
164# begin development of the change
165#
166activity="develop begin 166"
167$bin/aegis -devbeg 1 -dir $workchan -v > log 2>&1
168if test $? -ne 0 ; then cat log; no_result; fi
169
170#
171# add the new files to the change
172#
173activity="new file 173"
174$bin/aegis -new_file $workchan/aegis.conf -nl -v > log 2>&1
175if test $? -ne 0 ; then cat log; no_result; fi
176
177cat > $workchan/aegis.conf << 'fubar'
178build_command = "exit 0";
179history_create_command = "exit 0";
180history_get_command = "exit 0";
181history_put_command = "exit 0";
182history_query_command = "exit 0";
183diff_command = "exit 0";
184merge_command = "exit 0";
185clean_exceptions = [ "keep.*" ];
186fubar
187if test $? -ne 0 ; then cat log; no_result; fi
188
189date > $workchan/junk
190if test $? -ne 0 ; then no_result; fi
191
192date > $workchan/keep.garbage
193if test $? -ne 0 ; then no_result; fi
194
195activity="clean the change 195"
196$bin/aegis -clean -nl -v > log 2>&1
197if test $? -ne 0 ; then cat log; fail; fi
198
199test -r $workchan/junk && fail
200test ! -r $workchan/keep.garbage && fail
201test ! -r $workchan/aegis.conf && fail
202
203
204#
205# the things tested in this test, worked
206# the things not tested in this test, may or may not work
207#
208pass
209# vim: set ts=8 sw=4 et :
210