summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--tests/test_env.sh34
2 files changed, 35 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 8725479..a575369 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-*.sh
+/*.sh
*.tar.gz
Kyuafile
copy-modloop
diff --git a/tests/test_env.sh b/tests/test_env.sh
new file mode 100644
index 0000000..6fa3da1
--- /dev/null
+++ b/tests/test_env.sh
@@ -0,0 +1,34 @@
+PATH=$(atf_get_srcdir)/..:$PATH
+
+init_env() {
+ export ROOT=$PWD LIBDIR=$(atf_get_srcdir)/.. MOCK=echo
+}
+
+init_tests() {
+ TESTS="$@"
+ export TESTS
+ for t; do
+ atf_test_case $t
+ done
+}
+
+atf_init_test_cases() {
+ for t in $TESTS; do
+ atf_add_test_case $t
+ done
+}
+
+test_usage() {
+ local prog="$1"
+ init_env
+ atf_check -s exit:0 \
+ -o match:"^usage: $prog" \
+ -e empty \
+ $prog -h
+
+ atf_check -s exit:1 \
+ -o empty \
+ -e match:"^usage: $prog" \
+ $prog -INVALID
+}
+