shithub: front

Download patch

ref: 772f3099ef5c7ab16e787134a3bbad6b04863359
parent: e2fa84d6cda223d3e75b78e74209977336dea932
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Sep 16 18:55:40 EDT 2024

git/test: run tests with a temporary install bound to /bin/git

We want to run test before we do the installation
into the system.

So do a temporary install into test/$cputype.git/
direcotry and bind it on /bin/git, that way,
all the scripts run the local source version.

--- a/sys/src/cmd/git/test/add.rc
+++ b/sys/src/cmd/git/test/add.rc
@@ -10,7 +10,7 @@
 	rfork ne
 	cd scratch/repo
 	pwd=`{pwd}
-	$G/init
+	git/init
 	mkdir dir
 	mkdir another
 	mkdir more
@@ -20,15 +20,15 @@
 	touch another/^(a b c)
 	touch more/^(a b c)
 	touch extra/^(a b c)
-	$G/add a
-	$G/add $pwd/b
-	$G/add dir/a
-	$G/add $pwd/dir/b
-	$G/add more
-	@{cd more && $G/add ../extra/a}
-	@{cd more && $G/add $pwd/extra/b}
-	$G/$O.fs
-	$G/$O.walk > ../added
+	git/add a
+	git/add $pwd/b
+	git/add dir/a
+	git/add $pwd/dir/b
+	git/add more
+	@{cd more && git/add ../extra/a}
+	@{cd more && git/add $pwd/extra/b}
+	git/fs
+	git/walk > ../added
 }
 
 diff -c scratch/added add.expected >/dev/null || die wrong files
--- a/sys/src/cmd/git/test/basic.rc
+++ b/sys/src/cmd/git/test/basic.rc
@@ -9,15 +9,15 @@
 echo @@ version1 @@
 @{
 	cd scratch/upstream
-	q $G/init
+	q git/init
 	echo version1 > file.txt
-	q $G/add file.txt
-	q $G/commit -m version1 file.txt
+	q git/add file.txt
+	q git/commit -m version1 file.txt
 }
 
 @{
 	cd scratch
-	$G/clone $wrkdir/scratch/upstream downstream
+	git/clone $wrkdir/scratch/upstream downstream
 }
 
 diff -c scratch/upstream/file.txt scratch/downstream/file.txt || die mismatch
@@ -26,11 +26,11 @@
 @{
 	cd scratch/upstream
 	echo version2 > file.txt
-	q $G/commit -m version2 file.txt
+	q git/commit -m version2 file.txt
 }
 @{
 	cd scratch/downstream
-	q $G/pull
+	q git/pull
 }
 q diff -c scratch/upstream/file.txt scratch/downstream/file.txt || die mismatch
 
@@ -38,12 +38,12 @@
 @{
 	cd scratch/upstream
 	echo version3 > file2.txt
-	$G/add file2.txt
-	q $G/commit -m version3 file2.txt
+	git/add file2.txt
+	q git/commit -m version3 file2.txt
 }
 @{
 	cd scratch/downstream
-	q $G/pull
+	q git/pull
 }
 q diff -c scratch/upstream/file.txt scratch/downstream/file.txt || die mismatch
 q diff -c scratch/upstream/file2.txt scratch/downstream/file2.txt || die mismatch
@@ -52,14 +52,14 @@
 @{
 	cd scratch/upstream
 	echo version4 > file.txt
-	$G/rm file2.txt
+	git/rm file2.txt
 	rm file2.txt
-	q $G/commit -m version4 file.txt file2.txt
+	q git/commit -m version4 file.txt file2.txt
 }
 
 @{
 	cd scratch/downstream
-	q $G/pull
+	q git/pull
 }
 q diff -c scratch/upstream/file.txt scratch/downstream/file.txt || die mismatch
 ! test -e scratch/upstream/file2.txt || die mismatch
--- a/sys/src/cmd/git/test/export.rc
+++ b/sys/src/cmd/git/test/export.rc
@@ -9,16 +9,16 @@
 # setup test repo
 @{
 	rfork ne
-	q $G/init a
+	q git/init a
 
 	cd a
 	echo hello > a
 	echo goodbye > b
-	q $G/add a b
-	q $G/commit -m v1 .
+	q git/add a b
+	q git/commit -m v1 .
 	cd ..
 	pwd
-	q $G/clone `{pwd}^/a b
+	q git/clone `{pwd}^/a b
 }
 
 echo @@ export and apply @@
@@ -27,14 +27,14 @@
 	@{
 		cd b
 		echo hihi > b
-		q $G/commit -m export1 b
-		$G/export > ../export1.patch
+		q git/commit -m export1 b
+		git/export > ../export1.patch
 	}
 
 	@{
 		cd a
-		q $G/import ../export1.patch
+		q git/import ../export1.patch
 	}
 }
 
-~ `{cd a && $G/$O.query HEAD} `{cd b && $G/$O.query HEAD} || die 'mismatched export'
+~ `{cd a && git/query HEAD} `{cd b && git/query HEAD} || die 'mismatched export'
--- a/sys/src/cmd/git/test/ftype.rc
+++ b/sys/src/cmd/git/test/ftype.rc
@@ -10,7 +10,7 @@
 	rfork ne
 	cd scratch/repo1
 	repo1=`{pwd}
