summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Brown <ben.brown@codethink.co.uk>2020-09-17 17:20:22 +0000
committerBen Brown <ben.brown@codethink.co.uk>2020-09-17 17:20:22 +0000
commit641ebd75f9868753ba472e780062a7f2aed5abbb (patch)
treefcb367793cdeb557df5bd4436076272dedcef3d4
parentc356e375704e3951a6fa7db1097cef6182383047 (diff)
parent6d5fb6dbde1781fd74c0f7313024871003a5312b (diff)
downloadlorry-641ebd75f9868753ba472e780062a7f2aed5abbb.tar.gz
Merge branch 'bwh/cvs-use-worktree' into 'master'
Use a working tree in gitify_cvs Closes #12 See merge request CodethinkLabs/lorry/lorry!19
-rwxr-xr-xlorry62
-rwxr-xr-xtests/bzr-single-commit.script2
-rwxr-xr-xtests/cvs-incremental.script77
-rwxr-xr-xtests/cvs-incremental.setup65
-rw-r--r--tests/cvs-incremental.stdout53
-rwxr-xr-xtests/cvs-single-commit.script3
-rw-r--r--tests/cvs-single-commit.stdout1
-rwxr-xr-xtests/extended-headers-ignored.script2
-rwxr-xr-xtests/git-backup-on-error-multiple-backups.teardown21
-rwxr-xr-xtests/git-backup-on-error-single-backup-is-removed-if-exists.teardown21
-rwxr-xr-xtests/git-backup-on-error-single-backup.teardown21
-rwxr-xr-xtests/git-single-commit.script2
-rwxr-xr-xtests/hg-incremental.script4
-rwxr-xr-xtests/hg-incremental.teardown21
-rwxr-xr-xtests/hg-single-commit.script2
-rwxr-xr-xtests/hg-single-commit.teardown21
-rwxr-xr-xtests/hg-unnamed-head.script4
-rwxr-xr-xtests/hg-unnamed-head.teardown21
-rwxr-xr-xtests/make-tarball.script2
-rwxr-xr-xtests/migrate-oldstyle-repos.teardown21
-rwxr-xr-xtests/repo-update-count.teardown21
-rwxr-xr-xtests/svn-single-commit.script2
-rwxr-xr-xtests/tar-single-commit.script2
-rwxr-xr-xtests/teardown7
24 files changed, 271 insertions, 187 deletions
diff --git a/lorry b/lorry
index 524ed2c..81fdeb3 100755
--- a/lorry
+++ b/lorry
@@ -676,20 +676,68 @@ class Lorry(cliapp.Application):
self.run_program(['git', 'svn', 'fetch'], cwd=gitdir)
def gitify_cvs(self, project_name, dirname, gitdir, spec):
+ # git cvsimport requires a working tree for some operations;
+ # keep this separate from the repository
+ worktree = os.path.join(dirname, 'git-cvs-worktree')
+
+ if os.path.exists(gitdir):
+ if os.path.exists(worktree):
+ shutil.rmtree(worktree)
+ self.run_program(['git', 'worktree', 'prune'],
+ cwd=gitdir)
+ self.run_program(['git', 'worktree', 'add', worktree, 'master'],
+ cwd=gitdir)
+
+ # git cvsimport insists on $GIT_DIR or .git being a
+ # directory, but .git will be a file. Set $GIT_DIR to
+ # the subdirectory of gitdir created for this worktree.
+ cvsimp_gitdir = self.runcmd(['git', 'rev-parse', '--git-dir'],
+ cwd=worktree) \
+ .decode('utf-8') \
+ .rstrip('\n')
+
+ # cvsps should find its cache under gitdir, not the
+ # temporary worktree
+ cvsps_home = gitdir
+ else:
+ # We must let git cvsimport create the repository
+ cvsimp_gitdir = os.path.join(worktree, '.git')
+
+ # cvsps should create its cache there, and it will be
+ # moved to gitdir later
+ cvsps_home = cvsimp_gitdir
+
self.needs_aggressive = True
env = dict(os.environ)
env['CVS_RSH'] = 'lorry-ssh-wrapper'
- env['GIT_DIR'] = gitdir
+ env['GIT_DIR'] = cvsimp_gitdir
+ env['HOME'] = cvsps_home
self.run_program(
['git', 'cvsimport', '-a', '-d', spec['url'],
- '-i', spec['module']],
+ '-C', worktree, spec['module']],
env=env)
- # git cvsimport may create an index even in a bare repo
- try:
- os.remove(os.path.join(gitdir, 'index'))
- except FileNotFoundError:
- pass
+ if not os.path.exists(gitdir):
+ # git cvsimport created a non-bare repository; convert it
+ # to bare
+ os.rename(cvsimp_gitdir, gitdir)
+ self.run_program(['git', 'config', 'core.bare', 'true'],
+ cwd=gitdir)
+ self.run_program(['git', 'config', 'core.logallrefupdates',
+ 'false'],
+ cwd=gitdir)
+ try:
+ os.remove(os.path.join(gitdir, 'index'))
+ except FileNotFoundError:
+ pass
+ try:
+ shutil.rmtree(os.path.join(gitdir, 'logs'))
+ except FileNotFoundError:
+ pass
+
+ shutil.rmtree(worktree)
+ self.run_program(['git', 'worktree', 'prune'],
+ cwd=gitdir)
def gitify_hg(self, project_name, dirname, gitdir, spec):
cert_options = []
diff --git a/tests/bzr-single-commit.script b/tests/bzr-single-commit.script
index 80b9d99..0f7895e 100755
--- a/tests/bzr-single-commit.script
+++ b/tests/bzr-single-commit.script
@@ -25,7 +25,7 @@ logfile="$DATADIR/bzr-test-repo.log"
workdir="$DATADIR/work-dir"
"${SRCDIR}/test-lorry" --pull-only --log="$logfile" --working-area="$workdir" \
- "$DATADIR/bzr-test-repo.lorry" > /dev/null 2> /dev/null
+ "$DATADIR/bzr-test-repo.lorry" > /dev/null
# verify that the git repository was set up correctly
(
diff --git a/tests/cvs-incremental.script b/tests/cvs-incremental.script
new file mode 100755
index 0000000..0a487a0
--- /dev/null
+++ b/tests/cvs-incremental.script
@@ -0,0 +1,77 @@
+#!/bin/sh
+#
+# Tests converting a simple CVS 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
+
+logfile="$DATADIR/cvs-test-repo.log"
+workdir="$DATADIR/work-dir"
+workingcopy="$DATADIR/cvs-test-checkout"
+
+repo="$DATADIR/cvs-test-repo"
+export CVSROOT="$repo"
+
+normalize() {
+ sed -r -e '/hooks\/.*\.sample/d' \
+ -e "s/pack-[0-9a-z]+\.(idx|pack)$/pack-file/" \
+ -e "/\/objects\/info\/commit-graph$/d" \
+ -e "/\/objects\/pack\/pack-[0-9a-z]+\.bitmap$/d" \
+ -e "/\/\.cvsps\//d" \
+ -e "s|$DATADIR|DATADIR|g" "$@"
+}
+
+# CVS wants $USER, $LOGNAME, and $LOGNAME set to a real username.
+export USER=root
+export LOGNAME=$USER
+export USERNAME=$USER
+
+"${SRCDIR}/test-lorry" --pull-only --log="$logfile" --working-area="$workdir" \
+ "$DATADIR/cvs-test-repo.lorry" > /dev/null
+
+(
+ cd "$workingcopy/CVSROOT"
+
+ # ensure that this commit has a later timestamp than the last one
+ sleep 1
+
+ # append to the test file
+ echo "second line" >> test.txt
+
+ # make a commit
+ cvs -Q commit -m "second commit"
+)
+
+"${SRCDIR}/test-lorry" --pull-only --log="$logfile" --working-area="$workdir" \
+ "$DATADIR/cvs-test-repo.lorry" > /dev/null
+
+# verify that the git repository was created successfully
+(
+ cd "$workdir/cvs-test-repo/git-b/"
+
+ echo "branches:"
+ git show-ref | cut -d' ' -f2 | LC_ALL=C sort
+
+ echo "test file:"
+ git cat-file blob master:test.txt
+
+ echo "commit messages:"
+ git log --pretty='%s' master
+)
+
+find "$workdir/cvs-test-repo" | LC_ALL=C sort | normalize
diff --git a/tests/cvs-incremental.setup b/tests/cvs-incremental.setup
new file mode 100755
index 0000000..fee3eac
--- /dev/null
+++ b/tests/cvs-incremental.setup
@@ -0,0 +1,65 @@
+#!/bin/sh
+#
+# Creates a CVS repository with a single file and a single commit.
+#
+# 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
+
+# CVS wants $USER, $LOGNAME, and $LOGNAME set to a real username.
+export USER=root
+export LOGNAME=$USER
+export USERNAME=$USER
+
+# create the repository
+repo="$DATADIR/cvs-test-repo"
+export CVSROOT="$repo"
+export CVS_RSH=
+cvs init
+
+# create a local working copy
+workingcopy="$DATADIR/cvs-test-checkout"
+mkdir "$workingcopy"
+cd "$workingcopy"
+cvs checkout CVSROOT
+cd "$workingcopy/CVSROOT"
+
+# ensure that our commit has a later timestamp than cvs init's
+# "initial checkin"
+sleep 1
+
+# add the test file
+echo "first line" > test.txt
+cvs -Q add test.txt
+
+# make a commit
+cvs -Q commit -m "first commit"
+
+# create the .lorry file for the repository
+cat <<EOF > $DATADIR/cvs-test-repo.lorry
+{
+ "cvs-test-repo": {
+ "type": "cvs",
+ "url": "$repo",
+ "module": "CVSROOT"
+ }
+}
+EOF
+
+
+# create the working directory
+test -d "$DATADIR/work-dir" || mkdir "$DATADIR/work-dir"
diff --git a/tests/cvs-incremental.stdout b/tests/cvs-incremental.stdout
new file mode 100644
index 0000000..122d75c
--- /dev/null
+++ b/tests/cvs-incremental.stdout
@@ -0,0 +1,53 @@
+branches:
+refs/heads/master
+refs/heads/origin
+test file:
+first line
+second line
+commit messages:
+second commit
+first commit
+initial checkin
+DATADIR/work-dir/cvs-test-repo
+DATADIR/work-dir/cvs-test-repo/git-a
+DATADIR/work-dir/cvs-test-repo/git-a/.cvsps
+DATADIR/work-dir/cvs-test-repo/git-a/HEAD
+DATADIR/work-dir/cvs-test-repo/git-a/branches
+DATADIR/work-dir/cvs-test-repo/git-a/config
+DATADIR/work-dir/cvs-test-repo/git-a/description
+DATADIR/work-dir/cvs-test-repo/git-a/hooks
+DATADIR/work-dir/cvs-test-repo/git-a/info
+DATADIR/work-dir/cvs-test-repo/git-a/info/exclude
+DATADIR/work-dir/cvs-test-repo/git-a/info/refs
+DATADIR/work-dir/cvs-test-repo/git-a/lorry-update-count
+DATADIR/work-dir/cvs-test-repo/git-a/objects
+DATADIR/work-dir/cvs-test-repo/git-a/objects/info
+DATADIR/work-dir/cvs-test-repo/git-a/objects/info/packs
+DATADIR/work-dir/cvs-test-repo/git-a/objects/pack
+DATADIR/work-dir/cvs-test-repo/git-a/objects/pack/pack-file
+DATADIR/work-dir/cvs-test-repo/git-a/objects/pack/pack-file
+DATADIR/work-dir/cvs-test-repo/git-a/packed-refs
+DATADIR/work-dir/cvs-test-repo/git-a/refs
+DATADIR/work-dir/cvs-test-repo/git-a/refs/heads
+DATADIR/work-dir/cvs-test-repo/git-a/refs/tags
+DATADIR/work-dir/cvs-test-repo/git-b
+DATADIR/work-dir/cvs-test-repo/git-b/.cvsps
+DATADIR/work-dir/cvs-test-repo/git-b/HEAD
+DATADIR/work-dir/cvs-test-repo/git-b/branches
+DATADIR/work-dir/cvs-test-repo/git-b/config
+DATADIR/work-dir/cvs-test-repo/git-b/description
+DATADIR/work-dir/cvs-test-repo/git-b/hooks
+DATADIR/work-dir/cvs-test-repo/git-b/info
+DATADIR/work-dir/cvs-test-repo/git-b/info/exclude
+DATADIR/work-dir/cvs-test-repo/git-b/info/refs
+DATADIR/work-dir/cvs-test-repo/git-b/lorry-update-count
+DATADIR/work-dir/cvs-test-repo/git-b/objects
+DATADIR/work-dir/cvs-test-repo/git-b/objects/info
+DATADIR/work-dir/cvs-test-repo/git-b/objects/info/packs
+DATADIR/work-dir/cvs-test-repo/git-b/objects/pack
+DATADIR/work-dir/cvs-test-repo/git-b/objects/pack/pack-file
+DATADIR/work-dir/cvs-test-repo/git-b/objects/pack/pack-file
+DATADIR/work-dir/cvs-test-repo/git-b/packed-refs
+DATADIR/work-dir/cvs-test-repo/git-b/refs
+DATADIR/work-dir/cvs-test-repo/git-b/refs/heads
+DATADIR/work-dir/cvs-test-repo/git-b/refs/tags
diff --git a/tests/cvs-single-commit.script b/tests/cvs-single-commit.script
index a0639ba..ba31111 100755
--- a/tests/cvs-single-commit.script
+++ b/tests/cvs-single-commit.script
@@ -28,6 +28,7 @@ normalize() {
-e "s/pack-[0-9a-z]+\.(idx|pack)$/pack-file/" \
-e "/\/objects\/info\/commit-graph$/d" \
-e "/\/objects\/pack\/pack-[0-9a-z]+\.bitmap$/d" \
+ -e "/\/\.cvsps\//d" \
-e "s|$DATADIR|DATADIR|g" "$@"
}
@@ -37,7 +38,7 @@ export LOGNAME=$USER
export USERNAME=$USER
"${SRCDIR}/test-lorry" --pull-only --log="$logfile" --working-area="$workdir" \
- "$DATADIR/cvs-test-repo.lorry" > /dev/null 2> /dev/null
+ "$DATADIR/cvs-test-repo.lorry" > /dev/null
# verify that the git repository was created successfully
(
diff --git a/tests/cvs-single-commit.stdout b/tests/cvs-single-commit.stdout
index 6938eda..1a14972 100644
--- a/tests/cvs-single-commit.stdout
+++ b/tests/cvs-single-commit.stdout
@@ -8,6 +8,7 @@ first commit
initial checkin
DATADIR/work-dir/cvs-test-repo
DATADIR/work-dir/cvs-test-repo/git-a
+DATADIR/work-dir/cvs-test-repo/git-a/.cvsps
DATADIR/work-dir/cvs-test-repo/git-a/HEAD
DATADIR/work-dir/cvs-test-repo/git-a/branches
DATADIR/work-dir/cvs-test-repo/git-a/config
diff --git a/tests/extended-headers-ignored.script b/tests/extended-headers-ignored.script
index dcc01fc..04ceacd 100755
--- a/tests/extended-headers-ignored.script
+++ b/tests/extended-headers-ignored.script
@@ -31,7 +31,7 @@ logfile="$DATADIR/extended-headers-ignored-test-repo.log"
workdir="$DATADIR/work-dir"
"${SRCDIR}/test-lorry" --pull-only --log="$logfile" --working-area="$workdir" \
- "$DATADIR/extended-headers-ignored-test.lorry" > /dev/null 2> /dev/null
+ "$DATADIR/extended-headers-ignored-test.lorry" > /dev/null
repodst="$DATADIR/extended-headers"
git clone "$workdir/extended-headers-test-repo/git-a" "$repodst" >/dev/null 2>&1
diff --git a/tests/git-backup-on-error-multiple-backups.teardown b/tests/git-backup-on-error-multiple-backups.teardown
deleted file mode 100755
index 8b5bef3..0000000
--- a/tests/git-backup-on-error-multiple-backups.teardown
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-#
-# Tests when a git mirror fails that it keeps the backups around
-#
-# Copyright (C) 2012-2013 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 -r "$DATADIR/git-backup-test-repo.log" "$DATADIR/work-dir"
diff --git a/tests/git-backup-on-error-single-backup-is-removed-if-exists.teardown b/tests/git-backup-on-error-single-backup-is-removed-if-exists.teardown
deleted file mode 100755
index 8b5bef3..0000000
--- a/tests/git-backup-on-error-single-backup-is-removed-if-exists.teardown
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-#
-# Tests when a git mirror fails that it keeps the backups around
-#
-# Copyright (C) 2012-2013 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 -r "$DATADIR/git-backup-test-repo.log" "$DATADIR/work-dir"
diff --git a/tests/git-backup-on-error-single-backup.teardown b/tests/git-backup-on-error-single-backup.teardown
deleted file mode 100755
index 8b5bef3..0000000
--- a/tests/git-backup-on-error-single-backup.teardown
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-#
-# Tests when a git mirror fails that it keeps the backups around
-#
-# Copyright (C) 2012-2013 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 -r "$DATADIR/git-backup-test-repo.log" "$DATADIR/work-dir"
diff --git a/tests/git-single-commit.script b/tests/git-single-commit.script
index 9c4813e..80d117c 100755
--- a/tests/git-single-commit.script
+++ b/tests/git-single-commit.script
@@ -25,7 +25,7 @@ logfile="$DATADIR/git-test-repo.log"
workdir="$DATADIR/work-dir"
"${SRCDIR}/test-lorry" --pull-only --log="$logfile" --working-area="$workdir" \
- "$DATADIR/git-test-repo.lorry" > /dev/null 2> /dev/null
+ "$DATADIR/git-test-repo.lorry" > /dev/null
# verify that the git repository was set up correctly
(
diff --git a/tests/hg-incremental.script b/tests/hg-incremental.script
index 489efa7..b8ad73c 100755
--- a/tests/hg-incremental.script
+++ b/tests/hg-incremental.script
@@ -26,7 +26,7 @@ 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
+ "$DATADIR/hg-test-repo.lorry" > /dev/null
# make a second commit
(
@@ -36,7 +36,7 @@ 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
+ "$DATADIR/hg-test-repo.lorry" > /dev/null
# verify that the git repository was created correctly
(
diff --git a/tests/hg-incremental.teardown b/tests/hg-incremental.teardown
deleted file mode 100755
index 409c26b..0000000
--- a/tests/hg-incremental.teardown
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/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.script b/tests/hg-single-commit.script
index 0b95dc9..6fc3ca1 100755
--- a/tests/hg-single-commit.script
+++ b/tests/hg-single-commit.script
@@ -25,7 +25,7 @@ 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
+ "$DATADIR/hg-test-repo.lorry" > /dev/null
# verify that the git repository was created correctly
(
diff --git a/tests/hg-single-commit.teardown b/tests/hg-single-commit.teardown
deleted file mode 100755
index 5a6aa57..0000000
--- a/tests/hg-single-commit.teardown
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/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"
diff --git a/tests/hg-unnamed-head.script b/tests/hg-unnamed-head.script
index 1811645..d3047e4 100755
--- a/tests/hg-unnamed-head.script
+++ b/tests/hg-unnamed-head.script
@@ -25,7 +25,7 @@ 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
+ "$DATADIR/hg-test-repo.lorry" > /dev/null
grep -o 'pruned [0-9]* unreachable commit' < "$logfile" || true
# verify that the git repository was created correctly
@@ -48,5 +48,5 @@ grep -o 'pruned [0-9]* unreachable commit' < "$logfile" || true
# 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
+ "$DATADIR/hg-test-repo.lorry" > /dev/null
grep -o 'pruned [0-9]* unreachable commit' < "$logfile"
diff --git a/tests/hg-unnamed-head.teardown b/tests/hg-unnamed-head.teardown
deleted file mode 100755
index 8b8cee1..0000000
--- a/tests/hg-unnamed-head.teardown
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/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"
diff --git a/tests/make-tarball.script b/tests/make-tarball.script
index 46618cd..3edecb2 100755
--- a/tests/make-tarball.script
+++ b/tests/make-tarball.script
@@ -25,7 +25,7 @@ workdir="$DATADIR/work-dir"
"${SRCDIR}/test-lorry" --pull-only --log="$logfile" --working-area="$workdir" \
--tarball=first --mirror-base-url-fetch="file://non-existent-url" \
- "$DATADIR/make-tarball-repo.lorry" > /dev/null 2> /dev/null
+ "$DATADIR/make-tarball-repo.lorry" > /dev/null
# verify that we can see the tarball generated of the git tree
diff --git a/tests/migrate-oldstyle-repos.teardown b/tests/migrate-oldstyle-repos.teardown
deleted file mode 100755
index 19d1cb1..0000000
--- a/tests/migrate-oldstyle-repos.teardown
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-#
-# Tests migration of old-style working repositories
-#
-# 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 -r "$DATADIR/migrate-test-repo.log" "$DATADIR/work-dir"
diff --git a/tests/repo-update-count.teardown b/tests/repo-update-count.teardown
deleted file mode 100755
index b400abf..0000000
--- a/tests/repo-update-count.teardown
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-#
-# Tests update counts in working repositories
-#
-# 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 -r "$DATADIR/update-count-test-repo.log" "$DATADIR/work-dir"
diff --git a/tests/svn-single-commit.script b/tests/svn-single-commit.script
index 7ae2eb9..ff1cc70 100755
--- a/tests/svn-single-commit.script
+++ b/tests/svn-single-commit.script
@@ -33,7 +33,7 @@ normalize() {
}
"${SRCDIR}/test-lorry" --pull-only --log="$logfile" --working-area="$workdir" \
- "$DATADIR/svn-test-repo.lorry" > /dev/null 2> /dev/null
+ "$DATADIR/svn-test-repo.lorry" > /dev/null
# verify that the git repository was created successfully
(
diff --git a/tests/tar-single-commit.script b/tests/tar-single-commit.script
index 4d91417..3204a0c 100755
--- a/tests/tar-single-commit.script
+++ b/tests/tar-single-commit.script
@@ -24,7 +24,7 @@ logfile="$DATADIR/tar-single-commit.log"
workdir="$DATADIR/work-dir"
"${SRCDIR}/test-lorry" --pull-only --log="$logfile" --working-area="$workdir" \
- "$DATADIR/tar-test-repo.lorry" > /dev/null 2> /dev/null
+ "$DATADIR/tar-test-repo.lorry" > /dev/null
# verify that the git repositories were created successfully
for FORMAT in "gzip" "bzip2" "lzma"; do
diff --git a/tests/teardown b/tests/teardown
new file mode 100755
index 0000000..c821266
--- /dev/null
+++ b/tests/teardown
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -e
+
+# Delete everything under $DATADIR except git-upstream
+find "$DATADIR" -mindepth 1 -maxdepth 1 \! -path "$DATADIR/git-upstream" \
+ -exec rm -rf {} \+