test: hg-git: fetch output from expected dir

So we don't actually have to run hg-git every time (it's broken most of
the time anyway).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
This commit is contained in:
Felipe Contreras
2023-03-05 20:31:37 -06:00
parent 30a2d61bdf
commit 83620648ab

View File

@@ -12,6 +12,8 @@ test_description='Test remote-hg output compared to hg-git'
. ./test-lib.sh . ./test-lib.sh
export EXPECTED_DIR="$SHARNESS_TEST_DIRECTORY/expected"
if ! test_have_prereq PYTHON if ! test_have_prereq PYTHON
then then
skip_all='skipping remote-hg tests; python not available' skip_all='skipping remote-hg tests; python not available'
@@ -24,17 +26,6 @@ then
test_done test_done
fi fi
if python -c 'import hggit' > /dev/null 2>&1
then
hggit=hggit
elif python -c 'import hgext.git' > /dev/null 2>&1
then
hggit=hgext.git
else
skip_all='skipping remote-hg tests; hg-git not available'
test_done
fi
# clone to a git repo with git # clone to a git repo with git
git_clone_git () { git_clone_git () {
git clone -q "hg::$1" $2 && git clone -q "hg::$1" $2 &&
@@ -57,21 +48,6 @@ hg_clone_git () {
(cd $2 && hg -q update) (cd $2 && hg -q update)
} }
# clone to a git repo with hg
git_clone_hg () {
(
git init -q $2 &&
cd $1 &&
hg bookmark -i -f -r tip master &&
{ hg -q push -r master ../$2 || true ;}
)
}
# clone to an hg repo with hg
hg_clone_hg () {
hg -q clone $1 $2
}
# push an hg repo with git # push an hg repo with git
hg_push_git () { hg_push_git () {
( (
@@ -84,14 +60,6 @@ hg_push_git () {
) )
} }
# push an hg git repo with hg
hg_push_hg () {
(
cd $1 &&
{ hg -q push ../$2 || true ;}
)
}
hg_log () { hg_log () {
hg -R $1 log --debug -r 'sort(tip:0, date)' | hg -R $1 log --debug -r 'sort(tip:0, date)' |
sed -e '/tag: *default/d' -e 's/[0-9]\+:\([0-9a-f]\{40\}\)/\1/' sed -e '/tag: *default/d' -e 's/[0-9]\+:\([0-9a-f]\{40\}\)/\1/'
@@ -102,11 +70,11 @@ git_log () {
} }
test_cmp_expected () { test_cmp_expected () {
test_cmp "${1}-hg" "${1}-git" test_cmp "$EXPECTED_DIR/$test_id/$1" "${1}-git"
} }
cmp_hg_to_git_log () { cmp_hg_to_git_log () {
for x in hg git for x in git
do do
hg_log hgrepo2-$x > "hg-log-$x" && hg_log hgrepo2-$x > "hg-log-$x" &&
git_log gitrepo-$x > "git-log-$x" git_log gitrepo-$x > "git-log-$x"
@@ -117,7 +85,7 @@ cmp_hg_to_git_log () {
} }
cmp_hg_to_git_log_hgrepo1 () { cmp_hg_to_git_log_hgrepo1 () {
for x in hg git for x in git
do do
git_clone_$x hgrepo1 gitrepo-$x && git_clone_$x hgrepo1 gitrepo-$x &&
hg_clone_$x gitrepo-$x hgrepo2-$x hg_clone_$x gitrepo-$x hgrepo2-$x
@@ -127,7 +95,7 @@ cmp_hg_to_git_log_hgrepo1 () {
} }
cmp_hg_to_git_manifest () { cmp_hg_to_git_manifest () {
for x in hg git for x in git
do do
( (
hg_clone_$x gitrepo hgrepo-$x && hg_clone_$x gitrepo hgrepo-$x &&
@@ -151,10 +119,6 @@ setup () {
[defaults] [defaults]
commit = -d "0 0" commit = -d "0 0"
tag = -d "0 0" tag = -d "0 0"
[extensions]
$hggit =
[git]
debugextrainmessage = 1
EOF EOF
cat > "$HOME"/.gitconfig <<-EOF cat > "$HOME"/.gitconfig <<-EOF
@@ -176,6 +140,7 @@ setup
eval "old_$(declare -f test_expect_success)" eval "old_$(declare -f test_expect_success)"
test_expect_success () { test_expect_success () {
test_id="$1" &&
old_test_expect_success "$1" " old_test_expect_success "$1" "
test_when_finished \"rm -rf gitrepo* hgrepo*\" && $2" test_when_finished \"rm -rf gitrepo* hgrepo*\" && $2"
} }
@@ -326,7 +291,7 @@ test_expect_success 'encoding' '
git commit -m "add déltà" git commit -m "add déltà"
) && ) &&
for x in hg git for x in git
do do
hg_clone_$x gitrepo hgrepo-$x && hg_clone_$x gitrepo hgrepo-$x &&
git_clone_$x hgrepo-$x gitrepo2-$x && git_clone_$x hgrepo-$x gitrepo2-$x &&
@@ -378,7 +343,7 @@ test_expect_success 'git tags' '
git tag -a -m "added tag beta" beta git tag -a -m "added tag beta" beta
) && ) &&
for x in hg git for x in git
do do
hg_clone_$x gitrepo hgrepo-$x && hg_clone_$x gitrepo hgrepo-$x &&
hg_log hgrepo-$x > "log-$x" hg_log hgrepo-$x > "log-$x"
@@ -388,7 +353,7 @@ test_expect_success 'git tags' '
' '
test_expect_success 'hg author' ' test_expect_success 'hg author' '
for x in hg git for x in git
do do
( (
git init -q gitrepo-$x && git init -q gitrepo-$x &&
@@ -449,7 +414,7 @@ test_expect_success 'hg author' '
' '
test_expect_success 'hg branch' ' test_expect_success 'hg branch' '
for x in hg git for x in git
do do
( (
git init -q gitrepo-$x && git init -q gitrepo-$x &&
@@ -480,7 +445,7 @@ test_expect_success 'hg branch' '
' '
test_expect_success 'hg tags' ' test_expect_success 'hg tags' '
for x in hg git for x in git
do do
( (
git init -q gitrepo-$x && git init -q gitrepo-$x &&