From fe26e9483b52192d704ea85e28e09184b6ccbc75 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Tue, 18 Apr 2023 13:13:16 +0200 Subject: [PATCH] functions: add test for environment preference --- tests/functions_test | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/functions_test b/tests/functions_test index c58e47a..06cba40 100755 --- a/tests/functions_test +++ b/tests/functions_test @@ -6,7 +6,8 @@ init_tests \ funcs_check_missing_gcc \ funcs_check_missing_apk \ funcs_check_missing_git \ - funcs_check_env_set_but_empty + funcs_check_env_set_but_empty \ + funcs_check_defconfig FUNCS=$(atf_get_srcdir)/../functions.sh @@ -53,3 +54,25 @@ funcs_check_env_set_but_empty_body() { done done } + +funcs_check_defconfig_body() { + echo "CFLAGS=syscflags" > etc.conf + echo "CFLAGS=usercflags" > user.conf + + # test /etc/abuild.conf + ABUILD_CONF="$PWD"/etc.conf atf_check \ + -o match:"syscflags" \ + sh -e -c " . $FUNCS; echo \"\$CFLAGS\"" + + # user config ($HOME/.abuild/abuild.conf) wins over /etc/abuild.conf + ABUILD_CONF="$PWD/etc.conf" ABUILD_USERCONF="$PWD/user.conf" \ + atf_check \ + -o match:"usercflags" \ + sh -e -c " . $FUNCS; echo \"\$CFLAGS\"" + + # environment wins + ABUILD_CONF="$PWD/etc.conf" ABUILD_USERCONF="$PWD/user.conf" \ + CFLAGS="envcflags" atf_check \ + -o match:"envcflags" \ + sh -e -c " . $FUNCS; echo \"\$CFLAGS\"" +}