1#!/bin/sh
2#
3# aegis - The "aegis" program.
4# Copyright (C) 2008, 2010 Walter Franzini
5# Copyright (C) 2012 Peter Miller
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 (at
10# 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 GNU
15# General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License along
18# with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20
21TEST_SUBJECT="aeipass vs. file's UUIDs"
22
23# load up standard prelude and test functions
24. test_funcs
25
26check_it()
27{
28    sed -e "s|$work|...|g" \
29        -e 's|= [0-9][0-9]*; /.*|= TIME;|' \
30        -e "s/\"$USER\"/\"USER\"/g" \
31        -e 's/19[0-9][0-9]/YYYY/' \
32        -e 's/20[0-9][0-9]/YYYY/' \
33        -e 's/node = ".*"/node = "NODE"/' \
34        -e 's/crypto = ".*"/crypto = "GUNK"/' \
35        < $2 > $work/sed.out
36    if test $? -ne 0; then no_result; fi
37    diff -b $1 $work/sed.out
38    if test $? -ne 0; then fail; fi
39}
40
41
42#
43# make a new project
44#
45activity="new project 45"
46aegis -newpro foo -version "" -dir $work/proj -lib $work/lib
47if test $? -ne 0 ; then fail; fi
48
49AEGIS_PROJECT=foo
50export AEGIS_PROJECT
51
52#
53# change project attributes
54#
55activity="project attributes 55"
56cat > atts << 'fubar'
57description = "The \"foo\" program.";
58developer_may_review = true;
59developer_may_integrate = true;
60reviewer_may_integrate = true;
61developers_may_create_changes = true;
62umask = 022;
63default_test_exemption = true;
64default_test_regression_exemption = true;
65minimum_change_number = 10;
66reuse_change_numbers = true;
67minimum_branch_number = 1;
68skip_unlucky = false;
69compress_database = false;
70develop_end_action = goto_awaiting_integration;
71protect_development_directory = false;
72fubar
73test $? -eq 0 || no_result
74
75aegis -proatt -f atts -proj foo -lib $work/lib
76test $? -eq 0 || no_result
77
78activity="new developer 78"
79aegis -newdev $USER
80test $? -eq 0 || no_result
81aegis -new-reviewer $USER
82test $? -eq 0 || no_result
83aegis -new-integrator $USER
84test $? -eq 0 || no_result
85
86#
87# create a new change
88#
89activity="new change 89"
90cat > cattr << 'end'
91brief_description = "First change.";
92cause = internal_enhancement;
93end
94test $? -eq 0 || no_result
95aegis -new_change 1 -f cattr -project $AEGIS_PROJECT
96test $? -eq 0 || no_result
97
98activity="develop begin 98"
99aegis -dev-begin 1 -dir $work/dd
100test $? -eq 0 || no_result
101
102#
103# add a new files to the change
104#
105activity="new file 105"
106aegis -new-file $work/dd/aegis.conf
107test $? -eq 0 || no_result
108
109cat > $work/dd/aegis.conf << 'fubar'
110build_command = "exit 0";
111diff_command =
112    "set +e;"
113    "diff -a ${quote $original} ${quote $input}"
114    " > ${quote $output};"
115    "test $? -le 1";
116merge_command = "set +e; "
117    "merge -p -L baseline -L Historical -L C$c "
118    "${quote $mostrecent} ${quote $original} ${quote $input} "
119    "> ${quote $output}; "
120    "test $? -le 1";
121history_get_command = "aesvt -check-out -edit ${quote $edit} "
122    "-history ${quote $history} -f ${quote $output}";
123history_put_command = "aesvt -check-in -history ${quote $history} "
124    "-f ${quote $input}";
125history_query_command = "aesvt -query -history ${quote $history}";
126history_content_limitation = binary_capable;
127fubar
128test $? -eq 0 || no_result
129
130
131#
132# finish development of the change
133#
134activity="finish dev 134"
135aefinish 1 > LOG 2>&1
136if test $? -ne 0; then cat LOG; no_result; fi
137
138#
139# integrate the change
140#
141activity="finis int 141"
142aefinish 1 > LOG 2>&1
143if test $? -ne 0; then cat LOG; no_result; fi
144
145# --------------------------------------------------------------------------
146
147#
148# we create a branch, because the bug is about branches
149#
150aegis -p foo -nbr 2 -v > LOG 2>&1
151if test $? -ne 0; then cat LOG; no_result; fi
152
153AEGIS_PROJECT=foo.2
154export AEGIS_PROJECT
155
156#
157# create a new change
158#
159activity="new change 159"
160cat > cattr << 'end'
161brief_description = "First change.";
162cause = internal_enhancement;
163end
164test $? -eq 0 || no_result
165aegis -new_change 1 -f cattr -project $AEGIS_PROJECT
166test $? -eq 0 || no_result
167
168activity="develop begin 168"
169aegis -dev-begin 1 -dir $work/dd
170test $? -eq 0 || no_result
171
172#
173# add a new files to the change
174#
175activity="new file 175"
176aegis -new-file $work/dd/barney \
177    -uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccdddddead
178test $? -eq 0 || no_result
179
180cat > $work/dd/barney <<EOF
181Hi, I'm Barney!
182EOF
183test $? -eq 0 || no_result
184
185activity="set the change UUID 185"
186aegis -change-attr -uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddd001 > LOG 2>&1
187if test $? -ne 0; then cat LOG; no_result; fi
188
189activity="finish the change 189"
190aefinish 1 > LOG 2>&1
191if test $? -ne 0; then cat LOG; no_result; fi
192
193activity="integrate the change 193"
194aefinish 1 > LOG 2>&1
195if test $? -ne 0; then cat LOG; no_result; fi
196
197
198# --------------------------------------------------------------------------
199#
200# The second branch
201#
202# --------------------------------------------------------------------------00
203aegis -p foo -nbr 3 -v > LOG 2>&1
204if test $? -ne 0; then cat LOG; no_result; fi
205
206AEGIS_PROJECT=foo.3
207export AEGIS_PROJECT
208
209#
210# create a new change
211#
212activity="new change 212"
213cat > cattr << 'end'
214brief_description = "First change.";
215cause = internal_enhancement;
216end
217test $? -eq 0 || no_result
218aegis -new_change 1 -f cattr -project $AEGIS_PROJECT
219test $? -eq 0 || no_result
220
221activity="develop begin 221"
222aegis -dev-begin 1 -dir $work/dd
223test $? -eq 0 || no_result
224
225#
226# add a new files to the change
227#
228activity="new file 228"
229aegis -new-file $work/dd/barney
230test $? -eq 0 || no_result
231
232cat > $work/dd/barney <<EOF
233Hi, I'm not Barney!
234EOF
235test $? -eq 0 || no_result
236
237activity="set the change UUID 237"
238aegis -change-attr -uuid aaaaaaaa-bbbb-4bbb-8ccc-ccccddddd002 > LOG 2>&1
239if test $? -ne 0; then cat LOG; no_result; fi
240
241activity="develop end the change 241"
242aefinish 1 > LOG 2>&1
243if test $? -ne 0; then cat LOG; no_result; fi
244
245activity="integrate the change 245"
246aefinish 1 > LOG 2>&1
247if test $? -ne 0; then cat LOG; no_result; fi
248
249activity="check fstate 249"
250cat > ok <<EOF
251src =
252[
253    {
254        file_name = "barney";
255        uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccdddddead";
256        action = create;
257        edit =
258        {
259            revision = "2";
260            encoding = none;
261            uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddd002";
262        };
263        edit_origin =
264        {
265            revision = "2";
266            encoding = none;
267            uuid = "aaaaaaaa-bbbb-4bbb-8ccc-ccccddddd002";
268        };
269        usage = source;
270        file_fp =
271        {
272            youngest = TIME;
273            oldest = TIME;
274            crypto = "GUNK";
275        };
276        diff_file_fp =
277        {
278            youngest = TIME;
279            oldest = TIME;
280            crypto = "GUNK";
281        };
282    },
283];
284EOF
285test $? -eq 0 || no_result
286
287check_it ok $work/proj/info/change/0/003.fs
288
289#
290# Only definite negatives are possible.
291# The functionality exercised by this test appears to work,
292# no other guarantees are made.
293#
294pass
295# vim: set ts=8 sw=4 et :
296