summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid P <megver83@parabola.nu>2017-07-29 21:59:30 -0400
committerDavid P <megver83@parabola.nu>2017-07-29 21:59:30 -0400
commit5e9742f03e4199c006b0f9d0d8069a2fb41d9258 (patch)
treec5e7c30625b30b50a2a2385ef934c1d7e57eb2fa /test
parent63f4ac3c0a6ea7e060720b63964cf158157fc785 (diff)
parent0b8606e0cd0e1aedfe222d4d6603c4986aacb7b5 (diff)
Merge branch 'master' of ssh://git.parabola.nu:1863/~git/packages/libretoolsHEADmaster
Diffstat (limited to 'test')
-rw-r--r--test/librechroot-test.sh11
-rw-r--r--test/librexgettext-test.sh58
-rw-r--r--test/librexgettext.d/.gitignore1
-rw-r--r--test/librexgettext.d/combine.pot15
-rw-r--r--test/librexgettext.d/combine1.sh5
-rw-r--r--test/librexgettext.d/combine2.sh5
-rw-r--r--test/librexgettext.d/it_fails_on_missing_final_flag_description.sh4
-rw-r--r--test/librexgettext.d/it_fails_on_subshell_flag_descriptions.sh7
-rw-r--r--test/librexgettext.d/it_handles_librefetch_flags.pot40
-rw-r--r--test/librexgettext.d/it_handles_librefetch_flags.sh15
-rw-r--r--test/librexgettext.d/it_handles_multiple_skipped_flags.pot58
-rw-r--r--test/librexgettext.d/it_handles_multiple_skipped_flags.sh17
-rw-r--r--test/librexgettext.d/it_handles_zero_flags.pot0
-rw-r--r--test/librexgettext.d/it_handles_zero_flags.sh4
-rwxr-xr-xtest/testenv3
15 files changed, 242 insertions, 1 deletions
diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh
index d225834..42d4803 100644
--- a/test/librechroot-test.sh
+++ b/test/librechroot-test.sh
@@ -82,6 +82,17 @@ it_displays_help_and_fails_with_0_args() {
[[ "$(sed -n 2p $tmpdir/stderr)" =~ Usage:.* ]]
}
+it_obeys_the_n_flag() {
+ require network sudo || return 0
+
+ not test -f "$chrootdir/$roundup_test_name/$roundup_test_name/$roundup_test_name.stamp"
+
+ libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
+ testsudo librechroot -n "$roundup_test_name" -l "$roundup_test_name" run touch /"$roundup_test_name.stamp"
+
+ test -f "$chrootdir/$roundup_test_name/$roundup_test_name/$roundup_test_name.stamp"
+}
+
# requires sudo so we know it's not failing because it needs root
it_fails_for_unknown_commands() {
require sudo || return 0
diff --git a/test/librexgettext-test.sh b/test/librexgettext-test.sh
new file mode 100644
index 0000000..f9a0031
--- /dev/null
+++ b/test/librexgettext-test.sh
@@ -0,0 +1,58 @@
+#!/usr/bin/env roundup
+
+describe librexgettext
+. ./test-common.sh
+
+it_displays_help() {
+ LC_ALL=C librexgettext -h >$tmpdir/stdout 2>$tmpdir/stderr
+
+ [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]]
+ empty $tmpdir/stderr
+}
+
+it_fails_with_0_args() {
+ librexgettext >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+
+ [[ $stat != 0 ]]
+ empty $tmpdir/stdout
+ not empty $tmpdir/stderr
+}
+
+passcase() {
+ librexgettext librexgettext.d/$roundup_test_name.sh > $tmpdir/actual.pot 2>$tmpdir/stderr
+ empty $tmpdir/stderr
+ diff -u librexgettext.d/$roundup_test_name.pot $tmpdir/actual.pot
+}
+
+it_handles_multiple_skipped_flags() { passcase; }
+it_handles_zero_flags() { passcase; }
+it_handles_librefetch_flags() { passcase; }
+
+it_fails_on_missing_final_flag_description() {
+ librexgettext librexgettext.d/$roundup_test_name.sh > /dev/null 2>$tmpdir/stderr || stat=$?
+
+ [[ $stat != 0 ]]
+ [[ "$(sed 1q $tmpdir/stderr)" = "librexgettext.d/$roundup_test_name.sh:4:"* ]]
+}
+
+
+it_fails_on_subshell_flag_descriptions() {
+ librexgettext librexgettext.d/$roundup_test_name.sh > /dev/null 2>$tmpdir/stderr || stat=$?
+
+ [[ $stat != 0 ]]
+ [[ "$(sed 1q $tmpdir/stderr)" = "librexgettext.d/$roundup_test_name.sh:4-6:"* ]]
+}
+
+it_doesnt_keep_failing() {
+ librexgettext some_file_that_doesnt_exist >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+
+ [[ $stat != 0 ]]
+ empty $tmpdir/stdout
+ [[ "$(wc -l <$tmpdir/stderr)" == 1 ]]
+}
+
+it_handles_multiple_files() {
+ librexgettext librexgettext.d/combine1.sh librexgettext.d/combine2.sh > $tmpdir/actual.pot 2>$tmpdir/stderr
+ empty $tmpdir/stderr
+ diff -u librexgettext.d/combine.pot $tmpdir/actual.pot
+}
diff --git a/test/librexgettext.d/.gitignore b/test/librexgettext.d/.gitignore
new file mode 100644
index 0000000..f0febc8
--- /dev/null
+++ b/test/librexgettext.d/.gitignore
@@ -0,0 +1 @@
+!/*.pot
diff --git a/test/librexgettext.d/combine.pot b/test/librexgettext.d/combine.pot
new file mode 100644
index 0000000..80d066f
--- /dev/null
+++ b/test/librexgettext.d/combine.pot
@@ -0,0 +1,15 @@
+#: librexgettext.d/combine1.sh:4
+msgid "Flag a"
+msgstr ""
+
+#: librexgettext.d/combine1.sh:5
+msgid "Flag b"
+msgstr ""
+
+#: librexgettext.d/combine2.sh:4
+msgid "Flag 1"
+msgstr ""
+
+#: librexgettext.d/combine2.sh:5
+msgid "Flag 2"
+msgstr ""
diff --git a/test/librexgettext.d/combine1.sh b/test/librexgettext.d/combine1.sh
new file mode 100644
index 0000000..9946076
--- /dev/null
+++ b/test/librexgettext.d/combine1.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+. libremessages
+
+flag -a 'Flag a' \
+ -b 'Flag b'
diff --git a/test/librexgettext.d/combine2.sh b/test/librexgettext.d/combine2.sh
new file mode 100644
index 0000000..441e87a
--- /dev/null
+++ b/test/librexgettext.d/combine2.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+. libremessages
+
+flag -1 'Flag 1' \
+ -2 'Flag 2'
diff --git a/test/librexgettext.d/it_fails_on_missing_final_flag_description.sh b/test/librexgettext.d/it_fails_on_missing_final_flag_description.sh
new file mode 100644
index 0000000..1c9fc23
--- /dev/null
+++ b/test/librexgettext.d/it_fails_on_missing_final_flag_description.sh
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+. libremessages
+
+flag -a
diff --git a/test/librexgettext.d/it_fails_on_subshell_flag_descriptions.sh b/test/librexgettext.d/it_fails_on_subshell_flag_descriptions.sh
new file mode 100644
index 0000000..f6be764
--- /dev/null
+++ b/test/librexgettext.d/it_fails_on_subshell_flag_descriptions.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+. libremessages
+
+flag '-a' \
+ "$(echo foo)" \
+ '-h' \
+ help
diff --git a/test/librexgettext.d/it_handles_librefetch_flags.pot b/test/librexgettext.d/it_handles_librefetch_flags.pot
new file mode 100644
index 0000000..0d76a49
--- /dev/null
+++ b/test/librexgettext.d/it_handles_librefetch_flags.pot
@@ -0,0 +1,40 @@
+#: librexgettext.d/it_handles_librefetch_flags.sh:4
+msgid "Settings:"
+msgstr ""
+
+#: librexgettext.d/it_handles_librefetch_flags.sh:5
+msgid "Force create mode (don't download)"
+msgstr ""
+
+#: librexgettext.d/it_handles_librefetch_flags.sh:6
+msgid "Force download mode (don't create)"
+msgstr ""
+
+#: librexgettext.d/it_handles_librefetch_flags.sh:7
+msgid "FILE"
+msgstr ""
+
+#: librexgettext.d/it_handles_librefetch_flags.sh:7
+msgid "Use an alternate build script (instead of 'PKGBUILD'). If an "
+ "SRCBUILD exists in the same directory, it is used instead"
+msgstr ""
+
+#: librexgettext.d/it_handles_librefetch_flags.sh:10
+msgid "Alternate modes:"
+msgstr ""
+
+#: librexgettext.d/it_handles_librefetch_flags.sh:11
+msgid "Generate integrity checks for source files"
+msgstr ""
+
+#: librexgettext.d/it_handles_librefetch_flags.sh:12
+msgid "Print the effective build script (SRCBUILD)"
+msgstr ""
+
+#: librexgettext.d/it_handles_librefetch_flags.sh:13
+msgid "Generate and print the location of the effective makepkg script"
+msgstr ""
+
+#: librexgettext.d/it_handles_librefetch_flags.sh:15
+msgid "Show this message"
+msgstr ""
diff --git a/test/librexgettext.d/it_handles_librefetch_flags.sh b/test/librexgettext.d/it_handles_librefetch_flags.sh
new file mode 100644
index 0000000..579ca96
--- /dev/null
+++ b/test/librexgettext.d/it_handles_librefetch_flags.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+. libremessages
+
+flag 'Settings:' \
+ "-C" "Force create mode (don't download)" \
+ "-D" "Force download mode (don't create)" \
+ "-p <$(_ FILE)>" "Use an alternate build script (instead of
+ 'PKGBUILD'). If an SRCBUILD exists in the same
+ directory, it is used instead" \
+ 'Alternate modes:' \
+ "-g, --geninteg" "Generate integrity checks for source files" \
+ "-S, --srcbuild" "Print the effective build script (SRCBUILD)" \
+ "-M, --makepkg" "Generate and print the location of the
+ effective makepkg script" \
+ "-h, --help" "Show this message"
diff --git a/test/librexgettext.d/it_handles_multiple_skipped_flags.pot b/test/librexgettext.d/it_handles_multiple_skipped_flags.pot
new file mode 100644
index 0000000..cae2a17
--- /dev/null
+++ b/test/librexgettext.d/it_handles_multiple_skipped_flags.pot
@@ -0,0 +1,58 @@
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:4
+msgid "Flag 1"
+msgstr ""
+
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:4
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:6
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:7
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:8
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:9
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:10
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:11
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:13
+msgid "OPTARG"
+msgstr ""
+
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:5
+msgid "Flag 2"
+msgstr ""
+
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:6
+msgid "Flag 3"
+msgstr ""
+
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:7
+msgid "Flag 4"
+msgstr ""
+
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:8
+msgid "Flag 5"
+msgstr ""
+
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:9
+msgid "Flag 6"
+msgstr ""
+
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:10
+msgid "Flag 7"
+msgstr ""
+
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:11
+msgid "Flag 8"
+msgstr ""
+
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:13
+msgid "FLAG 1"
+msgstr ""
+
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:14
+msgid "FLAG 2"
+msgstr ""
+
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:16
+msgid "FLAG A"
+msgstr ""
+
+#: librexgettext.d/it_handles_multiple_skipped_flags.sh:17
+msgid "FLAG B"
+msgstr ""
diff --git a/test/librexgettext.d/it_handles_multiple_skipped_flags.sh b/test/librexgettext.d/it_handles_multiple_skipped_flags.sh
new file mode 100644
index 0000000..3b4dcee
--- /dev/null
+++ b/test/librexgettext.d/it_handles_multiple_skipped_flags.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+. libremessages
+
+flag "-a $(_ OPTARG)" 'Flag 1' \
+ '-b' 'Flag 2' \
+ "-c $(_ OPTARG)" 'Flag 3' \
+ "-d $(_ OPTARG)" 'Flag 4' \
+ "-e $(_ OPTARG)" 'Flag 5' \
+ "-f $(_ OPTARG)" 'Flag 6' \
+ "-g $(_ OPTARG)" 'Flag 7' \
+ "-h $(_ OPTARG)" 'Flag 8'
+
+flag "-A $(_ OPTARG)" 'FLAG 1' \
+ '-B' 'FLAG 2'
+
+flag '-1' 'FLAG A' \
+ '-2' 'FLAG B'
diff --git a/test/librexgettext.d/it_handles_zero_flags.pot b/test/librexgettext.d/it_handles_zero_flags.pot
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/librexgettext.d/it_handles_zero_flags.pot
diff --git a/test/librexgettext.d/it_handles_zero_flags.sh b/test/librexgettext.d/it_handles_zero_flags.sh
new file mode 100644
index 0000000..2b6369c
--- /dev/null
+++ b/test/librexgettext.d/it_handles_zero_flags.sh
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+. libremessages
+
+flag
diff --git a/test/testenv b/test/testenv
index 3bb827f..a744308 100755
--- a/test/testenv
+++ b/test/testenv
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
+set -e
# Parse the arguments
NETWORK=true
@@ -31,7 +32,7 @@ old_pwd="$(pwd)"
if [[ -f $0 ]]; then
cd "${0%/*}"
fi
-if ! make -C .. install DESTDIR="$destdir" &>"$TMPDIR/make-output"; then
+if ! make -C .. install prefix=/usr sysconfdir=/etc DESTDIR="$destdir" &>"$TMPDIR/make-output"; then
echo 'error creating local install, cannot run tests' >&2
cat "$TMPDIR/make-output"
exit 1