head	1.1;
access;
symbols
	HWGRCSP7F:1.1
	C_15:1.1
	HWGRCSP6F:1.1
	HWGRCSP5F:1.1
	HWGRCSp4:1.1
	HWGRCSp3:1.1
	HWGRCS_Fish:1.1
	HWGRCS:1.1;
locks; strict;
comment	@# @;


1.1
date	93.01.18.13.55.01;	author heinz;	state Exp;
branches;
next	;


desc
@Start of the AMIGA port of RCS 5.6. I call it HWGRCS now ;^)
Partial port of the rcstest script for the Amiga.
Anybody volunterring to port the rest?
@


1.1
log
@Initial revision
@
text
@.key option

.BRA {
.KET }


failat 30

Echo "Testing RCS-Installation. Please wait ...*N"

If NOT EXISTS ENV:RCS
MakeDir ENV:RCS
MakeDir ENVARC:RCS
EndIf

; Don't use any suffix
Echo "Please reset ENV:RCS/INIT after use of this script or reboot!*N"
SetEnv RCS/INIT -x

Set RCSfile RCS.RCSfiles/a.c
Set RCSalt RCS.RCSfiles/a.d
Set lockfile RCS.RCSfiles/a._

If {option} EQ -v
    Set q ""
Else
    If {option} gt ""
	Echo "usage: RCSTESTAMIGA [-v]"
	Quit
    Else
	Set q -q
    EndIf
EndIf

If NOT EXISTS RCS_link
    MakeDir RCS.RCSfiles
    Echo >RCS_link RCS.RCSfiles
EndIf

FailAt 6
Delete >NIL: quiet force a.#? $RCSfile $RCSalt $lockfile
Echo >a.11  1.1
Echo >a.3x1 1.1.1.1
Echo >a.12  1.2

FailAt 30
diff >t:t -c a.11 a.3x1
Search >NIL: search "! 1.1.1.1" t:t
If warn
    Echo "warning: diff -c does not work, so diagnostics may be cryptic"
    Set diff "diff -c"
Else
    Set diff "diff"
EndIf


rcs -i -L -ta.11 $q a.c
if not exists $RCSfile
	echo "#rcs -i -L failed; perhaps RCS is not properly installed."
	Quit 1
EndIf

rlog a.c >NIL:
if val $rc gt 0
    echo "#rlog failed on empty RCS file"
    Quit 1
endif

FailAt 1
delete quiet force $RCSfile

xcopy a.11 a.c
ci -ta.11 -mm $q a.c
if not exists $RCSfile
    quit 1
endif

FailAt 30
rcs -L $q a.c
if val $rc gt 0
   echo "#ci+rcs -L failed"
   quit 1
endif

if exists a.c
    echo "#ci did not remove working file"
    quit 1
endif

co $q a.c
if not exists a.c
    echo "#ci did not create working file"
    quit 1
endif
$diff a.11 a.c
if val $rc gt 0
    echo "'#ci' followed by co $l is not a no-op"
    quit 1
endif

co -l $q a.c
if not exists a.c
    echo "#ci did not create working file"
    quit 1
endif
$diff a.11 a.c
if val $rc gt 0
    echo "'#ci' followed by co $l is not a no-op"
    quit 1
endif

xcopy a.12 a.c
ci -mm $q a.c
co $q a.c
$diff a.12 a.c

if val $rc gt 0
    echo "#ci+co failed"
    quit 1
endif

co -r1.1 $q a.c
$diff a.11 a.c
if val $rc gt 0
    echo "#can't retrieve first revision"
    quit 1
endif

delete quiet force a.c
xcopy a.3x1 a.c
ci -r1.1.1 -mm $q a.c
co -r1.1.1.1 $q a.c
$diff a.3x1 a.c
if val $rc gt 0
    echo "#branches failed"
    quit 1
endif

