diff options
author | Michał Górny <mgorny@gentoo.org> | 2013-09-25 11:20:12 +0000 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2013-09-25 11:20:12 +0000 |
commit | 51bf47917f3539d9b942f021630a0c03fa6a61e5 (patch) | |
tree | 5968ad4792c911ab176cc670902dbdd47b10ca6f /eclass/tests | |
parent | Support EGIT_REPO_URI being an array. This is needed for tests. (diff) | |
download | historical-51bf47917f3539d9b942f021630a0c03fa6a61e5.tar.gz historical-51bf47917f3539d9b942f021630a0c03fa6a61e5.tar.bz2 historical-51bf47917f3539d9b942f021630a0c03fa6a61e5.zip |
Add minimal fetch+checkout test for git-r3.
Diffstat (limited to 'eclass/tests')
-rwxr-xr-x | eclass/tests/git-r3.sh | 61 | ||||
-rw-r--r-- | eclass/tests/tests-common.sh | 1 |
2 files changed, 62 insertions, 0 deletions
diff --git a/eclass/tests/git-r3.sh b/eclass/tests/git-r3.sh index 4c4a169cd20f..83ad678c73fc 100755 --- a/eclass/tests/git-r3.sh +++ b/eclass/tests/git-r3.sh @@ -55,4 +55,65 @@ test_repouri https://github.com/gentoo/identity.gentoo.org.git gentoo_identity.g #test_repouri git@bitbucket.org:mgorny/python-exec.git mgorny_python-exec.git test_repouri https://mgorny@bitbucket.org/mgorny/python-exec.git mgorny_python-exec.git + +# 2) real repo tests +test_file() { + local message=${1} + local fn=${2} + local expect=${3} + + 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_repo_clean() { + ( + mkdir repo + cd repo + git init -q + echo test > file + git add file + git commit -m 1 -q + echo other-text > file + git add file + git commit -m 2 -q + ) || 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' + ) + + 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 + + cat fetch.log + return 1 +} + +test_repo_clean + texit diff --git a/eclass/tests/tests-common.sh b/eclass/tests/tests-common.sh index 7e3d637255d2..99712f68b864 100644 --- a/eclass/tests/tests-common.sh +++ b/eclass/tests/tests-common.sh @@ -131,3 +131,4 @@ PN="tests" PV="0" P="${PN}-${PV}" PF=${P} +SLOT=0 |