aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-04-27 18:35:07 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-04-27 18:35:07 +0100
commit23138200aca0fa30d285c7b5cf84db69498c1238 (patch)
tree27f60f359eba34eba5d6eddfff829b9c4416c331
parenta950df5854eef2dc6286deec2931d0d68f9a7b92 (diff)
downloadpaludis-23138200aca0fa30d285c7b5cf84db69498c1238.tar.gz
paludis-23138200aca0fa30d285c7b5cf84db69498c1238.tar.xz
illegal_in_global_scope
-rw-r--r--paludis/repositories/e/e_repository_TEST_exlibs.cc2
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_exlibs_setup.sh30
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash7
3 files changed, 39 insertions, 0 deletions
diff --git a/paludis/repositories/e/e_repository_TEST_exlibs.cc b/paludis/repositories/e/e_repository_TEST_exlibs.cc
index 1dbead3..c1e3f70 100644
--- a/paludis/repositories/e/e_repository_TEST_exlibs.cc
+++ b/paludis/repositories/e/e_repository_TEST_exlibs.cc
@@ -193,5 +193,7 @@ namespace test_cases
ExlibsTest test_noarray_bad("noarray-bad", throws_UnsupportedActionError);
ExlibsTest test_scalar_required("scalar-required", throws_UnsupportedActionError);
ExlibsTest test_array_required("array-required", throws_UnsupportedActionError);
+ ExlibsTest test_illegal_in_global_scope("illegal-in-global-scope", throws_UnsupportedActionError);
+ ExlibsTest test_illegal_in_global_scope_in_func("illegal-in-global-scope-in-func", success);
}
diff --git a/paludis/repositories/e/e_repository_TEST_exlibs_setup.sh b/paludis/repositories/e/e_repository_TEST_exlibs_setup.sh
index 4b1b476..250c5f0 100755
--- a/paludis/repositories/e/e_repository_TEST_exlibs_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_exlibs_setup.sh
@@ -415,6 +415,36 @@ pkg_setup() {
[[ ${SUMMARY} == "baz" ]] || die "Bad SUMMARY"
}
END
+mkdir -p "packages/cat/illegal-in-global-scope"
+cat <<'END' > packages/cat/illegal-in-global-scope/illegal-in-global-scope-1.ebuild || exit 1
+DESCRIPTION="The Long Description"
+SUMMARY="The Short Description"
+HOMEPAGE="http://example.com/"
+SLOT="0"
+LICENCES="GPL-2"
+
+f() {
+ illegal_in_global_scope
+}
+
+f
+END
+mkdir -p "packages/cat/illegal-in-global-scope-in-func"
+cat <<'END' > packages/cat/illegal-in-global-scope-in-func/illegal-in-global-scope-in-func-1.ebuild || exit 1
+DESCRIPTION="The Long Description"
+SUMMARY="The Short Description"
+HOMEPAGE="http://example.com/"
+SLOT="0"
+LICENCES="GPL-2"
+
+f() {
+ illegal_in_global_scope
+}
+
+pkg_setup() {
+ f
+}
+END
cd ..
cd ..
diff --git a/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash b/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash
index 769a9cd..fc690e3 100644
--- a/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/exlib_functions.bash
@@ -231,3 +231,10 @@ default()
die "default_$(paludis_phase_to_function_name "${!PALUDIS_EBUILD_PHASE_VAR}") is not a function"
default_$(paludis_phase_to_function_name "${!PALUDIS_EBUILD_PHASE_VAR}") "$@"
}
+
+illegal_in_global_scope()
+{
+ [[ "${!PALUDIS_EBUILD_PHASE_VAR}" == "metadata" ]] \
+ && die "Exheres bug: ${FUNCNAME[1]} must not be called in global scope"
+}
+