co -l $q a.c
ci -f -mm $q a.c
co -r1.3 $q a.c
$diff a.12 a.c
if val $rc gt 0
    echo "#(co -l; ci -f) failed"
    quit 1
endif

co -l $q a.c
echo 1.4 >a.c
ci -l -mm $q a.c
echo error >a.c
ci -mm $q a.c
if val $rc gt 0
    echo "#ci -l failed"
    quit 1
endif

co -l $q a.c
echo 1.5 >a.c
ci -u -mm $q a.c
if not exists a.c
    "#ci -u didn't create a working file"
    quit 1
endif

delete quiet force a.c
echo error >a.c
ci -mm $q a.c >NIL:
if val $rc eq 0
    echo "#ci -u didn't unlock the file"
    quit 1
endif

delete quiet force a.c
rcs -l $q a.c
co -u $q a.c
if val $rc gt 0
    echo "#rcs -l + co -u failed"
    quit 1
endif

delete quiet force a.c
echo error >a.c

ci >NIL: -mm $q a.c
if val $rc eq 0
    echo "#co -u didn't unlock the file"
    quit 1
endif

delete quiet force a.c
xcopy a.11 a.c
co -f $q a.c
if val $rc gt 0
    echo "#co -f failed"
    quit 1
endif

$diff a.11 a.c >NIL:
if val $rc eq 0
    echo "#co -f had no effect"
    quit 1
endif

co -p1.1 $q a.c >a.t

$diff a.11 a.t
if val $rc gt 0
    echo "#co -p failed"
    quit 1
endif

delete quiet force a.c
co -l $q a.c
echo n >a.n
xcopy a.n a.c
ci -nn -mm $q a.c
co -rn $q a.c
$diff a.n a.c
if val $rc gt 0
    echo "#ci -n failed"
    quit 1
endif

delete quiet force a.c
co -l $q a.c
echo N >a.n
xcopy a.n a.c
ci -Nn -mm $q a.c
co -rn $q a.c
$diff a.n a.c
if val $rc gt 0
    echo "#ci -N failed"
    quit 1
endif

if not $LOGNAME eq ""
    set me $LOGNAME
else
    if not $USER eq ""
	set me $USER
    else
	echo "Neither LOGNAME nor USER is set!"
	quit 2
    endif
endif

delete quiet force a.#? $RCSfile $RCSalt
unset q
unset RCSfile
unset RCSalt
unset lockfile
unset diff
unset me

Echo "*NPartial test of RCS completed."
Echo "You may ignore the two 'ci error: no lock set by <user>' messages."
Echo "To do a complete test you need to adapt the remaining 240 lines"
Echo "of the original unix rcstest script. Have fun."

quit
;-------------------------------------------------------------------
; End of Amiga translation, don't know too much about unix shells.
; and now it's getting to complicated.
; Please note: All '{' and '}' were replaced by '[' and ']' to
; make this script compatible to the Amiga EXECUTE command.
;-------------------------------------------------------------------

date=`date -u 2>/dev/null` ||
date=`TZ=GMT0 date 2>/dev/null` ||
date=`TZ= date` || exit 2
set $date
case $2 in
Jan) m=01;; Feb) m=02;; Mar) m=03;; Apr) m=04;; May) m=05;; Jun) m=06;;
Jul) m=07;; Aug) m=08;; Sep) m=09;; Oct) m=10;; Nov) m=11;; Dec) m=12;;
*) echo >&2 "$0: $2: unknown month name"; exit 2
esac
case $3 in
?) d=0$3;;
*) d=$3
esac
case $6 in
[0-9][0-9][0-9][0-9]*) D=$6/$m/$d;;
*)
	case $5 in
	[0-9][0-9][0-9][0-9]*) D=$5/$m/$d;;
	*) echo >&2 "$0: bad date format: $date"; exit 2
	esac
