functions: add test for environment preference

This commit is contained in:
Natanael Copa 2023-04-18 13:13:16 +02:00
parent 6806a0d39b
commit fe26e9483b
1 changed files with 24 additions and 1 deletions

View File

@ -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\""
}