1#!/bin/sh
2#
3#	aegis - project change supervisor
4#	Copyright (C) 2004 Walter Franzini;
5#	All rights reserved.
6#       Copyright (C) 2007, 2008 Peter Miller
7#
8#	This program is free software; you can redistribute it and/or modify
9#	it under the terms of the GNU General Public License as published by
10#	the Free Software Foundation; either version 3 of the License, or
11#	(at your option) any later version.
12#
13#	This program is distributed in the hope that it will be useful,
14#	but WITHOUT ANY WARRANTY; without even the implied warranty of
15#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16#	GNU General Public License for more details.
17#
18#	You should have received a copy of the GNU General Public License
19#	along with this program. If not, see
20#	<http://www.gnu.org/licenses/>.
21#
22
23unset AEGIS_PROJECT
24unset AEGIS_CHANGE
25unset AEGIS_PATH
26unset AEGIS
27umask 022
28
29LINES=24
30export LINES
31COLS=80
32export COLS
33
34USER=${USER:-${LOGNAME:-`whoami`}}
35
36work=${AEGIS_TMP:-/tmp}/$$
37workchan=${work}/foo.chan
38workproj=${work}/foo.proj
39tmp=${work}/tmp
40PAGER=cat
41export PAGER
42AEGIS_FLAGS="delete_file_preference = no_keep; \
43	lock_wait_preference = always; \
44	diff_preference = automatic_merge; \
45	pager_preference = never; \
46	persevere_preference = all; \
47	log_file_preference = never;"
48export AEGIS_FLAGS
49AEGIS_THROTTLE=-1
50export AEGIS_THROTTLE
51AEGIS_PROJECT=foo
52export AEGIS_PROJECT
53AEGIS_PATH=$work/lib
54export AEGIS_PATH
55
56here=`pwd`
57if test $? -ne 0 ; then exit 2; fi
58
59bin=$here/${1-.}/bin
60
61pass()
62{
63	set +x
64	echo PASSED 1>&2
65	cd $here
66	find $work -type d -user $USER -exec chmod u+w {} \;
67	rm -rf $work
68	exit 0
69}
70fail()
71{
72	set +x
73	echo "FAILED test of the aenbru functionality ($activity)" 1>&2
74	cd $here
75	find $work -type d -user $USER -exec chmod u+w {} \;
76	rm -rf $work
77	exit 1
78}
79no_result()
80{
81	set +x
82	echo "NO RESULT when testing the aenbru functionality ($activity)" 1>&2
83	cd $here
84	find $work -type d -user $USER -exec chmod u+w {} \;
85	rm -rf $work
86	exit 2
87}
88trap \"no_result\" 1 2 3 15
89
90mkdir $work $work/lib
91if test $? -ne 0 ; then no_result; fi
92chmod 777 $work/lib
93if test $? -ne 0 ; then no_result; fi
94cd $work
95if test $? -ne 0 ; then no_result; fi
96
97#
98# use the built-in error messages
99#
100AEGIS_MESSAGE_LIBRARY=$work/no-such-dir
101export AEGIS_MESSAGE_LIBRARY
102unset LANG
103unset LANGUAGE
104
105#
106# make a new project
107#
108activity="new project 128"
109$bin/aegis -npr foo -vers "" -dir $workproj > log 2>&1
110if test $? -ne 0 ; then cat log; no_result; fi
111
112activity="new branch 1  132"
113$bin/aegis -nbr -p foo 1 > log 2>&1
114if test $? -ne 0 ; then cat log; no_result; fi
115
116activity="new branch 1.1 136"
117$bin/aegis -nbr -p foo.1 1 >  log 2>&1
118if test $? -ne 0 ; then cat log; no_result; fi
119
120activity="new branch alias 140"
121$bin/aegis -npa -p foo.1.1 balias > log 2>&1
122if test $? -ne 0 ; then cat log; no_result; fi
123
124activity="new project alias 144"
125$bin/aegis -npa -p foo palias > log 2>&1
126if test $? -ne 0; then cat log; no_result; fi
127
128activity="alias list 148"
129$bin/aegis -list pa -unf | grep alias | sort > alias.list
130if test $? -ne 0; then no_result; fi
131
132cat > alias.expect <<EOF
133balias foo.1.1
134palias foo
135EOF
136
137diff alias.expect alias.list > log 2>&1
138if test $? -ne 0 ; then cat log ; no_result; fi
139
140cat > alias2.expect <<EOF
141palias foo
142EOF
143
144activity="new branch undo 164"
145$bin/aegis -nbru -p foo.1 1 > log 2>&1
146if test $? -ne 0; then cat log; no_result; fi
147
148activity="alias list after nbru 168"
149$bin/aegis -list pa -unf | grep alias | sort > alias2.list
150if test $? -ne 0; then cat log; no_result; fi
151
152diff alias2.expect alias2.list > log
153if test $? -ne 0; then cat log ; fail ; fi
154
155#
156# Only definite negatives are possible.
157# The functionality exercised by this test appears to work,
158# no other guarantees are made.
159#
160pass
161