1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 2002, 2004-2008, 2012 Peter Miller 5# Copyright (C) 2008 Walter Franzini 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 10# (at 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 15# GNU General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License 18# along with this program. If not, see 19# <http://www.gnu.org/licenses/>. 20# 21 22unset AEGIS_PROJECT 23unset AEGIS_CHANGE 24unset AEGIS_PATH 25unset AEGIS 26unset LINES 27unset COLS 28umask 022 29 30USER=${USER:-${LOGNAME:-`whoami`}} 31 32work=${AEGIS_TMP:-/tmp}/$$ 33 34here=`pwd` 35if test $? -ne 0 ; then exit 2; fi 36 37if test "$1" != "" ; then bin="$here/$1/bin"; else bin="$here/bin"; fi 38 39if test "$EXEC_SEARCH_PATH" != "" 40then 41 tpath= 42 hold="$IFS" 43 IFS=":$IFS" 44 for tpath2 in $EXEC_SEARCH_PATH 45 do 46 tpath=${tpath}${tpath2}/${1-.}/bin: 47 done 48 IFS="$hold" 49 PATH=${tpath}${PATH} 50else 51 PATH=${bin}:${PATH} 52fi 53export PATH 54 55check_it() 56{ 57 sed -e "s|$work|...|g" \ 58 -e 's|= [0-9][0-9]*; /.*|= TIME;|' \ 59 -e "s/\"$USER\"/\"USER\"/g" \ 60 -e 's/19[0-9][0-9]/YYYY/' \ 61 -e 's/20[0-9][0-9]/YYYY/' \ 62 -e 's/node = ".*"/node = "NODE"/' \ 63 -e 's/crypto = ".*"/crypto = "GUNK"/' \ 64 -e 's/uuid = ".*"/uuid = "UUID"/' \ 65 < $2 > $work/sed.out 66 if test $? -ne 0; then no_result; fi 67 diff -b $1 $work/sed.out 68 if test $? -ne 0; then fail; fi 69} 70 71no_result() 72{ 73 set +x 74 echo "NO RESULT for test of aemtu functionality ($activity)" 1>&2 75 cd $here 76 find $work -type d -user $USER -exec chmod u+w {} \; 77 rm -rf $work 78 exit 2 79} 80fail() 81{ 82 set +x 83 echo "FAILED test of aemtu functionality ($activity)" 1>&2 84 cd $here 85 find $work -type d -user $USER -exec chmod u+w {} \; 86 rm -rf $work 87 exit 1 88} 89pass() 90{ 91 set +x 92 echo PASSED 1>&2 93 cd $here 94 find $work -type d -user $USER -exec chmod u+w {} \; 95 rm -rf $work 96 exit 0 97} 98trap "no_result" 1 2 3 15 99 100# 101# some variable to make things earier to read 102# 103PAGER=cat 104export PAGER 105 106AEGIS_FLAGS="delete_file_preference = no_keep; \ 107 lock_wait_preference = always; \ 108 diff_preference = automatic_merge; \ 109 pager_preference = never; \ 110 persevere_preference = all; \ 111 log_file_preference = never;" 112export AEGIS_FLAGS 113AEGIS_THROTTLE=-1 114export AEGIS_THROTTLE 115 116worklib=$work/lib 117workproj=$work/foo.proj 118workchan=$work/foo.chan 119tmp=$work/tmp 120AEGIS_PATH=$worklib ; export AEGIS_PATH 121AEGIS_PROJECT=foo ; export AEGIS_PROJECT 122 123# 124# make the directories 125# 126activity="working directory 119" 127mkdir $work $work/lib 128if test $? -ne 0 ; then no_result; fi 129chmod 777 $work/lib 130if test $? -ne 0 ; then no_result; fi 131cd $work 132if test $? -ne 0 ; then no_result; fi 133 134# 135# use the built-in error messages 136# 137AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 138export AEGIS_MESSAGE_LIBRARY 139unset LANG 140unset LANGUAGE 141 142# 143# make a new project 144# 145activity="new project 138" 146$bin/aegis -npr foo -vers "" -dir $workproj > log 2>&1 147if test $? -ne 0 ; then cat log; no_result; fi 148 149# 150# change project attributes 151# 152activity="project attributes 145" 153cat > $tmp << 'end' 154description = "A bogus project created to test the aemtu functionality."; 155developer_may_review = true; 156developer_may_integrate = true; 157reviewer_may_integrate = true; 158default_test_exemption = true; 159end 160if test $? -ne 0 ; then no_result; fi 161$bin/aegis -pa -f $tmp > log 2>&1 162if test $? -ne 0 ; then cat log; no_result; fi 163 164# 165# add the staff 166# 167activity="staff 160" 168$bin/aegis -nd $USER > log 2>&1 169if test $? -ne 0 ; then cat log; no_result; fi 170$bin/aegis -nrv $USER > log 2>&1 171if test $? -ne 0 ; then cat log; no_result; fi 172$bin/aegis -ni $USER > log 2>&1 173if test $? -ne 0 ; then cat log; no_result; fi 174 175# -------------------------------------------------------------------------- 176 177# 178# create a new change 179# 180activity="new change 173" 181cat > $tmp << 'end' 182brief_description = "The first change"; 183cause = internal_bug; 184end 185if test $? -ne 0 ; then no_result; fi 186$bin/aegis -nc 1 -f $tmp -p foo > log 2>&1 187if test $? -ne 0 ; then cat log; no_result; fi 188 189# 190# begin development of a change 191# 192$bin/aegis -db 1 -dir $workchan > log 2>&1 193if test $? -ne 0 ; then cat log; no_result; fi 194 195# 196# add a new files to the change 197# 198activity="new file 191" 199$bin/aegis -nf $workchan/aegis.conf $workchan/bogus -nl > log 2>&1 200if test $? -ne 0 ; then cat log; no_result; fi 201 202cat > $workchan/bogus << 'end' 203the trunk version 204end 205if test $? -ne 0 ; then no_result; fi 206 207cat > $workchan/aegis.conf << 'end' 208build_command = "exit 0"; 209link_integration_directory = true; 210 211history_get_command = "aesvt -check-out -edit ${quote $edit} " 212 "-history ${quote $history} -f ${quote $output}"; 213history_put_command = "aesvt -check-in -history ${quote $history} " 214 "-f ${quote $input}"; 215history_query_command = "aesvt -query -history ${quote $history}"; 216history_content_limitation = binary_capable; 217 218diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 219diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 220 echo '1,$$p' ) | ed - $mr > $out"; 221patch_diff_command = "set +e; diff -C0 -L $index -L $index $orig $i > $out; \ 222test $$? -le 1"; 223end 224if test $? -ne 0 ; then no_result; fi 225 226# 227# build the change 228# 229activity="build 222" 230$bin/aegis -build -nl -v > log 2>&1 231if test $? -ne 0 ; then cat log; fail; fi 232 233# 234# difference the change 235# 236activity="diff 229" 237$bin/aegis -diff > log 2>&1 238if test $? -ne 0 ; then cat log; no_result; fi 239 240# 241# finish development of the change 242# 243activity="develop end 236" 244$bin/aegis -de > log 2>&1 245if test $? -ne 0 ; then cat log; fail; fi 246 247# 248# pass the review 249# 250activity="review pass 243" 251$bin/aegis -rpass -c 1 > log 2>&1 252if test $? -ne 0 ; then cat log; no_result; fi 253 254# 255# start integrating 256# 257activity="integrate begin 250" 258$bin/aegis -ib 1 > log 2>&1 259if test $? -ne 0 ; then cat log; no_result; fi 260 261# 262# integrate build 263# 264activity="build 257" 265$bin/aegis -b -nl -v > log 2>&1 266if test $? -ne 0 ; then cat log; no_result; fi 267 268# 269# pass the integration 270# 271activity="integrate pass 264" 272$bin/aegis -intpass -nl > log 2>&1 273if test $? -ne 0 ; then cat log; no_result; fi 274 275# -------------------------------------------------------------------------- 276 277# 278# create a branch 279# 280activity="new branch 273" 281$bin/aegis -nbr -p foo 2 > log 2>&1 282if test $? -ne 0 ; then cat log; no_result; fi 283 284AEGIS_PROJECT=foo.2 285export AEGIS_PROJECT 286 287# -------------------------------------------------------------------------- 288 289# 290# create a new change 291# 292activity="new change 285" 293cat > $tmp << 'end' 294brief_description = "The second change"; 295cause = internal_bug; 296end 297if test $? -ne 0 ; then no_result; fi 298$bin/aegis -nc 3 -f $tmp -p foo.2 > log 2>&1 299if test $? -ne 0 ; then cat log; no_result; fi 300 301# 302# begin development of a change 303# 304$bin/aegis -db 3 -dir $workchan > log 2>&1 305if test $? -ne 0 ; then cat log; no_result; fi 306 307# 308# add files to the change 309# 310activity="copy file 303" 311$bin/aegis -cp $workchan/bogus -nl > log 2>&1 312if test $? -ne 0 ; then cat log; no_result; fi 313 314cat > $workchan/bogus << 'end' 315the branch version 316end 317if test $? -ne 0 ; then no_result; fi 318 319# 320# build the change 321# 322activity="build 315" 323$bin/aegis -build -nl -v > log 2>&1 324if test $? -ne 0 ; then cat log; fail; fi 325 326# 327# difference the change 328# 329activity="diff 322" 330$bin/aegis -diff > log 2>&1 331if test $? -ne 0 ; then cat log; no_result; fi 332 333# 334# finish development of the change 335# 336activity="develop end 329" 337$bin/aegis -de > log 2>&1 338if test $? -ne 0 ; then cat log; fail; fi 339 340# 341# pass the review 342# 343activity="review pass 336" 344$bin/aegis -rpass -c 3 > log 2>&1 345if test $? -ne 0 ; then cat log; no_result; fi 346 347# 348# start integrating 349# 350activity="integrate begin 343" 351$bin/aegis -ib 3 > log 2>&1 352if test $? -ne 0 ; then cat log; no_result; fi 353 354# 355# integrate build 356# 357activity="build 350" 358$bin/aegis -b -nl -v > log 2>&1 359if test $? -ne 0 ; then cat log; no_result; fi 360 361# 362# integrate diff 363# 364activity="diff 357" 365$bin/aegis -diff -nl -v > log 2>&1 366if test $? -ne 0 ; then cat log; no_result; fi 367 368# 369# pass the integration 370# 371activity="integrate pass 364" 372$bin/aegis -intpass -nl > log 2>&1 373if test $? -ne 0 ; then cat log; no_result; fi 374 375# -------------------------------------------------------------------------- 376 377# 378# create a new change 379# 380activity="new change 373" 381cat > $tmp << 'end' 382brief_description = "The third change"; 383cause = internal_bug; 384end 385if test $? -ne 0 ; then no_result; fi 386$bin/aegis -nc 4 -f $tmp -p foo.2 > log 2>&1 387if test $? -ne 0 ; then cat log; no_result; fi 388 389# 390# begin development of a change 391# 392$bin/aegis -db 4 -dir $workchan > log 2>&1 393if test $? -ne 0 ; then cat log; no_result; fi 394 395# 396# add files to the change 397# 398activity="make transparent 391" 399$bin/aegis -mt $workchan/bogus -nl > log 2>&1 400if test $? -ne 0 ; then cat log; fail; fi 401 402activity="check file contents 395" 403cat > ok << 'end' 404the trunk version 405end 406if test $? -ne 0 ; then no_result; fi 407 408diff ok $workchan/bogus 409if test $? -ne 0 ; then fail; fi 410 411activity="check change file state 404" 412cat > ok << 'end' 413src = 414[ 415 { 416 file_name = "bogus"; 417 uuid = "UUID"; 418 action = transparent; 419 edit_origin = 420 { 421 revision = "2"; 422 encoding = none; 423 uuid = "UUID"; 424 }; 425 usage = source; 426 }, 427]; 428end 429if test $? -ne 0 ; then no_result; fi 430 431check_it ok $workproj/info/change/0/002.branch/0/004.fs 432 433# 434# now remove it again 435# 436activity="make transparent undo 428" 437$bin/aegis -mtu $workchan/bogus -nl > log 2>&1 438if test $? -ne 0 ; then cat log; fail; fi 439 440activity="check change file state 432" 441cat > ok << 'end' 442src = 443[ 444]; 445end 446if test $? -ne 0 ; then no_result; fi 447 448check_it ok $workproj/info/change/0/002.branch/0/004.fs 449 450# 451# the things tested in this test, worked 452# can't speak for the rest of the code 453# 454pass 455# vim: set ts=8 sw=4 et : 456