test: hg-git: general cleanup

Now that we don't have to run hg-git the code is much simpler.

No functional changes.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
This commit is contained in:
Felipe Contreras
2023-03-06 09:33:48 -06:00
parent 83620648ab
commit 9949745533

View File

@@ -26,8 +26,7 @@ then
test_done test_done
fi fi
# clone to a git repo with git git_clone () {
git_clone_git () {
git clone -q "hg::$1" $2 && git clone -q "hg::$1" $2 &&
( (
cd $2 && cd $2 &&
@@ -36,8 +35,7 @@ git_clone_git () {
) )
} }
# clone to an hg repo with git hg_clone () {
hg_clone_git () {
( (
hg init $2 && hg init $2 &&
hg -R $2 bookmark -i master && hg -R $2 bookmark -i master &&
@@ -48,8 +46,7 @@ hg_clone_git () {
(cd $2 && hg -q update) (cd $2 && hg -q update)
} }
# push an hg repo with git hg_push () {
hg_push_git () {
( (
cd $2 cd $2
git checkout -q -b tmp && git checkout -q -b tmp &&
@@ -70,43 +67,34 @@ git_log () {
} }
test_cmp_expected () { test_cmp_expected () {
test_cmp "$EXPECTED_DIR/$test_id/$1" "${1}-git" test_cmp "$EXPECTED_DIR/$test_id/$1" "$1"
} }
cmp_hg_to_git_log () { cmp_hg_to_git_log () {
for x in git hg_log hgrepo2 > hg-log &&
do git_log gitrepo > git-log &&
hg_log hgrepo2-$x > "hg-log-$x" &&
git_log gitrepo-$x > "git-log-$x"
done &&
test_cmp_expected hg-log && test_cmp_expected hg-log &&
test_cmp_expected git-log test_cmp_expected git-log
} }
cmp_hg_to_git_log_hgrepo1 () { cmp_hg_to_git_log_hgrepo1 () {
for x in git git_clone hgrepo1 gitrepo &&
do hg_clone gitrepo hgrepo2 &&
git_clone_$x hgrepo1 gitrepo-$x &&
hg_clone_$x gitrepo-$x hgrepo2-$x
done &&
cmp_hg_to_git_log cmp_hg_to_git_log
} }
cmp_hg_to_git_manifest () { cmp_hg_to_git_manifest () {
for x in git (
do hg_clone gitrepo hgrepo &&
( cd hgrepo &&
hg_clone_$x gitrepo hgrepo-$x && hg_log . &&
cd hgrepo-$x && eval "$1"
hg_log . && ) > output &&
eval "$1"
) > "output-$x" &&
git_clone_$x hgrepo-$x gitrepo2-$x && git_clone hgrepo gitrepo2 &&
git_log gitrepo2-$x > "log-$x" git_log gitrepo2 > log &&
done &&
test_cmp_expected output && test_cmp_expected output &&
test_cmp_expected log test_cmp_expected log
@@ -291,14 +279,11 @@ test_expect_success 'encoding' '
git commit -m "add déltà" git commit -m "add déltà"
) && ) &&
for x in git hg_clone gitrepo hgrepo &&
do git_clone hgrepo gitrepo2 &&
hg_clone_$x gitrepo hgrepo-$x &&
git_clone_$x hgrepo-$x gitrepo2-$x &&
HGENCODING=utf-8 hg_log hgrepo-$x > "hg-log-$x" && HGENCODING=utf-8 hg_log hgrepo > hg-log &&
git_log gitrepo2-$x > "git-log-$x" git_log gitrepo2 > git-log &&
done &&
test_cmp_expected hg-log && test_cmp_expected hg-log &&
test_cmp_expected git-log test_cmp_expected git-log
@@ -343,137 +328,125 @@ test_expect_success 'git tags' '
git tag -a -m "added tag beta" beta git tag -a -m "added tag beta" beta
) && ) &&
for x in git hg_clone gitrepo hgrepo &&
do hg_log hgrepo > log &&
hg_clone_$x gitrepo hgrepo-$x &&
hg_log hgrepo-$x > "log-$x"
done &&
test_cmp_expected log test_cmp_expected log
' '
test_expect_success 'hg author' ' test_expect_success 'hg author' '
for x in git (
do git init -q gitrepo &&
( cd gitrepo &&
git init -q gitrepo-$x &&
cd gitrepo-$x &&
echo alpha > alpha && echo alpha > alpha &&
git add alpha && git add alpha &&
git commit -m "add alpha" && git commit -m "add alpha" &&
git checkout -q -b not-master git checkout -q -b not-master
) && ) &&
( (
hg_clone_$x gitrepo-$x hgrepo-$x && hg_clone gitrepo hgrepo &&
cd hgrepo-$x && cd hgrepo &&
hg co master && hg co master &&
echo beta > beta && echo beta > beta &&
hg add beta && hg add beta &&
hg commit -u "test" -m "add beta" && hg commit -u "test" -m "add beta" &&
echo gamma >> beta && echo gamma >> beta &&
hg commit -u "test <test@example.com> (comment)" -m "modify beta" && hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
echo gamma > gamma && echo gamma > gamma &&
hg add gamma && hg add gamma &&
hg commit -u "<test@example.com>" -m "add gamma" && hg commit -u "<test@example.com>" -m "add gamma" &&
echo delta > delta && echo delta > delta &&
hg add delta && hg add delta &&
hg commit -u "name<test@example.com>" -m "add delta" && hg commit -u "name<test@example.com>" -m "add delta" &&
echo epsilon > epsilon && echo epsilon > epsilon &&
hg add epsilon && hg add epsilon &&
hg commit -u "name <test@example.com" -m "add epsilon" && hg commit -u "name <test@example.com" -m "add epsilon" &&
echo zeta > zeta && echo zeta > zeta &&
hg add zeta && hg add zeta &&
hg commit -u " test " -m "add zeta" && hg commit -u " test " -m "add zeta" &&
echo eta > eta && echo eta > eta &&
hg add eta && hg add eta &&
hg commit -u "test < test@example.com >" -m "add eta" && hg commit -u "test < test@example.com >" -m "add eta" &&
echo theta > theta && echo theta > theta &&
hg add theta && hg add theta &&
hg commit -u "test >test@example.com>" -m "add theta" && hg commit -u "test >test@example.com>" -m "add theta" &&
echo iota > iota && echo iota > iota &&
hg add iota && hg add iota &&
hg commit -u "test <test <at> example <dot> com>" -m "add iota" hg commit -u "test <test <at> example <dot> com>" -m "add iota"
) && ) &&
hg_push_$x hgrepo-$x gitrepo-$x && hg_push hgrepo gitrepo &&
hg_clone_$x gitrepo-$x hgrepo2-$x hg_clone gitrepo hgrepo2 &&
done &&
cmp_hg_to_git_log cmp_hg_to_git_log
' '
test_expect_success 'hg branch' ' test_expect_success 'hg branch' '
for x in git (
do git init -q gitrepo &&
( cd gitrepo &&
git init -q gitrepo-$x &&
cd gitrepo-$x &&
echo alpha > alpha && echo alpha > alpha &&
git add alpha && git add alpha &&
git commit -q -m "add alpha" && git commit -q -m "add alpha" &&
git checkout -q -b not-master git checkout -q -b not-master
) && ) &&
( (
hg_clone_$x gitrepo-$x hgrepo-$x && hg_clone gitrepo hgrepo &&
cd hgrepo-$x && cd hgrepo &&
hg -q co master && hg -q co master &&
hg mv alpha beta && hg mv alpha beta &&
hg -q commit -m "rename alpha to beta" && hg -q commit -m "rename alpha to beta" &&
hg branch gamma | grep -v "permanent and global" && hg branch gamma | grep -v "permanent and global" &&
hg -q commit -m "started branch gamma" hg -q commit -m "started branch gamma"
) && ) &&
hg_push_$x hgrepo-$x gitrepo-$x && hg_push hgrepo gitrepo &&
hg_clone_$x gitrepo-$x hgrepo2-$x hg_clone gitrepo hgrepo2 &&
done &&
cmp_hg_to_git_log cmp_hg_to_git_log
' '
test_expect_success 'hg tags' ' test_expect_success 'hg tags' '
for x in git (
do git init -q gitrepo &&
( cd gitrepo &&
git init -q gitrepo-$x &&
cd gitrepo-$x &&
echo alpha > alpha && echo alpha > alpha &&
git add alpha && git add alpha &&
git commit -m "add alpha" && git commit -m "add alpha" &&
git checkout -q -b not-master git checkout -q -b not-master
) && ) &&
( (
hg_clone_$x gitrepo-$x hgrepo-$x && hg_clone gitrepo hgrepo &&
cd hgrepo-$x && cd hgrepo &&
hg co master && hg co master &&
hg tag alpha hg tag alpha
) && ) &&
hg_push_$x hgrepo-$x gitrepo-$x && hg_push hgrepo gitrepo &&
hg_clone_$x gitrepo-$x hgrepo2-$x && hg_clone gitrepo hgrepo2 &&
( (
git --git-dir=gitrepo-$x/.git tag -l && git --git-dir=gitrepo/.git tag -l &&
hg_log hgrepo2-$x && hg_log hgrepo2 &&
cat hgrepo2-$x/.hgtags cat hgrepo2/.hgtags
) > "output-$x" ) > output &&
done &&
test_cmp_expected output test_cmp_expected output
' '