1#!/bin/sh
2#
3#       aegis - project change supervisor
4#       Copyright (C) 1996-1998, 2000, 2004-2008, 2012 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="default_project_directory = \"$work\"; \
35        lock_wait_preference = always; \
36        default_development_directory = \"$work\"; \
37        delete_file_preference = no_keep; \
38        diff_preference = automatic_merge; \
39        pager_preference = never; \
40        persevere_preference = all; \
41        log_file_preference = never;"
42export AEGIS_FLAGS
43AEGIS_THROTTLE=-1
44export AEGIS_THROTTLE
45
46here=`pwd`
47if test $? -ne 0 ; then exit 2; fi
48
49bin=$here/${1-.}/bin
50
51pass()
52{
53        set +x
54        echo PASSED 1>&2
55        cd $here
56        find $work -type d -user $USER -exec chmod u+w {} \;
57        rm -rf $work
58        exit 0
59}
60fail()
61{
62        set +x
63        echo "FAILED test of the aentu directory functionality ($activity)" 1>&2
64        cd $here
65        find $work -type d -user $USER -exec chmod u+w {} \;
66        rm -rf $work
67        exit 1
68}
69no_result()
70{
71        set +x
72        echo "NO RESULT for test of the aentu directory functionality ($activity)" 1>&2
73        cd $here
74        find $work -type d -user $USER -exec chmod u+w {} \;
75        rm -rf $work
76        exit 2
77}
78trap \"no_result\" 1 2 3 15
79
80check_it()
81{
82        sed     -e "s|$work|...|g" \
83                -e 's|= [0-9][0-9]*; /.*|= TIME;|' \
84                -e "s/\"$USER\"/\"USER\"/g" \
85                -e 's/19[0-9][0-9]/YYYY/' \
86                -e 's/20[0-9][0-9]/YYYY/' \
87                -e 's/node = ".*"/node = "NODE"/' \
88                -e 's/crypto = ".*"/crypto = "GUNK"/' \
89                -e 's/uuid = ".*"/uuid = "UUID"/' \
90                < $2 > $work/sed.out
91        if test $? -ne 0; then no_result; fi
92        diff -b $1 $work/sed.out
93        if test $? -ne 0; then fail; fi
94}
95
96activity="working directory 96"
97mkdir $work $work/lib
98if test $? -ne 0 ; then no_result; fi
99chmod 777 $work/lib
100if test $? -ne 0 ; then no_result; fi
101cd $work
102if test $? -ne 0 ; then no_result; fi
103
104AEGIS_PROJECT=test
105export AEGIS_PROJECT
106AEGIS_PATH=$work/lib
107export AEGIS_PATH
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# test the aentu directory functionality
119#
120activity="new project 120"
121$bin/aegis -npr $AEGIS_PROJECT -vers "" -v -dir $work/test > log 2>&1
122if test $? -ne 0 ; then cat log; no_result; fi
123
124activity="project attributes 124"
125cat > paf << 'fubar'
126developer_may_review = true;
127developer_may_integrate = true;
128reviewer_may_integrate = true;
129default_test_exemption = true;
130fubar
131if test $? -ne 0 ; then no_result; fi
132$bin/aegis -pa -f paf -v > log 2>&1
133if test $? -ne 0 ; then cat log; no_result; fi
134
135activity="new change 135"
136cat > caf << 'fubar'
137brief_description = "ten";
138cause = internal_enhancement;
139fubar
140if test $? -ne 0 ; then no_result; fi
141$bin/aegis -nc -p $AEGIS_PROJECT -f caf -v > log 2>&1
142if test $? -ne 0 ; then cat log; no_result; fi
143
144activity="staff 144"
145$bin/aegis -nd $USER -v > log 2>&1
146if test $? -ne 0 ; then cat log; no_result; fi
147$bin/aegis -nrv $USER -v > log 2>&1
148if test $? -ne 0 ; then cat log; no_result; fi
149$bin/aegis -ni $USER -v > log 2>&1
150if test $? -ne 0 ; then cat log; no_result; fi
151
152activity="develop begin 152"
153$bin/aegis -db 10 -v > log 2>&1
154if test $? -ne 0 ; then cat log; no_result; fi
155
156activity="new file 156"
157$bin/aegis -nf $work/test.C010/aegis.conf -v > log 2>&1
158if test $? -ne 0 ; then cat log; no_result; fi
159
160cat > $work/test.C010/aegis.conf << 'fubar'
161build_command = "exit 0";
162diff_command = "echo $orig $input > $output";
163diff3_command = "exit 0; echo $orig $mr $input $output";
164history_create_command = "exit 0; echo $history $input";
165history_put_command = "exit 0; echo $history $input";
166history_get_command = "exit 0; echo $history $output";
167history_query_command = "echo 1.1; exit 0; echo $history";
168fubar
169if test $? -ne 0 ; then no_result; fi
170
171activity="new test 171"
172$bin/aegis -nt -v > log 2>&1
173if test $? -ne 0 ; then cat log; no_result; fi
174
175activity="new test 175"
176$bin/aegis -nt -v > log 2>&1
177if test $? -ne 0 ; then cat log; no_result; fi
178
179activity="new test undo 179"
180$bin/aegis -ntu $work/test.C010/test -v > log 2>&1
181if test $? -ne 0 ; then cat log; fail; fi
182
183activity="check change file state 183"
184cat > ok << 'fubar'
185src =
186[
187        {
188                file_name = "aegis.conf";
189                uuid = "UUID";
190                action = create;
191                usage = config;
192        },
193];
194fubar
195if test $? -ne 0 ; then no_result; fi
196check_it ok $work/test/info/change/0/010.fs
197
198#
199# Only definite negatives are possible.
200# The functionality exercised by this test appears to work,
201# no other guarantees are made.
202#
203pass
204# vim: set ts=8 sw=4 et :
205