diff options
author | Michał Górny <mgorny@gentoo.org> | 2017-03-11 14:25:42 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2017-03-18 08:33:16 +0100 |
commit | f7a4c94d344b6c73773bf83bd397ba468386e294 (patch) | |
tree | c6f666a98059eae3eb2afabc621f4ef4a89f789e /eclass/tests/estack_evar.sh | |
parent | eutils.eclass: Deprecate validate_desktop_entries (diff) | |
download | gentoo-f7a4c94d344b6c73773bf83bd397ba468386e294.tar.gz gentoo-f7a4c94d344b6c73773bf83bd397ba468386e294.tar.bz2 gentoo-f7a4c94d344b6c73773bf83bd397ba468386e294.zip |
estack.eclass: Split estack* logic from eutils
Split the estack_* and related functions from eutils into a dedicated
estack.eclass. Those functions have significant complexity and are not
used frequently, therefore they benefit from having a separate file
and an explicit dedicated maintainer.
The new eclass is implicitly inherited by eutils to preserve
compatibility. However, the inherit will be removed in EAPI 7,
and the ebuilds should switch to using estack directly.
Thanks to Ulrich Müller for doing the research on this.
Diffstat (limited to 'eclass/tests/estack_evar.sh')
-rwxr-xr-x | eclass/tests/estack_evar.sh | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/eclass/tests/estack_evar.sh b/eclass/tests/estack_evar.sh new file mode 100755 index 000000000000..29badba0079e --- /dev/null +++ b/eclass/tests/estack_evar.sh @@ -0,0 +1,99 @@ +#!/bin/bash +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +source tests-common.sh + +inherit estack + +tbegin "simple push/pop" +VAR=1 +evar_push VAR +pu=$? +VAR=2 +evar_pop +po=$? +[[ ${pu}${po}${VAR} == "001" ]] +tend $? + +tbegin "unset push/pop" +unset VAR +evar_push VAR +pu=$? +VAR=2 +evar_pop +po=$? +[[ ${pu}${po}${VAR+set} == "00" ]] +tend $? + +tbegin "empty push/pop" +VAR= +evar_push VAR +pu=$? +VAR=2 +evar_pop +po=$? +[[ ${pu}${po}${VAR+set}${VAR} == "00set" ]] +tend $? + +tbegin "export push/pop" +export VAR=exported +evar_push VAR +pu=$? +VAR=2 +evar_pop +po=$? +var=$(bash -c 'echo ${VAR}') +[[ ${pu}${po}${var} == "00exported" ]] +tend $? + +tbegin "unexport push/pop" +unset VAR +VAR=not-exported +evar_push VAR +pu=$? +VAR=2 +evar_pop +po=$? +var=$(bash -c 'echo ${VAR+set}') +[[ ${pu}${po}${VAR}${var} == "00not-exported" ]] +tend $? + +tbegin "multi push/pop" +A=a B=b C=c +evar_push A B C +pu=$? +A=A B=B C=C +evar_pop 1 +po1=$? +[[ ${A}${B}${C} == "ABc" ]] +po2=$? +evar_pop 2 +po3=$? +var=$(bash -c 'echo ${VAR+set}') +[[ ${pu}${po1}${po2}${po3}${A}${B}${C} == "0000abc" ]] +tend $? + +tbegin "simple push_set/pop" +VAR=1 +evar_push_set VAR 2 +pu=$? +[[ ${VAR} == "2" ]] +po1=$? +evar_pop +po2=$? +[[ ${pu}${po1}${po2}${VAR} == "0001" ]] +tend $? + +tbegin "unset push_set/pop" +VAR=1 +evar_push_set VAR +pu=$? +[[ ${VAR+set} != "set" ]] +po1=$? +evar_pop +po2=$? +[[ ${pu}${po1}${po2}${VAR} == "0001" ]] +tend $? + +texit |