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="aefinish vs. non-existent home"
21
22# load up standard prelude and test functions
23. test_funcs
24
25HOME=$work/private/notexisting
26export HOME
27
28mkdir $work/private > log 2>&1
29if test $? -ne 0; then cat log; no_result; fi
30
31chmod 0000 $work/private > log 2>&1
32if test $? -ne 0; then cat log; no_result; fi
33
34#
35# test the aeipass functionality
36#
37workproj=$work/proj
38workchan=$work/chan
39
40AEGIS_PROJECT=example ; export AEGIS_PROJECT
41
42#
43# make a new project
44#
45activity="new project 39"
46aegis -npr $AEGIS_PROJECT -vers "" -dir $workproj > log 2>&1
47if test $? -ne 0 ; then cat log; no_result; fi
48
49#
50# change project attributes
51#
52activity="project attributes 46"
53cat > tmp << 'end'
54description = "A bogus project created to test the aefinish functionality.";
55developer_may_review = true;
56developer_may_integrate = true;
57reviewer_may_integrate = true;
58default_test_exemption = true;
59develop_end_action = goto_awaiting_integration;
60end
61if test $? -ne 0 ; then no_result; fi
62aegis -pa -f tmp > log 2>&1
63if test $? -ne 0 ; then cat log; no_result; fi
64
65#
66# add the staff
67#
68activity="staff 62"
69aegis -nd $USER > log 2>&1
70if test $? -ne 0 ; then cat log; no_result; fi
71aegis -nrv $USER > log 2>&1
72if test $? -ne 0 ; then cat log; no_result; fi
73aegis -ni $USER > log 2>&1
74if test $? -ne 0 ; then cat log; no_result; fi
75
76#
77# create a new change
78#
79activity="new change 73"
80cat > tmp << 'end'
81brief_description = "The first change";
82cause = internal_bug;
83end
84if test $? -ne 0 ; then no_result; fi
85aegis -nc 1 -f tmp -p $AEGIS_PROJECT > log 2>&1
86if test $? -ne 0 ; then cat log; no_result; fi
87
88#
89# begin development of a change
90#
91aegis -db 1 -dir $workchan > log 2>&1
92if test $? -ne 0 ; then cat log; no_result; fi
93
94#
95# add a new files to the change
96#
97activity="new files 91"
98aegis -nf  $workchan/bogus1 -nl > log 2>&1
99if test $? -ne 0 ; then cat log; no_result; fi
100aegis -nf  $workchan/aegis.conf -nl > log 2>&1
101if test $? -ne 0 ; then cat log; no_result; fi
102
103cat > $workchan/bogus1 << 'end'
104OLD CONTENT
105bogus1, line 1
106bogus1, line 2
107end
108if test $? -ne 0 ; then no_result; fi
109
110cat > $workchan/aegis.conf << 'end'
111build_command = "exit 0";
112link_integration_directory = true;
113
114history_get_command = "aesvt -check-out -edit ${quote $edit} "
115    "-history ${quote $history} -f ${quote $output}";
116history_put_command = "aesvt -check-in -history ${quote $history} "
117    "-f ${quote $input}";
118history_query_command = "aesvt -query -history ${quote $history}";
119history_content_limitation = binary_capable;
120
121diff_command = "set +e; $diff $orig $i > $out; test $$? -le 1";
122merge_command = "(diff3 -e $i $orig $mr | sed -e '/^w$$/d' -e '/^q$$/d'; \
123	echo '1,$$p' ) | ed - $i > $out";
124patch_diff_command = "set +e; $diff -C0 -L $index -L $index $orig $i > $out; \
125test $$? -le 1";
126end
127if test $? -ne 0 ; then no_result; fi
128
129#
130# build the change
131#
132activity="finish the change 126"
133aefinish -v > log 2>&1
134if test $? -ne 0 ; then cat log; no_result; fi
135
136#
137# start integrating
138#
139activity="integrate begin 133"
140aegis -ib 1 > log 2>&1
141if test $? -ne 0 ; then cat log; no_result; fi
142
143#
144# finish integration
145#
146activity="integrate the change 140"
147aefinish -c 1 > log 2>&1
148if test $? -ne 0 ; then cat log; fail; fi
149
150#
151# Only definite negatives are possible.
152# The functionality exercised by this test appears to work,
153# no other guarantees are made.
154#
155pass
156