-	$G/init
+	git/init
 
 	# in repo1:
 	#	create A as a file
@@ -18,11 +18,11 @@
 	echo A > A
 	mkdir B
 	echo C > B/C
-	$G/add A B/C
-	$G/commit -m 1 A B/C
+	git/add A B/C
+	git/commit -m 1 A B/C
 
 	cd ..
-	$G/clone $repo1 repo2
+	git/clone $repo1 repo2
 	cd repo2
 	repo2=`{pwd}
 
@@ -38,12 +38,12 @@
 	mkdir A
 	echo B > A/B
 	echo B > B
-	$G/add A/B B
-	$G/commit -m 2 A/B B
+	git/add A/B B
+	git/commit -m 2 A/B B
 
 	# pull repo2 after file changed to directory in repo1
 	cd $repo2
-	$G/pull
+	git/pull
 
 	diff -r $repo1/A $repo2/A || exit 'pull fail A'
 	diff -r $repo1/B $repo2/B || exit 'pull fail B'
--- a/sys/src/cmd/git/test/lca.rc
+++ b/sys/src/cmd/git/test/lca.rc
@@ -8,36 +8,36 @@
 
 echo @@ test lca @@
 @{
-	q $G/init a
+	q git/init a
 
 	cd a
 
 	echo 'first' > f
-	q $G/add f
-	q $G/commit -m base f
-	r=`{$G/$O.query HEAD}
+	q git/add f
+	q git/commit -m base f
+	r=`{git/query HEAD}
 
 	echo 0 > f
-	q $G/commit -m a.0 .
-	a=`{$G/$O.query HEAD}
+	q git/commit -m a.0 .
+	a=`{git/query HEAD}
 
 	for(i in `{seq 10}){
 		echo $i > f
-		q $G/commit -m a.$i .
+		q git/commit -m a.$i .
 	}
 
-	q $G/branch -nb $r merge
+	q git/branch -nb $r merge
 	echo x > f
-	q $G/commit -m b.0 .
-	b=`{$G/$O.query HEAD}
+	q git/commit -m b.0 .
+	b=`{git/query HEAD}
 
-	qq $G/merge front
-	q $G/commit -m merge .
-	m=`{$G/$O.query HEAD}
+	qq git/merge front
+	q git/commit -m merge .
+	m=`{git/query HEAD}
 
-~ `{$G/$O.query $a $m @} $a || die lca a-m
-~ `{$G/$O.query $a $b @} $r || die lca a-b
-~ `{$G/$O.query $a $r @} $r || die lca a-r
+~ `{git/query $a $m @} $a || die lca a-m
+~ `{git/query $a $b @} $r || die lca a-b
+~ `{git/query $a $r @} $r || die lca a-r
 }
 
 #       a
