diff options
Diffstat (limited to 'test/librestage-test.sh')
-rw-r--r-- | test/librestage-test.sh | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/test/librestage-test.sh b/test/librestage-test.sh new file mode 100644 index 0000000..849a68c --- /dev/null +++ b/test/librestage-test.sh @@ -0,0 +1,85 @@ +#!/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 + echo "ARCHES=('x86_64' 'i686' 'misp64el')" >>$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 librestage -h >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q "$tmpdir/stdout")" =~ Usage:.* ]] + [[ -z "$(cat "$tmpdir/stderr")" ]] +} + +it_fails_with_0_args() { + librestage >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + + [[ $stat != 0 ]] + [[ -z "$(cat "$tmpdir/stdout")" ]] + [[ -n "$(cat "$tmpdir/stderr")" ]] +} + +it_fails_with_invalid_args() { + librestage -q >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + + [[ $stat != 0 ]] + [[ -z "$(cat "$tmpdir/stdout")" ]] + [[ -n "$(cat "$tmpdir/stderr")" ]] +} + +# This was an actual bug I hit with md/emacs-mdmua a long time ago; solution was +# to use $(get_full_version) +it_stages_split_packages_with_different_versions() { + cp librestage.d/PKGBUILD-split "$tmpdir/PKGBUILD" + cd "$tmpdir" + + makepkg + librestage '~lukeshu' + + # peak at the PKGBUILD to get this info + [[ -f $tmpdir/workdir/staging/~lukeshu/md-0.81-4-any.pkg.tar.gz ]] + [[ -f $tmpdir/workdir/staging/~lukeshu/emacs-mdmua-0.72-4-any.pkg.tar.gz ]] +} + +it_stages_packages_to_multiple_repos() { + cp librestage.d/PKGBUILD-hello "$tmpdir/PKGBUILD" + cd "$tmpdir" + + makepkg + librestage repo1 repo2 repo3 + + [[ -f $tmpdir/workdir/staging/repo1/libretools-hello-1.0-1-any.pkg.tar.gz ]] + [[ -f $tmpdir/workdir/staging/repo2/libretools-hello-1.0-1-any.pkg.tar.gz ]] + [[ -f $tmpdir/workdir/staging/repo3/libretools-hello-1.0-1-any.pkg.tar.gz ]] +} + + +it_stages_packages_without_PKGDEST() { + echo "PKGDEST=''" >> $HOME/.makepkg.conf + + cp librestage.d/PKGBUILD-hello "$tmpdir/PKGBUILD" + cd "$tmpdir" + + makepkg + librestage repo1 + + [[ -f $tmpdir/workdir/staging/repo1/libretools-hello-1.0-1-any.pkg.tar.gz ]] +} |