esac
T=$4
case $PWD in
'') PWD=`pwd`
esac &&
co -l $q a.c &&
sed 's/@@/$/g' >a.kv <<EOF
@@Author: w @@
@@Date: $D $T @@
@@Header: $PWD$SLASH$RCSfile 2.1 $D $T w s @@
@@Id: a.c 2.1 $D $T w s @@
@@Locker:  @@
@@Log: a.c @@
 * Revision 2.1  $D  $T  w
 * m
 *
@@RCSfile: a.c @@
@@Revision: 2.1 @@
@@Source: $PWD$SLASH$RCSfile @@
@@State: s @@
EOF
test $? = 0 &&
sed 's/:.*\$/$/' a.kv >a.k &&
sed -e 's/w s [$]/w s '"$me"' $/' -e 's/[$]Locker: /&'"$me/" a.kv >a.kvl &&
sed -e '/^\$/!d' -e 's/\$$/: old $/' a.k >a.o &&
sed -e 's/\$[^ ]*: //' -e 's/ \$//' a.kv >a.v &&
cp a.o a.c &&
ci -d"$date" -ss -ww -u2.1 -mm $q a.c &&
$diff a.kv a.c || [ echo "#keyword expansion failed"; exit 1; ]
co -p -ko $q a.c >a.oo &&
$diff a.o a.oo || [ echo "#co -p -ko failed"; exit 1; ]
cp a.kv a.o || exit 2
rcs -o2.1 $q a.c &&
rcs -l $q a.c &&
ci -k -u $q a.c &&
$diff a.kv a.c || [ echo "#ci -k failed"; exit 1; ]
sed '/^[^$]/d' a.kv >a.i &&
ident a.c >a.i1 &&
sed -e 1d -e 's/^[       ]*//' a.i1 >a.i2 &&
$diff a.i a.i2 || [ echo "#ident failed"; exit 1; ]

rcs -i $q a.c 2>/dev/null && [ echo "#rcs -i permitted existing file"; exit 1; ]

co -l $q a.c &&
echo 2.2 >a.c &&
ci -mm $q a.c &&
echo 1.1.1.2 >a.c &&
rcs -l1.1.1 $q a.c &&
ci -r1.1.1.2 -mm $q a.c &&
rcs -b1.1.1 $q a.c &&
test " `co -p $q a.c`" = ' 1.1.1.2' || [ echo "#rcs -b1.1.1 failed"; exit 1; ]
rcs -b $q a.c &&
test " `co -p $q a.c`" = ' 2.2' || [ echo "#rcs -b failed"; exit 1; ]

echo 2.3 >a.c || exit 2
rcs -U $q a.c || [ echo "#rcs -U failed"; exit 1; ]
ci -mm $q a.c || [ echo "#rcs -U didn't unset strict locking"; exit 1; ]
rcs -L $q a.c || [ echo "#rcs -L failed"; exit 1; ]
echo error >a.c || exit 2
ci -mm $q a.c 2>/dev/null && [ echo "#ci retest failed"; exit 1; ]

rm -f a.c &&
log0=`rlog -h a.c` &&
co -l $q a.c &&
ci -mm $q a.c &&
log1=`rlog -h a.c` &&
test " $log0" = " $log1" || [ echo "#unchanged ci didn't revert"; exit 1; ]

rm -f a.c &&
rcs -nN:1.1 $q a.c &&
co -rN $q a.c &&
$diff a.11 a.c || [ echo "#rcs -n failed"; exit 1; ]

rcs -NN:2.1 $q a.c &&
co -rN $q a.c &&
$diff a.kv a.c || [ echo "#rcs -N failed"; exit 1; ]

co -l $q a.c &&
rcs -c':::' $q a.c &&
echo '$''Log$' >a.c &&
ci -u -mm $q a.c &&
test " `sed '$!d' a.c`" = ' :::' || [ echo "#rcs -c failed"; exit 1; ]

rcs -o2.2: $q a.c &&
co $q a.c &&
$diff a.kv a.c || [ echo "#rcs -o failed"; exit 1; ]

