diff options
author | Mike Frysinger <vapier@gentoo.org> | 2012-01-04 08:25:05 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2012-01-04 08:25:05 +0000 |
commit | 54f0468aad22a889c01a46123398ec00fbdd27c9 (patch) | |
tree | 42c074fb5f2717376088a249fc873d1c71698126 /eclass/tests | |
parent | force mtime changes on config files so they get left behind when USE=savedcon... (diff) | |
download | gentoo-2-54f0468aad22a889c01a46123398ec00fbdd27c9.tar.gz gentoo-2-54f0468aad22a889c01a46123398ec00fbdd27c9.tar.bz2 gentoo-2-54f0468aad22a889c01a46123398ec00fbdd27c9.zip |
add tests for savedconfig.eclass:restore_config too
Diffstat (limited to 'eclass/tests')
-rwxr-xr-x | eclass/tests/savedconfig.sh | 91 | ||||
-rw-r--r-- | eclass/tests/tests-common.sh | 10 |
2 files changed, 76 insertions, 25 deletions
diff --git a/eclass/tests/savedconfig.sh b/eclass/tests/savedconfig.sh index 997255150ca9..8149cd33c1ca 100755 --- a/eclass/tests/savedconfig.sh +++ b/eclass/tests/savedconfig.sh @@ -4,28 +4,73 @@ source tests-common.sh inherit savedconfig -sc() { EBUILD_PHASE=install save_config "$@" ; } -rc() { EBUILD_PHASE=prepare restore_config "$@" ; } - -tbegin "simple save_config" -sc $0 >/dev/null -ret=$? -[[ -f ${ED}/etc/portage/savedconfig/${CATEGORY}/${PF} ]] -tend $(( ret + $? )) -rm -rf "${ED}/etc" - -tbegin "multi save_config" -sc *.sh >/dev/null -ret=$? -[[ -d ${ED}/etc/portage/savedconfig/${CATEGORY}/${PF} ]] -tend $(( ret + $? )) -rm -rf "${ED}/etc" - -tbegin "dir save_config" -sc CVS >/dev/null -ret=$? -[[ -d ${ED}/etc/portage/savedconfig/${CATEGORY}/${PF} ]] -tend $(( ret + $? )) -rm -rf "${ED}/etc" +quiet() { + local out ret + out=$("$@" 2>&1) + ret=$? + [[ ${ret} -eq 0 ]] || echo "${out}" + return ${ret} +} +sc() { EBUILD_PHASE=install quiet save_config "$@" ; } +rc() { EBUILD_PHASE=prepare quiet restore_config "$@" ; } + +cleanup() { rm -rf "${ED}"/* "${T}"/* "${WORKDIR}"/* ; } +test-it() { + local ret=0 + tbegin "$@" + mkdir -p "${ED}"/etc/portage/savedconfig + : $(( ret |= $? )) + pushd "${WORKDIR}" >/dev/null + : $(( ret |= $? )) + test + : $(( ret |= $? )) + popd >/dev/null + : $(( ret |= $? )) + tend ${ret} + cleanup +} + +test() { + touch f || return 1 + sc f || return 1 + [[ -f ${ED}/etc/portage/savedconfig/${CATEGORY}/${PF} ]] +} +test-it "simple save_config" + +test() { + touch a b c || return 1 + sc a b c || return 1 + [[ -d ${ED}/etc/portage/savedconfig/${CATEGORY}/${PF} ]] +} +test-it "multi save_config" + +test() { + mkdir dir || return 1 + touch dir/{a,b,c} || return 1 + sc dir || return 1 + [[ -d ${ED}/etc/portage/savedconfig/${CATEGORY}/${PF} ]] +} +test-it "dir save_config" + +PORTAGE_CONFIGROOT=${D} + +test() { + echo "ggg" > f || return 1 + rc f || return 1 + [[ $(<f) == "ggg" ]] +} +test-it "simple restore_config" + +test() { + echo "ggg" > f || return 1 + rc f || return 1 + [[ $(<f) == "ggg" ]] || return 1 + sc f || return 1 + + echo "hhh" > f || return 1 + rc f || return 1 + [[ $(<f) == "ggg" ]] +} +test-it "simple restore+save config" texit diff --git a/eclass/tests/tests-common.sh b/eclass/tests/tests-common.sh index f26b56aa8ef9..9bc5ba61397d 100644 --- a/eclass/tests/tests-common.sh +++ b/eclass/tests/tests-common.sh @@ -8,6 +8,7 @@ inherit() { source ../${e}.eclass done } +EXPORT_FUNCTIONS() { :; } debug-print() { [[ ${#} -eq 0 ]] && return @@ -37,6 +38,7 @@ has() { done return 1 } +use() { has "$1" ${IUSE} ; } die() { echo "die: $*" 1>&2 @@ -107,9 +109,12 @@ t() { } tmpdir="${PWD}/tmp" -D="${tmpdir}/$0/${RANDOM}" +pkg_root="${tmpdir}/$0/${RANDOM}" +T="${pkg_root}/temp" +D="${pkg_root}/image" +WORKDIR="${pkg_root}/work" ED=${D} -mkdir -p "${D}" +mkdir -p "${D}" "${T}" "${WORKDIR}" dodir() { mkdir -p "${@/#/${ED}/}" @@ -117,6 +122,7 @@ dodir() { elog() { einfo "$@" ; } +IUSE="" CATEGORY="dev-eclass" PN="tests" PV="0" |