add tests for savedconfig.eclass:save_config()
authorMike Frysinger <vapier@gentoo.org>
Wed, 4 Jan 2012 06:18:51 +0000 (06:18 +0000)
committerMike Frysinger <vapier@gentoo.org>
Wed, 4 Jan 2012 06:18:51 +0000 (06:18 +0000)
eclass/tests/savedconfig.sh [new file with mode: 0755]
eclass/tests/tests-common.sh

diff --git a/eclass/tests/savedconfig.sh b/eclass/tests/savedconfig.sh
new file mode 100755 (executable)
index 0000000..9972551
--- /dev/null
@@ -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
index c976e29aee56f3773e5a7b1b1c0205ae05fedfb2..f26b56aa8ef9dadcc3fcb7ebda0bf2c7c1b6dc43 100644 (file)
@@ -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}