summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2013-09-25 20:52:47 +0000
committerMichał Górny <mgorny@gentoo.org>2013-09-25 20:52:47 +0000
commit0022a9a6969ade69cb2850696c88dc896b62ef4b (patch)
treec1217a5a4a09d2d279702bb2cdfb5fe5c6724ad7 /eclass/tests
parentversion bump (diff)
downloadgentoo-2-0022a9a6969ade69cb2850696c88dc896b62ef4b.tar.gz
gentoo-2-0022a9a6969ade69cb2850696c88dc896b62ef4b.tar.bz2
gentoo-2-0022a9a6969ade69cb2850696c88dc896b62ef4b.zip
Add more simple fetch tests.
Diffstat (limited to 'eclass/tests')
-rwxr-xr-xeclass/tests/git-r3.sh200
1 files changed, 177 insertions, 23 deletions
diff --git a/eclass/tests/git-r3.sh b/eclass/tests/git-r3.sh
index 3ecbd632f405..7d4ce7e049e9 100755
--- a/eclass/tests/git-r3.sh
+++ b/eclass/tests/git-r3.sh
@@ -12,32 +12,41 @@ EGIT3_STORE_DIR=store
mkdir "${EGIT3_STORE_DIR}" || die "unable to mkdir store"
test_file() {
- local message=${1}
- local fn=${2}
- local expect=${3}
+ local fn=${1}
+ local expect=${2}
- tbegin "${message}"
if [[ ! -f ${fn} ]]; then
- tend 1
eerror "${fn} does not exist (not checked out?)"
else
local got=$(<"${fn}")
if [[ ${got} != ${expect} ]]; then
- tend 1
eerror "${fn}, expected: ${expect}, got: ${got}"
else
- tend 0
return 0
fi
fi
return 1
}
+test_no_file() {
+ local fn=${1}
+
+ if [[ -f ${fn} ]]; then
+ eerror "${fn} exists (wtf?!)"
+ else
+ return 0
+ fi
+ return 1
+}
+
test_repo_clean() {
+ local repo=${FUNCNAME#test_}
+ local P=${P}_${repo}
+
(
- mkdir repo
- cd repo
+ mkdir ${repo}
+ cd ${repo}
git init -q
echo test > file
git add file
@@ -48,26 +57,171 @@ test_repo_clean() {
) || die "unable to prepare repo"
# we need to use an array to preserve whitespace
- EGIT_REPO_URI=(
- 'ext::git daemon --export-all --base-path=. --inetd %G/repo'
+ local EGIT_REPO_URI=(
+ "ext::git daemon --export-all --base-path=. --inetd %G/${repo}"
)
tbegin "fetching from a simple repo"
- ( git-r3_fetch ) &> fetch.log
- if tend ${?}; then
- tbegin "checkout of a simple repo"
- ( git-r3_checkout ) &>> fetch.log
- if tend ${?}; then
- test_file "results of checking out a simple repo" \
- "${WORKDIR}/${P}/file" other-text \
- && return 0
- fi
- fi
+ (
+ git-r3_src_unpack
+ test_file "${WORKDIR}/${P}/file" other-text
+ ) &>fetch.log
- cat fetch.log
- return 1
+ eend ${?} || cat fetch.log
+}
+
+test_repo_revert() {
+ local repo=${FUNCNAME#test_}
+ local P=${P}_${repo}
+
+ (
+ mkdir ${repo}
+ cd ${repo}
+ git init -q
+ echo test > file
+ git add file
+ git commit -m 1 -q
+ echo other-text > file2
+ git add file2
+ git commit -m 2 -q
+ git revert -n HEAD^
+ git commit -m 3 -q
+ ) || die "unable to prepare repo"
+
+ # we need to use an array to preserve whitespace
+ local EGIT_REPO_URI=(
+ "ext::git daemon --export-all --base-path=. --inetd %G/${repo}"
+ )
+
+ tbegin "fetching from a repo with reverted commit"
+ (
+ git-r3_src_unpack
+ test_file "${WORKDIR}/${P}/file2" other-text \
+ && test_no_file "${WORKDIR}/${P}/file"
+ ) &>fetch.log
+
+ eend ${?} || cat fetch.log
+}
+
+test_repo_merge() {
+ local repo=${FUNCNAME#test_}
+ local P=${P}_${repo}
+
+ (
+ mkdir ${repo}
+ cd ${repo}
+ git init -q
+ echo test > file
+ git add file
+ git commit -m 1 -q
+ git checkout -q -b other
+ echo other-text > file2
+ git add file2
+ git commit -m 2 -q
+ git checkout -q master
+ echo some-more-text > file
+ git add file
+ git commit -m 3 -q
+ git merge -m 4 -q other
+ ) || die "unable to prepare repo"
+
+ # we need to use an array to preserve whitespace
+ local EGIT_REPO_URI=(
+ "ext::git daemon --export-all --base-path=. --inetd %G/${repo}"
+ )
+
+ tbegin "fetching from a repository with a merge commit"
+ (
+ git-r3_src_unpack
+ test_file "${WORKDIR}/${P}/file" some-more-text \
+ && test_file "${WORKDIR}/${P}/file2" other-text
+ ) &>fetch.log
+
+ eend ${?} || cat fetch.log
+}
+
+test_repo_merge_revert() {
+ local repo=${FUNCNAME#test_}
+ local P=${P}_${repo}
+
+ (
+ mkdir ${repo}
+ cd ${repo}
+ git init -q
+ echo test > file
+ git add file
+ git commit -m 1 -q
+ git checkout -q -b other
+ echo other-text > file2
+ git add file2
+ git commit -m 2 -q
+ git checkout -q master
+ echo some-more-text > file
+ git add file
+ git commit -m 3 -q
+ git merge -m 4 -q other
+ git revert -n -m 1 HEAD
+ git commit -m 5 -q
+ ) || die "unable to prepare repo"
+
+ # we need to use an array to preserve whitespace
+ local EGIT_REPO_URI=(
+ "ext::git daemon --export-all --base-path=. --inetd %G/${repo}"
+ )
+
+ tbegin "fetching from a repository with a reverted merge commit"
+ (
+ git-r3_src_unpack
+ test_file "${WORKDIR}/${P}/file" some-more-text \
+ && test_no_file "${WORKDIR}/${P}/file2"
+ ) &>fetch.log
+
+ eend ${?} || cat fetch.log
+}
+
+test_repo_merge_revert2() {
+ local repo=${FUNCNAME#test_}
+ local P=${P}_${repo}
+
+ (
+ mkdir ${repo}
+ cd ${repo}
+ git init -q
+ echo test > file
+ git add file
+ git commit -m 1 -q
+ git checkout -q -b other
+ echo other-text > file2
+ git add file2
+ git commit -m 2 -q
+ git checkout -q master
+ echo some-more-text > file
+ git add file
+ git commit -m 3 -q
+ git merge -m 4 -q other
+ git revert -n -m 2 HEAD
+ git commit -m 5 -q
+ ) || die "unable to prepare repo"
+
+ # we need to use an array to preserve whitespace
+ local EGIT_REPO_URI=(
+ "ext::git daemon --export-all --base-path=. --inetd %G/${repo}"
+ )
+
+ tbegin "fetching from a repository with a reverted merge commit (other way)"
+ (
+ git-r3_src_unpack
+ test_file "${WORKDIR}/${P}/file" test \
+ && test_file "${WORKDIR}/${P}/file2" other-text
+ ) &>fetch.log
+
+ eend ${?} || cat fetch.log
}
test_repo_clean
+test_repo_revert
+test_repo_merge
+test_repo_merge_revert
+test_repo_merge_revert2
texit