1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 2006-2008 Peter Miller 5# Copyright (C) 2002 John Darrington 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 26umask 022 27 28LINES=24 29export LINES 30COLS=80 31export COLS 32 33USER=${USER:-${LOGNAME:-`whoami`}} 34 35work=${AEGIS_TMP:-/tmp}/$$ 36PAGER=cat 37export PAGER 38AEGIS_FLAGS="delete_file_preference = no_keep; \ 39 lock_wait_preference = always; \ 40 diff_preference = automatic_merge; \ 41 pager_preference = never; \ 42 persevere_preference = all; \ 43 log_file_preference = never;" 44export AEGIS_FLAGS 45AEGIS_THROTTLE=-1 46export AEGIS_THROTTLE 47 48here=`pwd` 49if test $? -ne 0 ; then exit 2; fi 50 51bin=$here/${1-.}/bin 52 53if test "$EXEC_SEARCH_PATH" != "" 54then 55 tpath= 56 hold="$IFS" 57 IFS=":$IFS" 58 for tpath2 in $EXEC_SEARCH_PATH 59 do 60 tpath=${tpath}${tpath2}/${1-.}/bin: 61 done 62 IFS="$hold" 63 PATH=${tpath}${PATH} 64else 65 PATH=${bin}:${PATH} 66fi 67export PATH 68 69pass() 70{ 71 set +x 72 echo PASSED 1>&2 73 cd $here 74 find $work -type d -user $USER -exec chmod u+w {} \; 75 rm -rf $work 76 exit 0 77} 78fail() 79{ 80 set +x 81 echo 'FAILED test of the history_label_command functionality' 1>&2 82 echo $activity 83 cd $here 84 find $work -type d -user $USER -exec chmod u+w {} \; 85 rm -rf $work 86 exit 1 87} 88no_result() 89{ 90 set +x 91 92 echo 'NO RESULT when testing the history_label_command functionality' 1>&2 93 echo $activity 94 cd $here 95 find $work -type d -user $USER -exec chmod u+w {} \; 96 rm -rf $work 97 exit 2 98} 99trap \"no_result\" 1 2 3 15 100 101worklib=$work/lib 102workproj=$work/foo.proj 103workchan=$work/foo.chan 104tmp=$work/tmp 105AEGIS_PATH=$worklib ; export AEGIS_PATH 106AEGIS_PROJECT=foo ; export AEGIS_PROJECT 107 108mkdir $work $work/lib 109if test $? -ne 0 ; then no_result; fi 110chmod 777 $work/lib 111if test $? -ne 0 ; then no_result; fi 112cd $work 113if test $? -ne 0 ; then no_result; fi 114 115# 116# use the built-in error messages 117# 118AEGIS_MESSAGE_LIBRARY=$work/no-such-dir 119export AEGIS_MESSAGE_LIBRARY 120unset LANG 121unset LANGUAGE 122 123# 124# make a new project 125# 126activity="new project 111" 127$bin/aegis -npr foo -vers "" -dir $workproj > log 2>&1 128if test $? -ne 0 ; then cat log; no_result; fi 129 130# 131# change project attributes 132# 133activity="project attributes 118" 134cat > $tmp << 'end' 135description = "A bogus project created to test the label_history \ 136functionality."; 137developer_may_review = true; 138developer_may_integrate = true; 139reviewer_may_integrate = true; 140end 141if test $? -ne 0 ; then no_result; fi 142$bin/aegis -pa -f $tmp > log 2>&1 143if test $? -ne 0 ; then cat log; no_result; fi 144 145# 146# create a new change 147# 148activity="new change 133" 149cat > $tmp << 'end' 150brief_description = "The first change"; 151cause = internal_bug; 152end 153if test $? -ne 0 ; then no_result; fi 154$bin/aegis -nc 1 -f $tmp -p foo > log 2>&1 155if test $? -ne 0 ; then cat log; no_result; fi 156 157# 158# create a second change 159# 160activity="new change 145" 161cat > $tmp << 'end' 162brief_description = "The second change"; 163cause = internal_bug; 164test_exempt = true; 165test_baseline_exempt = true; 166end 167if test $? -ne 0 ; then no_result; fi 168$bin/aegis -nc 2 -f $tmp -p foo > log 2>&1 169if test $? -ne 0 ; then cat log; no_result; fi 170 171# 172# add the staff 173# 174activity="staff 159" 175$bin/aegis -nd $USER > log 2>&1 176if test $? -ne 0 ; then cat log; no_result; fi 177$bin/aegis -nrv $USER > log 2>&1 178if test $? -ne 0 ; then cat log; no_result; fi 179$bin/aegis -ni $USER > log 2>&1 180if test $? -ne 0 ; then cat log; no_result; fi 181 182# 183# begin development of a change 184# 185$bin/aegis -db 1 -dir $workchan > log 2>&1 186if test $? -ne 0 ; then cat log; no_result; fi 187 188# 189# add a new files to the change 190# 191activity="new file 176" 192$bin/aegis -nf $workchan/main.c $workchan/test.c $workchan/Makefile \ 193 $workchan/aegis.conf -nl > log 2>&1 194if test $? -ne 0 ; then cat log; no_result; fi 195cat > $workchan/main.c << 'end' 196int main() { test(); exit(0); return 0; } 197end 198if test $? -ne 0 ; then no_result; fi 199cat > $workchan/test.c << 'end' 200void test() { } 201end 202if test $? -ne 0 ; then no_result; fi 203cat > $workchan/Makefile << 'end' 204.c.o: 205 date > $@ 206 207foo: main.o test.o 208 date > $@ 209end 210if test $? -ne 0 ; then no_result; fi 211cat > $workchan/aegis.conf << 'end' 212build_command = "exit 0"; 213link_integration_directory = true; 214 215history_get_command = "aesvt -check-out -edit ${quote $edit} " 216 "-history ${quote $history} -f ${quote $output}"; 217history_put_command = "aesvt -check-in -history ${quote $history} " 218 "-f ${quote $input}"; 219history_query_command = "aesvt -query -history ${quote $history}"; 220history_content_limitation = binary_capable; 221 222history_label_command = 223/* "rcs -n${SUBST \\\\. _ ${Label}}:${Edit} ${History}"; */ 224 "echo Labeling ${History} edit ${Edit} with t${SUBST \\\\. _ ${Label}}"; 225 226diff_command = "set +e; diff $orig $i > $out; test $$? -le 1"; 227diff3_command = "(diff3 -e $mr $orig $i | sed -e '/^w$$/d' -e '/^q$$/d'; \ 228 echo '1,$$p' ) | ed - $mr > $out"; 229end 230if test $? -ne 0 ; then no_result; fi 231 232# 233# create a new test 234# 235activity="new test 222" 236$bin/aegis -nt > log 2>&1 237if test $? -ne 0 ; then cat log; fail; fi 238 239cat > $workchan/test/00/t0001a.sh << 'end' 240#!/bin/sh 241exit 0 242end 243if test $? -ne 0 ; then no_result; fi 244 245# 246# build the change 247# 248activity="build 235" 249$bin/aegis -build -nl -v > log 2>&1 250if test $? -ne 0 ; then cat log; fail; fi 251 252# 253# difference the change 254# 255activity="diff 242" 256$bin/aegis -diff > log 2>&1 257if test $? -ne 0 ; then cat log; no_result; fi 258 259# 260# test the change 261# 262activity="test 249" 263$bin/aegis -t -v > log 2>&1 264if test $? -ne 0 ; then cat log; no_result; fi 265 266# 267# finish development of the change 268# 269activity="develop end 256" 270$bin/aegis -de > log 2>&1 271if test $? -ne 0 ; then cat log; fail; fi 272 273# 274# pass the review 275# 276activity="review pass 263" 277$bin/aegis -rpass -c 1 > log 2>&1 278if test $? -ne 0 ; then cat log; no_result; fi 279 280# 281# start integrating 282# 283activity="integrate begin 270" 284$bin/aegis -ib 1 > log 2>&1 285if test $? -ne 0 ; then cat log; no_result; fi 286 287# 288# integrate build 289# 290activity="build 277" 291$bin/aegis -b -nl -v > log 2>&1 292if test $? -ne 0 ; then cat log; no_result; fi 293 294# 295# integrate test 296# 297activity="test 284" 298$bin/aegis -t -nl -v > log 2>&1 299if test $? -ne 0 ; then cat log; no_result; fi 300 301# 302# pass the integration 303# 304activity="integrate pass 291" 305$bin/aegis -intpass -nl > log 2>&1 306if test $? -ne 0 ; then cat log; no_result; fi 307 308grep "Labeling .* edit 1 with t_D001" log > /dev/null 309if test $? -ne 0 ; then cat log; fail; fi 310 311# 312# start work on change 2 313# 314activity="develop begin 301" 315$bin/aegis -db -c 2 -dir $workchan > log 2>&1 316if test $? -ne 0 ; then cat log; fail; fi 317 318# 319# copy a file into the change 320# 321activity="copy file 308" 322$bin/aegis -cp $workchan/main.c -nl > log 2>&1 323if test $? -ne 0 ; then cat log; fail; fi 324 325# 326# change the file 327# 328cat > $workchan/main.c << 'end' 329#include <stdio.h> 330 331int 332main(argc, argv) 333 int argc; 334 char **argv; 335{ 336 if (argc != 1) 337 { 338 fprintf(stderr, "usage: %s\n", argv[0]); 339 exit(1); 340 } 341 test(); 342 exit(0); 343 return 0; 344} 345end 346if test $? -ne 0 ; then no_result; fi 347 348 349# 350# build the change 351# 352activity="build 339" 353$bin/aegis -build -nl -v > log 2>&1 354if test $? -ne 0 ; then cat log; fail; fi 355 356# 357# difference the change 358# 359activity="diff 346" 360$bin/aegis -diff > log 2>&1 361if test $? -ne 0 ; then cat log; no_result; fi 362 363# 364# finish development of the change 365# 366activity="develop end 353" 367$bin/aegis -de > log 2>&1 368if test $? -ne 0 ; then cat log; fail; fi 369 370# 371# pass the review 372# 373activity="review pass 360" 374$bin/aegis -rpass -c 2 > log 2>&1 375if test $? -ne 0 ; then cat log; no_result; fi 376 377# 378# start integrating 379# 380activity="integrate begin 367" 381$bin/aegis -ib 2 > log 2>&1 382if test $? -ne 0 ; then cat log; no_result; fi 383 384# 385# integrate build 386# 387activity="build 374" 388$bin/aegis -b -nl -v > log 2>&1 389if test $? -ne 0 ; then cat log; no_result; fi 390 391 392# 393# pass the integration 394# 395activity="integrate pass 382" 396$bin/aegis -intpass -nl > log 2>&1 397if test $? -ne 0 ; then cat log; no_result; fi 398 399grep "Labeling .* edit 1 with t_D002" log > /dev/null 400if test $? -ne 0 ; then cat log; fail; fi 401grep "Labeling .* edit 2 with t_D002" log > /dev/null 402if test $? -ne 0 ; then cat log; fail; fi 403 404# 405# label the HEAD of the history 406# 407activity="label history head 394" 408$bin/aegis -delta_name XyZZY > log 2>&1 409if test $? -ne 0 ; then cat log; no_result; fi 410 411grep "Labeling .* edit 1 with tXyZZY" log > /dev/null 412if test $? -ne 0 ; then cat log; fail; fi 413grep "Labeling .* edit 2 with tXyZZY" log > /dev/null 414if test $? -ne 0 ; then cat log; fail; fi 415 416# 417# label Delta 1 of the history 418# 419activity="label history delta 1 406" 420$bin/aegis -delta_name 1 Foobar > log 2>&1 421if test $? -ne 0 ; then cat log; no_result; fi 422 423grep "Labeling .* edit 1 with tFoobar" log > /dev/null 424if test $? -ne 0 ; then cat log; fail; fi 425 426# 427# The things tested by this test passed. 428# No other assertions are made. 429# 430pass 431