1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 2001, 2005-2008 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}/$$ 32 33here=`pwd` 34if test $? -ne 0; then exit 2; fi 35 36if test "$1" != "" ; then bin="$here/$1/bin"; else bin="$here/bin"; fi 37 38if test "$EXEC_SEARCH_PATH" != "" 39then 40 tpath= 41 hold="$IFS" 42 IFS=":$IFS" 43 for tpath2 in $EXEC_SEARCH_PATH 44 do 45 tpath=${tpath}${tpath2}/${1-.}/bin: 46 done 47 IFS="$hold" 48 PATH=${tpath}${PATH} 49else 50 PATH=${bin}:${PATH} 51fi 52export PATH 53 54activity="create working directory 41" 55 56no_result() 57{ 58 set +x 59 echo NO RESULT for test of aed functionality "($activity)" 1>&2 60 cd $here 61 find $work -type d -user $USER -exec chmod u+w {} \; 62 rm -rf $work 63 exit 2 64} 65fail() 66{ 67 set +x 68 echo FAILED test of aed functionality "($activity)" 1>&2 69 cd $here 70 find $work -type d -user $USER -exec chmod u+w {} \; 71 rm -rf $work 72 exit 1 73} 74pass() 75{ 76 set +x 77 echo PASSED 1>&2 78 cd $here 79 find $work -type d -user $USER -exec chmod u+w {} \; 80 rm -rf $work 81 exit 0 82} 83trap "no_result" 1 2 3 15 84 85check_it() 86{ 87 sed -e "s|$work|...|g" \ 88 -e 's|= [0-9][0-9]*; /.*|= TIME;|' \ 89 -e "s/\"$USER\"/\"USER\"/g" \ 90 -e 's/delta[0-9][0-9]*/delta/' \ 91 -e 's/19[0-9][0-9]/YYYY/' \ 92 -e 's/20[0-9][0-9]/YYYY/' \ 93 -e 's/node = ".*"/node = "NODE"/' \ 94 -e 's/crypto = ".*"/crypto = "GUNK"/' \ 95 < $1 > $work/sed.out 96 if test $? -ne 0; then no_result; fi 97 diff $2 $work/sed.out 98 if test $? -ne 0; then fail; fi 99} 100 101# 102# some variable to make things earier to read 103# 104PAGER=cat 105export PAGER 106 107AEGIS_FLAGS="delete_file_preference = no_keep; \ 108 lock_wait_preference = always; \ 109 diff_preference = automatic_merge; \ 110 pager_preference = never; \ 111 persevere_preference = all; \ 112 log_file_preference = never;" 113export AEGIS_FLAGS 114AEGIS_THROTTLE=-1 115export AEGIS_THROTTLE 116 117worklib=$work/lib 118workproj=$work/foo.proj 119workchan=$work/foo.chan 120tmp=$work/tmp 121 122# 123# make the directories 124# 125mkdir $work $work/lib 126if test $? -ne 0 ; then exit 2; fi 127chmod 777 $work/lib 128if test $? -ne 0 ; then exit 2; fi 129cd $work 130if test $? -ne 0 ; then exit 2; fi 131 132AEGIS_PATH=$work/lib 133export AEGIS_PATH 134 135# 136# use the built-in error messages 137# 138AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 139export AEGIS_MESSAGE_LIBRARY 140unset LANG 141unset LANGUAGE 142 143# 144# make a new project 145# 146activity="new project 133" 147$bin/aegis -npr foo -version "" -dir $workproj -lib $worklib 148if test $? -ne 0 ; then no_result; fi 149 150# 151# change project attributes 152# 153activity="project attributes 140" 154cat > $tmp << 'end' 155description = "A bogus project created to test things."; 156developer_may_review = true; 157developer_may_integrate = true; 158reviewer_may_integrate = true; 159minimum_change_number = 1; 160default_test_exemption = true; 161end 162if test $? -ne 0 ; then no_result; fi 163$bin/aegis -proatt -f $tmp -proj foo 164if test $? -ne 0 ; then no_result; fi 165 166# 167# add staff 168# 169activity="staff 156" 170$bin/aegis -newdev $USER -p foo 171if test $? -ne 0 ; then no_result; fi 172$bin/aegis -newrev $USER -p foo 173if test $? -ne 0 ; then no_result; fi 174$bin/aegis -newint $USER -p foo 175if test $? -ne 0 ; then no_result; fi 176 177# 178# Now create the branches 179# 180activity="new branch 167" 181$bin/aegis -nbr -p foo 3 182if test $? -ne 0 ; then no_result; fi 183activity="new branch 170" 184$bin/aegis -nbr -p foo.3 29 185if test $? -ne 0 ; then no_result; fi 186 187AEGIS_PROJECT=foo.3.29 188export AEGIS_PROJECT 189 190# 191# create a new change 192# 193activity="new change 180" 194cat > $tmp << 'end' 195brief_description = "create a file"; 196cause = internal_bug; 197end 198if test $? -ne 0 ; then no_result; fi 199$bin/aegis -new_change 1 -f $tmp -project foo.3.29 200if test $? -ne 0 ; then no_result; fi 201 202# 203# create a second change 204# 205cat > $tmp << 'end' 206brief_description = "move a file"; 207cause = internal_bug; 208end 209$bin/aegis -new_change 2 -f $tmp -project foo.3.29 210if test $? -ne 0 ; then no_result; fi 211 212# 213# begin development of a change 214# check it made the files it should 215# 216activity="develop begin 203" 217$bin/aegis -devbeg 1 -dir $workchan 218if test $? -ne 0 ; then no_result; fi 219 220# 221# add a new files to the change 222# 223activity="new file 210" 224$bin/aegis -new_file $workchan/move_me $workchan/aegis.conf -nl 225if test $? -ne 0 ; then no_result; fi 226 227echo hello > $workchan/move_me 228if test $? -ne 0 ; then no_result; fi 229 230cat > $workchan/aegis.conf << 'end' 231build_command = "exit 0"; 232 233history_get_command = "aesvt -check-out -edit ${quote $edit} " 234 "-history ${quote $history} -f ${quote $output}"; 235history_put_command = "aesvt -check-in -history ${quote $history} " 236 "-f ${quote $input}"; 237history_query_command = "aesvt -query -history ${quote $history}"; 238history_content_limitation = binary_capable; 239 240diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 241 242diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 243 echo '1,$$p' ) | ed - $mr > $out"; 244end 245if test $? -ne 0 ; then no_result; fi 246 247# 248# build the change 249# 250activity="build 239" 251$bin/aegis -build -nl > test.out 2>&1 252if test $? -ne 0 ; then cat test.out;no_result; fi 253 254# 255# difference the change 256# 257activity="diff 246" 258$bin/aegis -diff > test.out 2>&1 259if test $? -ne 0 ; then cat test.out; no_result; fi 260 261# 262# finish development of the change 263# 264activity="develop end 253" 265$bin/aegis -dev_end 266if test $? -ne 0 ; then no_result; fi 267 268# 269# pass the review 270# 271activity="review pass 260" 272$bin/aegis -review_pass -chan 1 273if test $? -ne 0 ; then no_result; fi 274 275# 276# start integrating 277# 278activity="integrate begin 267" 279$bin/aegis -intbeg 1 > test.out 2>&1 280if test $? -ne 0 ; then cat test.out; no_result; fi 281 282# 283# integrate build 284# 285activity="integration build 274" 286$bin/aegis -build -nl > test.out 2>&1 287if test $? -ne 0 ; then cat test.out; no_result; fi 288activity="integration diff 277" 289$bin/aegis -diff -nl > test.out 2>&1 290if test $? -ne 0 ; then cat test.out; no_result; fi 291 292# 293# pass the integration 294# 295activity="integrate pass 284" 296$bin/aegis -intpass -nl > test.out 2>&1 297if test $? -ne 0 ; then cat test.out; no_result; fi 298 299# 300# start work on change 2 301# 302activity="develop begin 291" 303$bin/aegis -devbeg 2 -dir $workchan 304if test $? -ne 0 ; then no_result; fi 305 306# 307# move a file 308# 309activity="move file 298" 310$bin/aegis -mv $workchan/move_me $workchan/remove_me -nl 311if test $? -ne 0 ; then no_result; fi 312 313# 314# build the change 315# diff the change 316# 317activity="build 306" 318$bin/aegis -b -nl > test.out 2>&1 319if test $? -ne 0 ; then cat test.out; no_result; fi 320activity="diff 309" 321$bin/aegis -diff -nl > test.out 2>&1 322if test $? -ne 0 ; then cat test.out; no_result; fi 323 324# 325# end development 326# review pass 327# start integrating 328# build the integration 329# pass the integration 330# 331activity="devlop end 320" 332$bin/aegis -devend 333if test $? -ne 0 ; then no_result; fi 334activity="review pass 323" 335$bin/aegis -revpass -c 2 336if test $? -ne 0 ; then no_result; fi 337activity="integrate begin 326" 338$bin/aegis -intbeg -c 2 > test.out 2>&1 339if test $? -ne 0 ; then cat test.out; no_result; fi 340activity="integrate build 329" 341$bin/aegis -b -nl > test.out 2>&1 342if test $? -ne 0 ; then cat test.out; no_result; fi 343activity="integrate diff 332" 344$bin/aegis -diff -nl > test.out 2>&1 345if test $? -ne 0 ; then cat test.out; no_result; fi 346activity="integrate pass 335" 347$bin/aegis -intpass -nl > test.out 2>&1 348if test $? -ne 0 ; then cat test.out; no_result; fi 349 350AEGIS_PROJECT=foo.3 351export AEGIS_PROJECT 352 353# 354# end the first branch 355# 356activity="devlop end 345" 357$bin/aegis -devend 29 358 359if test $? -ne 0 ; then no_result; fi 360activity="review pass 349" 361$bin/aegis -revpass -c 29 362if test $? -ne 0 ; then no_result; fi 363activity="integrate begin 352" 364$bin/aegis -intbeg -c 29 > test.out 2>&1 365if test $? -ne 0 ; then cat test.out; no_result; fi 366activity="integrate build 355" 367$bin/aegis -b -nl > test.out 2>&1 368if test $? -ne 0 ; then cat test.out; no_result; fi 369activity="integrate pass 358" 370activity="integrate diff 359" 371$bin/aegis -diff -nl > test.out 2>&1 372if test $? -ne 0 ; then cat test.out; no_result; fi 373activity="integrate pass 362" 374$bin/aegis -intpass -nl > test.out 2>&1 375if test $? -ne 0 ; then cat test.out; no_result; fi 376 377AEGIS_PROJECT=foo 378export AEGIS_PROJECT 379 380# 381# end the second (grandparent) branch 382# 383activity="devlop end 372" 384$bin/aegis -devend 3 385 386if test $? -ne 0 ; then no_result; fi 387activity="review pass 376" 388$bin/aegis -revpass -c 3 389if test $? -ne 0 ; then no_result; fi 390activity="integrate begin 379" 391$bin/aegis -intbeg -c 3 > test.out 2>&1 392if test $? -ne 0 ; then cat test.out; no_result; fi 393activity="integrate build 382" 394$bin/aegis -b -nl > test.out 2>&1 395if test $? -ne 0 ; then cat test.out; no_result; fi 396activity="integrate diff 385" 397$bin/aegis -diff -nl > test.out 2>&1 398if test $? -ne 0 ; then cat test.out; fail; fi 399activity="integrate pass 388" 400$bin/aegis -intpass -nl > test.out 2>&1 401if test $? -ne 0 ; then cat test.out; no_result; fi 402 403# 404# the things tested in this test, worked 405# 406pass 407