@@ -47,13 +47,13 @@
 # date order (oldest to newest): f d c b e a
 echo @@ test lca rebase @@
 @{
-	q $G/init b
+	q git/init b
 	cd b
 
 	touch f
 
 	fn commit {
-		$G/$O.save -n regress -e regress $* f
+		git/save -n regress -e regress $* f
 	}
 
 	f=`{commit -m f -d 1}
@@ -63,6 +63,6 @@
 	b=`{commit -m b -d 4 -p $c}
 	a=`{commit -m a -d 6 -p $e}
 
-~ `{$G/$O.query $a $b @} $e || die lca a-b
-~ `{$G/$O.query $b $a @} $e || die lca b-a
+~ `{git/query $a $b @} $e || die lca a-b
+~ `{git/query $b $a @} $e || die lca b-a
 }
--- a/sys/src/cmd/git/test/merge.rc
+++ b/sys/src/cmd/git/test/merge.rc
@@ -13,7 +13,7 @@
 # setup test repo
 @{
 	rfork ne
-	q $G/init a
+	q git/init a
 
 	cd a
 	echo hello > a
@@ -20,11 +20,11 @@
 	echo goodbye > b
 	echo -n $c > c
 	chmod +x a
-	q $G/add a b c
-	q $G/commit -m v1 .
+	q git/add a b c
+	q git/commit -m v1 .
 	cd ..
 	pwd
-	q $G/clone `{pwd}^/a b
+	q git/clone `{pwd}^/a b
 }
 
 echo @@ merge different files @@
@@ -33,19 +33,19 @@
 	@{
 		cd a
 		echo x > a
-		q $G/commit -m diverge1a a
+		q git/commit -m diverge1a a
 	}
 	@{
 		cd b
 		echo y > b
-		q $G/commit -m diverge1b b
+		q git/commit -m diverge1b b
 	}
 
 	@{
 		cd b
-		qq $G/pull
-		$G/merge origin/front || status=''
-		q $G/commit -m merged
+		qq git/pull
+		git/merge origin/front || status=''
+		q git/commit -m merged
 	}
 }
 
@@ -66,17 +66,17 @@
 		chmod -x a
 		chmod +x b
 		echo quux >>c
-		q $G/commit -m diverge2a a b c
+		q git/commit -m diverge2a a b c
 	}
 	@{
 		cd b
 		sed s/foo/FOO/ <c >c.new
 		mv c.new c
-		q $G/commit -m diverge2b c
+		q git/commit -m diverge2b c
 
-		qq $G/pull
-		qq $G/merge origin/front
-		q $G/commit -m merge c
+		qq git/pull
+		qq git/merge origin/front
+		q git/commit -m merge c
 	}
 }
 
--- a/sys/src/cmd/git/test/mkfile
+++ b/sys/src/cmd/git/test/mkfile
@@ -11,6 +11,11 @@
 
 </sys/src/cmd/mktest
 
+$cputype.git:
+	@{cd .. && objtype=$cputype mk install 'BIN=test/'$target}
+
+test:V:	$cputype.git
+
 clean:V:
 	rm -f *.[$OS] *.out *.a[$OS] y.tab.? lex.yy.c y.debug y.output [$OS].??* $TARG
-	rm -fr scratch
+	rm -fr scratch $cputype.git
--- a/sys/src/cmd/git/test/range.rc
+++ b/sys/src/cmd/git/test/range.rc
@@ -7,7 +7,7 @@
 cd scratch
 
 fn commit {
-	$G/$O.save -n regress -e regress $* f
+	git/save -n regress -e regress $* f
 }
 
 # h→g→f
@@ -15,7 +15,7 @@
 # e→d→c→b→a
 echo @@ test range @@
 @{
-	q $G/init a
+	q git/init a
 	cd a
 	touch f
 
@@ -39,7 +39,7 @@
 	'
 
 	diff -u <{echo d; echo e; echo g; echo h} \
-		<{$G/$O.query $f..$h | sed -e $map} || die range
+		<{git/query $f..$h | sed -e $map} || die range
 }
 
 #       b
@@ -49,7 +49,7 @@
 #       c
 echo @@ test range 2 @@
 @{
-	q $G/init b
+	q git/init b
 	cd b
 	touch f
 
@@ -69,7 +69,7 @@
 	'
 
 	diff -u <{echo c; echo d; echo e; echo f} \
-		<{$G/$O.query $b..$f | sed -e $map} || die range
+		<{git/query $b..$f | sed -e $map} || die range
 	diff -u <{echo b; echo d; echo e; echo f} \
-		<{$G/$O.query $c..$f | sed -e $map} || die range
+		<{git/query $c..$f | sed -e $map} || die range
 }
--- a/sys/src/cmd/git/test/util.rc
+++ b/sys/src/cmd/git/test/util.rc
@@ -14,4 +14,5 @@
 	}
 }
 
-G=`{cleanname `{pwd}^/..}
+rfork n
+bind $cputype.git /bin/git
--