#!/usr/bin/env roundup describe libremakepkg . ./test-common.sh _setup_chrootdir before() { _before libremakepkg mkdir -p "$XDG_CONFIG_HOME"/libretools echo "BLACKLIST=https://repo.parabolagnulinux.org/docs/blacklist.txt" >"$XDG_CONFIG_HOME"/libretools/libretools.conf echo "CHROOTDIR='${chrootdir}'" > "$XDG_CONFIG_HOME"/libretools/chroot.conf echo "CHROOT='default'" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf echo "CHROOTEXTRAPKG=()" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf } after() { _after_sudo } it_builds_a_trivial_package() { require network sudo || return 0 cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" cd "$tmpdir" libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty testsudo libremakepkg -l "$roundup_test_name" [[ -f $(echo libretools-hello-1.0-1-any.pkg.tar.?z) ]] } it_cleans_the_chroot_before_building() { require network sudo || return 0 # 1. First, we build testpkg1 # 2. Then, we build testpkg2, which depends on testpkg1 # Therefore, testpkg1 will be installed after testpkg2 is built, we # check for that. # 3. Then, we build hello, which depends on neither, so testpkg1 should # be removed. # Also, do funny things with the output of libremakepkg to get a helpful # fail case. mkdir -p "$tmpdir"/{1,2,3} cp libremakepkg.d/PKGBUILD-testpkg1 "$tmpdir/1/PKGBUILD" cp libremakepkg.d/PKGBUILD-testpkg2 "$tmpdir/2/PKGBUILD" cp libremakepkg.d/PKGBUILD-hello "$tmpdir/3/PKGBUILD" libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty cd "$tmpdir/1" testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; } cd "$tmpdir/2" testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; } testsudo librechroot -l "$roundup_test_name" run libretools-testpkg1 'first time, pass' cd "$tmpdir/3" testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; } ! testsudo librechroot -l "$roundup_test_name" run libretools-testpkg1 'second time, fail' } it_handles_PKGDEST_not_existing() { require network sudo || return 0 cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" cd "$tmpdir" libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty testsudo env PKGDEST="$tmpdir/dest/pkgdest" libremakepkg -l "$roundup_test_name" [[ -f $(echo dest/pkgdest/libretools-hello-1.0-1-any.pkg.tar.?z) ]] } it_displays_help_as_normal_user() { rm -rf "$XDG_CONFIG_HOME" LC_ALL=C libremakepkg -l "$roundup_test_name" -h >$tmpdir/stdout 2>$tmpdir/stderr [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] empty $tmpdir/stderr } it_otherwise_fails_as_normal_user() { # I do this to give it a chance of passing cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" cd "$tmpdir" libremakepkg -l "$roundup_test_name" >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] empty $tmpdir/stdout ! empty $tmpdir/stderr }