From 25bd327ad06d0497e9888ebc7c4bbbd6cab11f12 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 27 May 2013 22:54:50 -0600 Subject: fix a bug in conf.sh (from the get_files->list_files switch), add unit test --- src/lib/conf.sh | 2 +- test/lib-conf-test.sh | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/lib-conf-test.sh diff --git a/src/lib/conf.sh b/src/lib/conf.sh index 8e8610e..07780ee 100644 --- a/src/lib/conf.sh +++ b/src/lib/conf.sh @@ -107,7 +107,7 @@ get_conf_makepkg() ( set_conf_makepkg() { local key=$1 local val=$2 - for file in $(list_files makepkg.conf|tac); do + for file in $(list_files makepkg|tac); do if [[ -w $file ]]; then sed -i "/^\s*$key=/d" "$file" echo "$key='$val'" >> "$file" diff --git a/test/lib-conf-test.sh b/test/lib-conf-test.sh new file mode 100644 index 0000000..bb6b285 --- /dev/null +++ b/test/lib-conf-test.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env roundup + +describe lib/conf.sh + +before() { + tmpdir=$(mktemp -d --tmpdir test-conf.sh.XXXXXXXXXXXX) + stat=0 +} + +after() { + rm -rf -- "$tmpdir" "$XDG_CACHE_HOME" "$XDG_CONFIG_HOME" +} + + +it_sets_makepkg_vars_in_custom_file() { + unset PKGDEST + touch "$tmpdir/makepkg.conf" + . $(librelib conf.sh) + MAKEPKG_CONF="$tmpdir/makepkg.conf" set_conf_makepkg PKGDEST /pkgdest + . "$tmpdir/makepkg.conf" + [[ $PKGDEST == /pkgdest ]] +} -- cgit v1.2.3-54-g00ecf