1#!/bin/sh
2#
3# aegis - The "aegis" program.
4# Copyright (C) 2008 Walter Franzini
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 (at
9# 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 GNU
14# General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19
20TEST_SUBJECT="unlink before open functionality"
21
22# load up standard prelude and test functions
23. test_funcs
24
25AEGIS_PROJECT=example
26export AEGIS_PROJECT
27
28workproj=$work/proj
29workchan=$work/chan
30
31#
32# make a new project
33#
34activity="new project 34"
35aegis -npr $AEGIS_PROJECT -vers "" -dir $workproj > log 2>&1
36if test $? -ne 0 ; then cat log; no_result; fi
37
38#
39# change project attributes
40#
41activity="project attributes 41"
42cat > tmp << 'end'
43description = "A bogus project created to test the unlink before open "
44    "functionality.";
45developer_may_review = true;
46developer_may_integrate = true;
47reviewer_may_integrate = true;
48default_test_exemption = true;
49develop_end_action = goto_awaiting_integration;
50end
51if test $? -ne 0 ; then no_result; fi
52aegis -pa -f tmp > log 2>&1
53if test $? -ne 0 ; then cat log; no_result; fi
54
55#
56# add the staff
57#
58activity="staff 58"
59aegis -nd $USER > log 2>&1
60if test $? -ne 0 ; then cat log; no_result; fi
61aegis -nrv $USER > log 2>&1
62if test $? -ne 0 ; then cat log; no_result; fi
63aegis -ni $USER > log 2>&1
64if test $? -ne 0 ; then cat log; no_result; fi
65
66#
67# create a new change
68#
69activity="new change 69"
70cat > tmp << 'end'
71brief_description = "The first change";
72cause = internal_bug;
73end
74if test $? -ne 0 ; then no_result; fi
75aegis -nc 1 -f tmp -p $AEGIS_PROJECT > log 2>&1
76if test $? -ne 0 ; then cat log; no_result; fi
77
78#
79# begin development of a change
80#
81aegis -db 1 -dir $workchan > log 2>&1
82if test $? -ne 0 ; then cat log; no_result; fi
83
84#
85# add a new files to the change
86#
87activity="new files 87"
88aegis -nf  $workchan/bogus1 -nl \
89        --uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd1 > log 2>&1
90if test $? -ne 0 ; then cat log; no_result; fi
91aegis -nf  $workchan/aegis.conf -nl \
92        --uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddddd3 > log 2>&1
93if test $? -ne 0 ; then cat log; no_result; fi
94
95cat > $workchan/bogus1 << 'end'
96OLD CONTENT
97bogus1, line 1
98bogus1, line 2
99end
100if test $? -ne 0 ; then no_result; fi
101
102#
103# Save the content of bogus1 for future use
104#
105cp $workchan/bogus1 $work/bogus2
106if test $? -ne 0 ; then no_result; fi
107
108cat > $workchan/aegis.conf << 'end'
109build_command = "exit 0";
110link_integration_directory = true;
111
112history_get_command = "aesvt -check-out -edit ${quote $edit} "
113    "-history ${quote $history} -f ${quote $output}";
114history_put_command = "aesvt -check-in -history ${quote $history} "
115    "-f ${quote $input}";
116history_query_command = "aesvt -query -history ${quote $history}";
117history_content_limitation = binary_capable;
118
119diff_command = "set +e; $diff $orig $i > $out; test $$? -le 1";
120merge_command = "(diff3 -e $i $orig $mr | sed -e '/^w$$/d' -e '/^q$$/d'; \
121	echo '1,$$p' ) | ed - $i > $out";
122patch_diff_command = "set +e; $diff -C0 -L $index -L $index $orig $i > $out; \
123test $$? -le 1";
124end
125if test $? -ne 0 ; then no_result; fi
126
127#
128# build the change
129#
130activity="finish the change 130"
131aefinish -v > log 2>&1
132if test $? -ne 0 ; then cat log; no_result; fi
133
134#
135# start integrating
136#
137activity="integrate begin 137"
138aegis -ib 1 > log 2>&1
139if test $? -ne 0 ; then cat log; no_result; fi
140
141#
142# finish integration
143#
144activity="integrate the change 144"
145aefinish -c 1 > log 2>&1
146if test $? -ne 0 ; then cat log; no_result; fi
147
148cp -al $workproj $work/proj2 > log 2>&1
149if test $? -ne 0; then cat log; no_result; fi
150
151activity="create new project 151"
152aegis -npr -p example2 -keep -dir $work/proj2 -verb > log 2>&1
153if test $? -ne 0; then cat log; no_result; fi
154
155aegis -list c -p example -unf > example.changes 2>log
156if test $? -ne 0; then cat log; no_result; fi
157
158aegis -list c -p example2 -unf > example2.changes 2>log
159if test $? -ne 0; then cat log; no_result; fi
160
161diff example.changes example2.changes
162if test $? -ne 0; then no_result; fi
163
164activity="change description 164"
165cat > tmp << 'end'
166brief_description = "The first change (modified)";
167cause = internal_enhancement;
168end
169if test $? -ne 0 ; then no_result; fi
170
171aegis -ca 1 -f tmp -p $AEGIS_PROJECT > log 2>&1
172if test $? -ne 0 ; then cat log; no_result; fi
173
174activity="check description 174"
175aegis -ca -l 1 -p example -unf > example.changes 2>log
176if test $? -ne 0; then cat log; no_result; fi
177
178aegis -ca -l 1 -p example2 -unf > example2.changes 2>log
179if test $? -ne 0; then cat log; no_result; fi
180
181cat > ok <<EOF
1821c1
183< brief_description = "The first change (modified)";
184---
185> brief_description = "The first change";
186EOF
187if test $? -ne 0; then no_result; fi
188
189diff example.changes example2.changes > difference
190if test $? -ne 1; then no_result; fi
191
192diff ok difference
193if test $? -ne 0; then fail; fi
194
195#
196# Only definite negatives are possible.
197# The functionality exercised by this test appears to work,
198# no other guarantees are made.
199#
200pass
201