diff options
author | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-08-05 17:09:41 +0100 |
---|---|---|
committer | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-08-05 18:06:36 +0100 |
commit | 235ed194d7a3094db7f9e2e4d93c5b1750f55e3a (patch) | |
tree | 860f0ef9cd1333439619cb1412ff9f7a5db06b80 | |
parent | cd67da78140046ac90877194e3f818cfeb252f60 (diff) | |
download | lorry-235ed194d7a3094db7f9e2e4d93c5b1750f55e3a.tar.gz |
tests: Add a test case for unnamed heads in Mercurial
Test that we can cope with conversion of unnamed heads now.
Related to #7.
-rwxr-xr-x | tests/hg-unnamed-head.script | 51 | ||||
-rwxr-xr-x | tests/hg-unnamed-head.setup | 58 | ||||
-rw-r--r-- | tests/hg-unnamed-head.stdout | 7 | ||||
-rwxr-xr-x | tests/hg-unnamed-head.teardown | 21 |
4 files changed, 137 insertions, 0 deletions
diff --git a/tests/hg-unnamed-head.script b/tests/hg-unnamed-head.script new file mode 100755 index 0000000..fa2693f --- /dev/null +++ b/tests/hg-unnamed-head.script @@ -0,0 +1,51 @@ +#!/bin/sh +# +# Regression test for https://gitlab.com/CodethinkLabs/lorry/lorry/-/issues/7 +# +# Copyright (C) 2012, 2020 Codethink Limited +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +set -e + + +logfile="$DATADIR/hg-test-repo.log" +workdir="$DATADIR/work-dir" + +"${SRCDIR}/test-lorry" --verbose --pull-only --log="$logfile" --working-area="$workdir" \ + "$DATADIR/hg-test-repo.lorry" > /dev/null 2> /dev/null + +# verify that the git repository was created correctly +( + cd "$workdir/hg-test-repo/git/" + + # check number of commits generated + wc -l hg2git-marks + + # list the branches + git show-ref | cut -d' ' -f2 + + # cat the test file + git cat-file blob master:test.txt + + # list the commit messages + git log --pretty='%s' master +) + +# check that we can another incremental conversion succeeds, and +# that this involves pruning an unreachable commit +"${SRCDIR}/test-lorry" --verbose --pull-only --log="$logfile" --working-area="$workdir" \ + "$DATADIR/hg-test-repo.lorry" > /dev/null 2> /dev/null +grep -c 'pruning unreachable commit' < "$logfile" diff --git a/tests/hg-unnamed-head.setup b/tests/hg-unnamed-head.setup new file mode 100755 index 0000000..31105f5 --- /dev/null +++ b/tests/hg-unnamed-head.setup @@ -0,0 +1,58 @@ +#!/bin/sh +# +# Regression test for https://gitlab.com/CodethinkLabs/lorry/lorry/-/issues/7 +# +# Copyright (C) 2012, 2020 Codethink Limited +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +set -e + +# create the repository +repo="$DATADIR/hg-test-repo" +mkdir "$repo" +cd "$repo" +hg init --quiet + +# add the test file +echo "first line" > test.txt +hg add --quiet test.txt + +# make a commit +hg commit --user lorry-test-suite --quiet -m "first commit" + +base=$(hg id -n) + +# make a second commit +echo "second line" >> test.txt +hg commit --user lorry-test-suite --quiet -m "second commit" + +# make a third, divergent, commit +hg update -r$base +echo "third line" >> test.txt +hg commit --user lorry-test-suite --quiet -m "third commit" + +# create the .lorry file for the repository +cat <<EOF > $DATADIR/hg-test-repo.lorry +{ + "hg-test-repo": { + "type": "hg", + "url": "file://$repo" + } +} +EOF + +# create the working directory +test -d "$DATADIR/work-dir" || mkdir "$DATADIR/work-dir" diff --git a/tests/hg-unnamed-head.stdout b/tests/hg-unnamed-head.stdout new file mode 100644 index 0000000..7354306 --- /dev/null +++ b/tests/hg-unnamed-head.stdout @@ -0,0 +1,7 @@ +3 hg2git-marks +refs/heads/master +first line +third line +third commit +first commit +1 diff --git a/tests/hg-unnamed-head.teardown b/tests/hg-unnamed-head.teardown new file mode 100755 index 0000000..8b8cee1 --- /dev/null +++ b/tests/hg-unnamed-head.teardown @@ -0,0 +1,21 @@ +#!/bin/sh +# +# Regression test for https://gitlab.com/CodethinkLabs/lorry/lorry/-/issues/7 +# +# Copyright (C) 2020 Codethink Limited +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +rm -rf "$DATADIR/hg-test-repo" "$DATADIR/hg-test-repo.lorry" "$DATADIR/work-dir" |