rcsdiff -r1.1 -r2.1 $q a.c >a.0
case $? in
1) ;;
*) echo "#rcsdiff bad status"; exit 1
esac
diff a.11 a.kv >a.1
$diff a.0 a.1 || [ echo "#rcsdiff failed"; exit 1; ]

rcs -l2.1 $q a.c || [ echo "#rcs -l2.1 failed"; exit 1; ]
for i in k kv kvl o v
do
	rm -f a.c &&
	cp a.$i a.c &&
	rcsdiff -k$i $q a.c || [ echo "#rcsdiff -k$i failed"; exit 1; ]
done
co -p1.1 -ko $q a.c >a.t &&
$diff a.11 a.t || [ echo "#co -p1.1 -ko failed"; exit 1; ]
rcs -u2.1 $q a.c || [ echo "#rcs -u2.1 failed"; exit 1; ]

rm -f a.c &&
co -l $q a.c &&
cat >a.c <<'EOF'
2.2
a
b
c
d
EOF
test $? = 0 &&
ci -l -mm $q a.c &&
co -p2.2 $q a.c | sed -e s/2.2/2.3/ -e s/b/b1/ >a.c &&
ci -l -mm $q a.c &&
co -p2.2 $q a.c | sed -e s/2.2/new/ -e s/d/d1/ >a.c || exit 2
cat >a.0 <<'EOF'
2.3
a
b1
c
d1
EOF
cat >a.1 <<'EOF'
<<<<<<< a.c
new
=======
2.3
>>>>>>> 2.3
a
b1
c
d1
EOF
rcsmerge -r2.2 -r2.3 $q a.c
case $? in
0)
	if $diff a.0 a.c >/dev/null
	then echo "#warning: diff3 -E does not work, " \
		"so merge and rcsmerge ignore overlaps and suppress overlap lines."
	else
		$diff a.1 a.c || [ echo "#rcsmerge failed (status 0)"; exit 1; ]
		echo "#warning: The diff3 lib program exit status ignores overlaps," \
			"so rcsmerge does not warn about overlap lines that it generates."
	fi
	;;
1)
	$diff a.1 a.c || [ echo "#rcsmerge failed (status 1)"; exit 1; ]
	;;
*)
	echo "#rcsmerge bad status"; exit 1
esac

nl='
'
[
	co -p $q a.c | tr "$nl" '\200' >a.24 &&
	cp a.24 a.c &&
	ciOut=`(ci -l -mm $q a.c 2>&1)` &&
	case $ciOut in
	?*) echo >&2 "$ciOut"
	esac &&
	co -p $q a.c | tr '\200' "$nl" >a.c &&
	rcsdiff -r2.3 $q a.c >/dev/null &&

	echo 2.5 >a.c &&
	ci -l -mm $q a.c &&
	cp a.24 a.c &&
	rcsdiff -r2.4 $q a.c >/dev/null
] || echo "#warning: Traditional diff is used, so RCS is limited to text files."

rcs -u -o2.4: $q a.c || [ echo "#rcs -u -o failed"; exit 1; ]

rcs -i -Aa.c -t- $q a.d || [ echo "#rcs -i -A failed"; exit 1; ]

rlog -r2.1 a.c >a.t &&
grep '^checked in with -k' a.t >/dev/null &&
sed '/^checked in with -k/d' a.t >a.u &&
$diff - a.u <<EOF

RCS file: $RCSfile
Working file: a.c
head: 2.3
branch:
locks: strict
access list:
symbolic names:
	N: 2.1
	n: 1.8
comment leader: ":::"
keyword substitution: kv
total revisions: 13;	selected revisions: 1
description:
1.1
----------------------------
revision 2.1
date: $D $T;  author: w;  state: s;  lines: +13 -1
=============================================================================
EOF
test $? = 0 || [ echo "#rlog failed"; exit 1; ]


test ! -f $lockfile || [ echo "#lock file not removed"; exit 1; ]

exec rm -f a.* $RCSfile $RCS_alt
@
