diff options
author | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-08-05 16:24:25 +0100 |
---|---|---|
committer | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-08-05 18:06:36 +0100 |
commit | cd67da78140046ac90877194e3f818cfeb252f60 (patch) | |
tree | 90b1c97c2be3447b1433fc7268e1ba7a66f01f03 /tests | |
parent | 9d8c35bfa8a717c656a78c636c5a4600e5837ae7 (diff) | |
download | lorry-cd67da78140046ac90877194e3f818cfeb252f60.tar.gz |
tests: Add a test case for incremental conversion from Mercurial
Also add a teardown script for hg-single-commit so these two don't
get in each other's way.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/hg-incremental.script | 53 | ||||
-rwxr-xr-x | tests/hg-incremental.setup | 47 | ||||
-rw-r--r-- | tests/hg-incremental.stdout | 5 | ||||
-rwxr-xr-x | tests/hg-incremental.teardown | 21 | ||||
-rwxr-xr-x | tests/hg-single-commit.teardown | 21 |
5 files changed, 147 insertions, 0 deletions
diff --git a/tests/hg-incremental.script b/tests/hg-incremental.script new file mode 100755 index 0000000..16ca350 --- /dev/null +++ b/tests/hg-incremental.script @@ -0,0 +1,53 @@ +#!/bin/sh +# +# Tests incremental conversion of a simple hg repository to git. +# +# 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 + +repo="$DATADIR/hg-test-repo" + +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 + +# make a second commit +( + cd "$repo" + echo "second line" >> test.txt + hg commit --user lorry-test-suite --quiet -m "second commit" +) + +"${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/" + + # 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 +) diff --git a/tests/hg-incremental.setup b/tests/hg-incremental.setup new file mode 100755 index 0000000..1f965b3 --- /dev/null +++ b/tests/hg-incremental.setup @@ -0,0 +1,47 @@ +#!/bin/sh +# +# Tests incremental conversion of a simple hg repository to git. +# +# Copyright (C) 2012 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" + +# 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-incremental.stdout b/tests/hg-incremental.stdout new file mode 100644 index 0000000..dffabe8 --- /dev/null +++ b/tests/hg-incremental.stdout @@ -0,0 +1,5 @@ +refs/heads/master +first line +second line +second commit +first commit diff --git a/tests/hg-incremental.teardown b/tests/hg-incremental.teardown new file mode 100755 index 0000000..409c26b --- /dev/null +++ b/tests/hg-incremental.teardown @@ -0,0 +1,21 @@ +#!/bin/sh +# +# Tests incremental conversion of a simple hg repository to git. +# +# 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" diff --git a/tests/hg-single-commit.teardown b/tests/hg-single-commit.teardown new file mode 100755 index 0000000..5a6aa57 --- /dev/null +++ b/tests/hg-single-commit.teardown @@ -0,0 +1,21 @@ +#!/bin/sh +# +# Tests converting a simple hg repository to git. +# +# 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" |