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.
This commit is contained in:
cinap_lenrek 2024-09-16 22:55:40 +00:00
parent e2fa84d6cd
commit 772f3099ef
9 changed files with 85 additions and 79 deletions

View file

@ -10,7 +10,7 @@ echo @@ abs paths @@
rfork ne
cd scratch/repo
pwd=`{pwd}
$G/init
git/init
mkdir dir
mkdir another
mkdir more
@ -20,15 +20,15 @@ echo @@ abs paths @@
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

View file

@ -9,15 +9,15 @@ mkdir -p scratch/upstream
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 @@ echo @@ version2 @@
@{
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 @@ echo @@ version3 @@
@{
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 @@ echo @@ version4 @@
@{
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

View file

@ -9,16 +9,16 @@ cd scratch
# 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 @@ echo @@ export and apply @@
@{
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'

View file

@ -10,7 +10,7 @@ echo @@ file-type change @@
rfork ne
cd scratch/repo1
repo1=`{pwd}
$G/init
git/init
# in repo1:
# create A as a file
@ -18,11 +18,11 @@ echo @@ file-type change @@
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 @@ echo @@ file-type change @@
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'

View file

@ -8,36 +8,36 @@ cd scratch
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 @@ echo @@ test lca @@
# 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 @@ echo @@ test lca rebase @@
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
}

View file

@ -13,18 +13,18 @@ baz
# setup test repo
@{
rfork ne
q $G/init a
q git/init a
cd a
echo hello > a
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 @@ echo @@ merge different files @@
@{
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 @@ echo @@ merge concurent edits @@
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
}
}

View file

@ -11,6 +11,11 @@ TEST=\
</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

View file

@ -7,7 +7,7 @@ mkdir -p scratch
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 @@ fn commit {
# e→d→c→b→a
echo @@ test range @@
@{
q $G/init a
q git/init a
cd a
touch f
@ -39,7 +39,7 @@ echo @@ test range @@
'
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 @@ echo @@ test range @@
# c
echo @@ test range 2 @@
@{
q $G/init b
q git/init b
cd b
touch f
@ -69,7 +69,7 @@ echo @@ test range 2 @@
'
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
}

View file

@ -14,4 +14,5 @@ fn die {
}
}
G=`{cleanname `{pwd}^/..}
rfork n
bind $cputype.git /bin/git