summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBen Hutchings <ben.hutchings@codethink.co.uk>2020-08-06 19:20:19 +0100
committerBen Hutchings <ben.hutchings@codethink.co.uk>2020-08-10 19:38:24 +0100
commit0a03ee31ac71714e0fed217ad4f047f9ecc4e250 (patch)
treefa21fef3bd7fa6a70bf497776ad0df9fab200171 /tests
parent50383f3bcce75d897760bb2c606ffea865f352da (diff)
downloadlorry-0a03ee31ac71714e0fed217ad4f047f9ecc4e250.tar.gz
tests: Add test case for update counts in the A/B scheme
Diffstat (limited to 'tests')
-rwxr-xr-xtests/repo-update-count.script44
-rwxr-xr-xtests/repo-update-count.setup48
-rw-r--r--tests/repo-update-count.stdout45
-rwxr-xr-xtests/repo-update-count.teardown21
4 files changed, 158 insertions, 0 deletions
diff --git a/tests/repo-update-count.script b/tests/repo-update-count.script
new file mode 100755
index 0000000..db68b12
--- /dev/null
+++ b/tests/repo-update-count.script
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+# Tests update counts in working repositories
+#
+# Copyright (C) 2012-2013, 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
+set -o pipefail
+
+repo_name="update-count-test-repo"
+logfile="$DATADIR/$repo_name.log"
+workdir="$DATADIR/work-dir"
+repo="$DATADIR/$repo_name"
+
+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 "s|$DATADIR|DATADIR|g" "$@"
+}
+
+# update it 3 times, which should write a=1, b=2, a=3
+for i in 1 2 3; do
+ "${SRCDIR}/test-lorry" --pull-only --log="$logfile" --working-area="$workdir" --bundle=never \
+ "$DATADIR/update-count-test-repo.lorry"
+done
+
+find "$workdir/update-count-test-repo" | LC_ALL=C sort | normalize
+grep -H . "$workdir/update-count-test-repo/git"*"/lorry-update-count" | normalize
diff --git a/tests/repo-update-count.setup b/tests/repo-update-count.setup
new file mode 100755
index 0000000..3df1c39
--- /dev/null
+++ b/tests/repo-update-count.setup
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# Tests update counts in working repositories
+#
+# Copyright (C) 2012-2013, 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/update-count-test-repo"
+mkdir "$repo"
+cd "$repo"
+git init --quiet
+
+# add the test file
+echo "first line" > test.txt
+git add test.txt
+
+# make a commit
+git commit --quiet -m "first commit"
+
+# create the .lorry file for the repository
+cat <<EOF > $DATADIR/update-count-test-repo.lorry
+{
+ "update-count-test-repo": {
+ "type": "git",
+ "url": "file://$repo"
+ }
+}
+EOF
+
+# create the working directory
+workdir="$DATADIR/work-dir"
+test -d "$workdir" || mkdir "$workdir"
diff --git a/tests/repo-update-count.stdout b/tests/repo-update-count.stdout
new file mode 100644
index 0000000..6edd8c0
--- /dev/null
+++ b/tests/repo-update-count.stdout
@@ -0,0 +1,45 @@
+DATADIR/work-dir/update-count-test-repo
+DATADIR/work-dir/update-count-test-repo/git-a
+DATADIR/work-dir/update-count-test-repo/git-a/FETCH_HEAD
+DATADIR/work-dir/update-count-test-repo/git-a/HEAD
+DATADIR/work-dir/update-count-test-repo/git-a/branches
+DATADIR/work-dir/update-count-test-repo/git-a/config
+DATADIR/work-dir/update-count-test-repo/git-a/description
+DATADIR/work-dir/update-count-test-repo/git-a/hooks
+DATADIR/work-dir/update-count-test-repo/git-a/info
+DATADIR/work-dir/update-count-test-repo/git-a/info/exclude
+DATADIR/work-dir/update-count-test-repo/git-a/info/refs
+DATADIR/work-dir/update-count-test-repo/git-a/lorry-update-count
+DATADIR/work-dir/update-count-test-repo/git-a/objects
+DATADIR/work-dir/update-count-test-repo/git-a/objects/info
+DATADIR/work-dir/update-count-test-repo/git-a/objects/info/packs
+DATADIR/work-dir/update-count-test-repo/git-a/objects/pack
+DATADIR/work-dir/update-count-test-repo/git-a/objects/pack/pack-file
+DATADIR/work-dir/update-count-test-repo/git-a/objects/pack/pack-file
+DATADIR/work-dir/update-count-test-repo/git-a/packed-refs
+DATADIR/work-dir/update-count-test-repo/git-a/refs
+DATADIR/work-dir/update-count-test-repo/git-a/refs/heads
+DATADIR/work-dir/update-count-test-repo/git-a/refs/tags
+DATADIR/work-dir/update-count-test-repo/git-b
+DATADIR/work-dir/update-count-test-repo/git-b/FETCH_HEAD
+DATADIR/work-dir/update-count-test-repo/git-b/HEAD
+DATADIR/work-dir/update-count-test-repo/git-b/branches
+DATADIR/work-dir/update-count-test-repo/git-b/config
+DATADIR/work-dir/update-count-test-repo/git-b/description
+DATADIR/work-dir/update-count-test-repo/git-b/hooks
+DATADIR/work-dir/update-count-test-repo/git-b/info
+DATADIR/work-dir/update-count-test-repo/git-b/info/exclude
+DATADIR/work-dir/update-count-test-repo/git-b/info/refs
+DATADIR/work-dir/update-count-test-repo/git-b/lorry-update-count
+DATADIR/work-dir/update-count-test-repo/git-b/objects
+DATADIR/work-dir/update-count-test-repo/git-b/objects/info
+DATADIR/work-dir/update-count-test-repo/git-b/objects/info/packs
+DATADIR/work-dir/update-count-test-repo/git-b/objects/pack
+DATADIR/work-dir/update-count-test-repo/git-b/objects/pack/pack-file
+DATADIR/work-dir/update-count-test-repo/git-b/objects/pack/pack-file
+DATADIR/work-dir/update-count-test-repo/git-b/packed-refs
+DATADIR/work-dir/update-count-test-repo/git-b/refs
+DATADIR/work-dir/update-count-test-repo/git-b/refs/heads
+DATADIR/work-dir/update-count-test-repo/git-b/refs/tags
+DATADIR/work-dir/update-count-test-repo/git-a/lorry-update-count:3
+DATADIR/work-dir/update-count-test-repo/git-b/lorry-update-count:2
diff --git a/tests/repo-update-count.teardown b/tests/repo-update-count.teardown
new file mode 100755
index 0000000..b400abf
--- /dev/null
+++ b/tests/repo-update-count.teardown
@@ -0,0 +1,21 @@
+#!/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"