summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-09-30 12:05:06 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-09-30 12:07:44 -0400
commitf15ec397c5729d792c020eede7132637d2135f9d (patch)
tree47ec3196fdd8295eccc5935ec312c7029f81bb2b
parent505cf3ea3c09b390a57c715e47b65fea764d726d (diff)
librerelease: I was dumb and messed up the flags to `find`. Add unit tests.
-rwxr-xr-xsrc/abslibre-tools/librerelease4
-rw-r--r--test/librerelease-test.sh48
2 files changed, 50 insertions, 2 deletions
diff --git a/src/abslibre-tools/librerelease b/src/abslibre-tools/librerelease
index 86ee4c8..3baa8ad 100755
--- a/src/abslibre-tools/librerelease
+++ b/src/abslibre-tools/librerelease
@@ -53,7 +53,7 @@ readonly rsync_flags=(
# Functions ####################################################################
list0_files() {
- find "${WORKDIR}/staging" -L -type f -print0
+ find -L "${WORKDIR}/staging" -type f -print0
}
# This function is taken almost verbatim from makepkg
@@ -180,7 +180,7 @@ pretty_print_packages() {
find "$WORKDIR/staging/" -mindepth 1 -type d -not -empty -printf '%f\n' | sort |
while read -r repo; do
msg2 "$repo"
- find "${WORKDIR}/staging/${repo}" -L -type f -printf "%f\n" | sort
+ find -L "${WORKDIR}/staging/${repo}" -type f -printf "%f\n" | sort
done
}
diff --git a/test/librerelease-test.sh b/test/librerelease-test.sh
new file mode 100644
index 0000000..0fc1089
--- /dev/null
+++ b/test/librerelease-test.sh
@@ -0,0 +1,48 @@
+#!/usr/bin/env roundup
+
+describe librestage
+
+. ./test-common.sh
+
+before() {
+ _before
+
+ mkdir -p $XDG_CONFIG_HOME/libretools
+ echo "WORKDIR='$tmpdir/workdir'" >$XDG_CONFIG_HOME/libretools/libretools.conf
+
+ export HOME=$XDG_CONFIG_HOME
+ echo 'PKGEXT=.pkg.tar.gz' > $HOME/.makepkg.conf
+ echo "PKGDEST='$tmpdir/workdir/pkgdest'" >> $HOME/.makepkg.conf
+ mkdir -p "$tmpdir/workdir/pkgdest"
+}
+
+after() {
+ _after
+}
+
+it_displays_usage_text() {
+ rm -rf "$XDG_CONFIG_HOME"
+ LANG=C librerelease -h >"$tmpdir/stdout" 2>"$tmpdir/stderr"
+
+ [[ "$(sed 1q "$tmpdir/stdout")" =~ Usage:.* ]]
+ empty "$tmpdir/stderr"
+}
+
+it_lists_all_files() {
+ mkdir -p "$WORKDIR/staging/repo1" "$WORKDIR/staging/repo2"
+ touch \
+ "$WORKDIR/staging/repo1/file1" \
+ "$WORKDIR/staging/repo1/file2" \
+ "$WORKDIR/staging/repo2/file with spaces"
+ LANG=C librerelease -l &>"$tmpdir/list"
+
+ cat > "$tmpdir/list-correct" <<EOF
+ -> repo1
+file1
+file2
+ -> repo2
+file with spaces
+EOF
+
+ diff "$tmpdir/list-correct" "$tmpdir/list"
+ empty "$tmpdir/list"