From: Mike Frysinger Date: Wed, 4 Jan 2012 06:18:51 +0000 (+0000) Subject: add tests for savedconfig.eclass:save_config() X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c250f07381f6c223845f7e75e3aa45d868716c04;p=gentoo.git add tests for savedconfig.eclass:save_config() --- diff --git a/eclass/tests/savedconfig.sh b/eclass/tests/savedconfig.sh new file mode 100755 index 000000000000..997255150ca9 --- /dev/null +++ b/eclass/tests/savedconfig.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +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" + +texit diff --git a/eclass/tests/tests-common.sh b/eclass/tests/tests-common.sh index c976e29aee56..f26b56aa8ef9 100644 --- a/eclass/tests/tests-common.sh +++ b/eclass/tests/tests-common.sh @@ -93,6 +93,7 @@ tbegin() { ebegin "Testing $*" } texit() { + rm -rf "${tmpdir}" exit ${tret} } tend() { @@ -104,3 +105,20 @@ t() { : $(( tret |= ${ret} )) return ${ret} } + +tmpdir="${PWD}/tmp" +D="${tmpdir}/$0/${RANDOM}" +ED=${D} +mkdir -p "${D}" + +dodir() { + mkdir -p "${@/#/${ED}/}" +} + +elog() { einfo "$@" ; } + +CATEGORY="dev-eclass" +PN="tests" +PV="0" +P="${PN}-${PV}" +PF=${P}