#!/usr/bin/env roundup describe librestage . ./test-common.sh setup_chrootdir common_before() { mkdir -p $XDG_CONFIG_HOME/libretools echo "WORKDIR='$tmpdir/workdir'" > $XDG_CONFIG_HOME/libretools/libretools.conf mkdir -p $XDG_CONFIG_HOME/pacman { printf 'PKGDEST=%q\n' "$tmpdir/workdir/pkgdest" printf 'SRCPKGDEST=%q\n' "$tmpdir/workdir/srcpkgdest" echo "PACKAGER='Test Suite '" } >$XDG_CONFIG_HOME/pacman/makepkg.conf mkdir -p "$tmpdir/workdir/pkgdest" mkdir -p "$tmpdir/workdir/srcpkgdest" } it_displays_usage_text() { rm -rf "$XDG_CONFIG_HOME" LC_ALL=C librestage -h >$tmpdir/stdout 2>$tmpdir/stderr [[ "$(sed 1q "$tmpdir/stdout")" =~ Usage:.* ]] empty "$tmpdir/stderr" } it_fails_with_0_args() { librestage >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] empty "$tmpdir/stdout" not empty "$tmpdir/stderr" } it_fails_with_invalid_args() { librestage -q >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] empty "$tmpdir/stdout" not empty "$tmpdir/stderr" } it_guesses_the_repo() { nochroot=false; require network sudo || nochroot=true mkdir -p -- "$tmpdir/reponame/libretools-hello" cp librestage.d/PKGBUILD-hello "$tmpdir/reponame/libretools-hello/PKGBUILD" cd "$tmpdir/reponame/libretools-hello" if $nochroot; then makepkg else libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty testsudo libremakepkg -l "$roundup_test_name" fi librestage find "$tmpdir" -not -type d -exec ls -ld -- {} + [[ -f $(echo $tmpdir/workdir/staging/reponame/libretools-hello-1.0-1-any.pkg.tar.?z) ]] $nochroot || [[ -f $(echo $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar.?z) ]] } it_stages_packages_without_PKGDEST() { nochroot=false; require network sudo || nochroot=true echo "PKGDEST=''" >> $XDG_CONFIG_HOME/pacman/makepkg.conf echo "SRCPKGDEST=''" >> $XDG_CONFIG_HOME/pacman/makepkg.conf cp librestage.d/PKGBUILD-hello "$tmpdir/PKGBUILD" cd "$tmpdir" if $nochroot; then makepkg else libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty testsudo libremakepkg -l "$roundup_test_name" fi librestage repo1 find "$tmpdir" -not -type d -exec ls -ld -- {} + [[ -f $(echo $tmpdir/workdir/staging/repo1/libretools-hello-1.0-1-any.pkg.tar.?z) ]] $nochroot || [[ -f $(echo $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar.?z) ]] }