From fa6e7ccf3914081504681679645fd7cfd803cfdd Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 5 Jan 2014 18:39:47 -0500 Subject: test/: re-jigger the chroot tests to be fast on btrfs --- test/librechroot-test.sh | 24 ++++++++++++++---------- test/libremakepkg-test.sh | 22 ++++++++++++---------- test/test-common.sh | 23 +++++++++++++++++++++++ 3 files changed, 49 insertions(+), 20 deletions(-) (limited to 'test') diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh index 5ca1b37..442abed 100644 --- a/test/librechroot-test.sh +++ b/test/librechroot-test.sh @@ -4,30 +4,34 @@ describe librechroot . ./test-common.sh +_setup_chrootdir + before() { _before librechroot + mkdir -p "$XDG_CONFIG_HOME"/libretools - echo "CHROOTDIR='$tmpdir/chrootdir'" > "$XDG_CONFIG_HOME"/libretools/chroot.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() ( _after_sudo -} +) it_creates_repo_for_new_chroots() { require network sudo || return 0 libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo librechroot run test -r /repo/repo.db + testsudo librechroot -l "$roundup_test_name" run test -r /repo/repo.db } it_cleans_the_local_repo_correctly() { require network sudo || return 0 libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo librechroot make - testsudo librechroot clean-repo - testsudo librechroot run test -r /repo/repo.db + testsudo librechroot -l "$roundup_test_name" make + testsudo librechroot -l "$roundup_test_name" clean-repo + testsudo librechroot -l "$roundup_test_name" run test -r /repo/repo.db # TODO: inspect /repo/* more } @@ -36,7 +40,7 @@ it_respects_exit_status_if_out_isnt_a_tty() ( set -o pipefail libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty r=0 - { testsudo librechroot run exit 3 | cat; } || r=$? + { testsudo librechroot -l "$roundup_test_name" run exit 3 | cat; } || r=$? [[ $r == 3 ]] ) @@ -49,7 +53,7 @@ it_displays_help_as_normal_user() { } it_otherwise_fails_as_normal_user() { - librechroot run true >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + librechroot -l "$roundup_test_name" run true >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] empty $tmpdir/stdout @@ -57,7 +61,7 @@ it_otherwise_fails_as_normal_user() { } it_displays_help_and_fails_with_0_args() { - LC_ALL=C librechroot >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + LC_ALL=C librechroot -l "$roundup_test_name" >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] empty $tmpdir/stdout diff --git a/test/libremakepkg-test.sh b/test/libremakepkg-test.sh index e684f18..9f3bed3 100644 --- a/test/libremakepkg-test.sh +++ b/test/libremakepkg-test.sh @@ -4,6 +4,8 @@ describe libremakepkg . ./test-common.sh +_setup_chrootdir + before() { _before libremakepkg @@ -11,7 +13,7 @@ before() { echo "BLACKLIST=https://repo.parabolagnulinux.org/docs/blacklist.txt" >"$XDG_CONFIG_HOME"/libretools/libretools.conf - echo "CHROOTDIR='$tmpdir/chrootdir'" > "$XDG_CONFIG_HOME"/libretools/chroot.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 } @@ -26,7 +28,7 @@ it_builds_a_trivial_package() { cd "$tmpdir" libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo libremakepkg + testsudo libremakepkg -l "$roundup_test_name" [[ -f $(echo libretools-hello-1.0-1-any.pkg.tar.?z) ]] } @@ -50,13 +52,13 @@ it_cleans_the_chroot_before_building() { libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty cd "$tmpdir/1" - testsudo libremakepkg &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; } + testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; } cd "$tmpdir/2" - testsudo libremakepkg &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; } - testsudo librechroot run libretools-testpkg1 'first time, pass' + 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 &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; } - ! testsudo librechroot run libretools-testpkg1 'second time, fail' + 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() { @@ -65,14 +67,14 @@ it_handles_PKGDEST_not_existing() { cd "$tmpdir" libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo env PKGDEST="$tmpdir/dest/pkgdest" libremakepkg + 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 -h >$tmpdir/stdout 2>$tmpdir/stderr + LC_ALL=C libremakepkg -l "$roundup_test_name" -h >$tmpdir/stdout 2>$tmpdir/stderr [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] empty $tmpdir/stderr @@ -83,7 +85,7 @@ it_otherwise_fails_as_normal_user() { cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" cd "$tmpdir" - libremakepkg >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + libremakepkg -l "$roundup_test_name" >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] empty $tmpdir/stdout diff --git a/test/test-common.sh b/test/test-common.sh index aadd8f2..46e584d 100644 --- a/test/test-common.sh +++ b/test/test-common.sh @@ -26,6 +26,29 @@ _after_sudo() { fi } +_setup_chrootdir() { + if [[ -z "$chrootdir" ]]; then + export chrootdir="$(mktemp -d --tmpdir "test-chrootdir.XXXXXXXXXXXX")" + trap "$(printf '_cleanup_chrootdir %q' "$chrootdir")" EXIT + fi +} + +_cleanup_chrootdir() ( + chrootdir=$1 + shopt -s nullglob + if [[ $SUDO ]]; then + for copydir in "$chrootdir"/*/*/; do + local chroottype=$(stat -f -c %T "$copydir") + if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then + sudo btrfs subvolume delete "$copydir" >/dev/null + fi + done + sudo rm -rf -- "$chrootdir" + else + rm -rf -- "$chrootdir" + fi +) + require() ( set +x local missing=() -- cgit v1.2.3-54-g00ecf From e6a70164f89ee5e8571b6b485fda9262a9d16991 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 5 Jan 2014 20:17:13 -0500 Subject: test/libremakepkg: don't use -l in tests that don't require sudo It confuses check() when building the package --- test/libremakepkg-test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/libremakepkg-test.sh b/test/libremakepkg-test.sh index 9f3bed3..7b64dc0 100644 --- a/test/libremakepkg-test.sh +++ b/test/libremakepkg-test.sh @@ -74,7 +74,7 @@ it_handles_PKGDEST_not_existing() { 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 + LC_ALL=C libremakepkg -h >$tmpdir/stdout 2>$tmpdir/stderr [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] empty $tmpdir/stderr @@ -85,7 +85,7 @@ it_otherwise_fails_as_normal_user() { cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" cd "$tmpdir" - libremakepkg -l "$roundup_test_name" >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + libremakepkg >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] empty $tmpdir/stdout -- cgit v1.2.3-54-g00ecf From 7f3842777aeed4bd7b7ec28ef59c56c489a0831f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 5 Jan 2014 21:20:04 -0500 Subject: update test/librerelease-test.sh --- test/librerelease-test.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/librerelease-test.sh b/test/librerelease-test.sh index c395bc6..a44b150 100644 --- a/test/librerelease-test.sh +++ b/test/librerelease-test.sh @@ -34,20 +34,22 @@ it_displays_usage_text() { it_lists_all_files() { WORKDIR="$tmpdir/workdir" - mkdir -p "$WORKDIR/staging/repo1" "$WORKDIR/staging/repo2" + mkdir -p "$WORKDIR/staging/repo1" "$WORKDIR/staging/repo2/sub" touch \ "$WORKDIR/staging/repo1/file1" \ "$WORKDIR/staging/repo1/file2" \ - "$WORKDIR/staging/repo2/file with spaces" + "$WORKDIR/staging/repo2/file with spaces" \ + "$WORKDIR/staging/repo2/sub/subfolder" unset WORKDIR LC_ALL=C librerelease -l &>"$tmpdir/list" cat > "$tmpdir/list-correct" < repo1 -file1 -file2 + file1 + file2 -> repo2 -file with spaces + file with spaces + sub/subfolder EOF diff "$tmpdir/list-correct" "$tmpdir/list" -- cgit v1.2.3-54-g00ecf From b6e66bce4dadd1a5b9f74a456de3ef5575e648fa Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 19 Jan 2014 17:19:04 -0500 Subject: libremakepkg: Check the permissions of the bind-mounted directories --- src/chroot-tools/libremakepkg | 24 ++++++++++++++++++++++++ test/test-common.sh | 1 + 2 files changed, 25 insertions(+) (limited to 'test') diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index 1db9f08..96f86ab 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -54,6 +54,21 @@ indent() { "$_indent" ' | ' } +# Usage: _check_perms_dir $directory +# Make sure that $directory is readable and executable (searchable) by 'nobody' +check_directory_permissions() ( + local dir=$1 + # `cd` to the directory, then test `.`; that way if parent + # directories aren't readable, we aren't testing for that. We + # only need the last element in `$dir`. + cd "$dir" + if ! sudo -u nobody test -r . -a -x .; then + error "Directory '%s' must be readable by user 'nobody'" "$dir" + return 1 + fi + return 0 +) + # Usage: exit_copy $copydir $src_owner # End immediately, but copy log files out exit_copy() { @@ -236,6 +251,15 @@ main() { # Make sure that the various *DEST directories exist mkdir -p -- "$PKGDEST" "$SRCDEST" "$SRCPKGDEST" "$LOGDEST" + # Check the permissions for $startdir and $SRCDEST + ( + declare -i ret=0 + check_directory_permissions "$PWD" || ret=1 + if ! [[ "$PWD" -ef "$SRCDEST" ]]; then + check_directory_permissions "$SRCDEST" || ret=1 + fi + exit $ret + ) # OK, we are starting now ############################################## diff --git a/test/test-common.sh b/test/test-common.sh index 46e584d..3df7107 100644 --- a/test/test-common.sh +++ b/test/test-common.sh @@ -11,6 +11,7 @@ _before() { unset PKGEXT SRCEXT unset GPGKEY PACKAGER tmpdir="$(mktemp -d --tmpdir "test-${roundup_desc//\//-}.XXXXXXXXXXXX")" + chmod 755 "$tmpdir" stat=0 } -- cgit v1.2.3-54-g00ecf From c54c481b5b7a1cb7d4a201fad9450d3abb198742 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 20 Jan 2014 01:11:33 -0500 Subject: fix librechroot test --- test/librechroot-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh index 442abed..d458cd9 100644 --- a/test/librechroot-test.sh +++ b/test/librechroot-test.sh @@ -65,7 +65,7 @@ it_displays_help_and_fails_with_0_args() { [[ $stat != 0 ]] empty $tmpdir/stdout - [[ "$(sed 1q $tmpdir/stderr)" =~ Usage:.* ]] + [[ "$(sed -n 2p $tmpdir/stderr)" =~ Usage:.* ]] } # requires sudo so we know it's not failing because it needs root -- cgit v1.2.3-54-g00ecf From 641002eff37a30eb2b8237b15b74cc15b4d9f822 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 20 Jan 2014 13:41:28 -0500 Subject: test/librefetch: update the DLAGENTS setting --- test/librefetch-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/librefetch-test.sh b/test/librefetch-test.sh index 13ce80f..92f67a1 100644 --- a/test/librefetch-test.sh +++ b/test/librefetch-test.sh @@ -9,7 +9,7 @@ before() { mkdir -p "$HOME" printf '%s\n' \ - "DLAGENTS+=(\"libre::$(which librefetch) -p \\\"\\\$BUILDFILE\\\" %u %o\")" \ + 'DLAGENTS+=({https,libre}'\''::/usr/bin/librefetch -p "$BUILDFILE" -- %u %o'\'')' \ 'BUILDDIR=""' \ > "$HOME/.makepkg.conf" -- cgit v1.2.3-54-g00ecf From e0b9e3ab07f64b9cbf575f560a25e5712208b8d7 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 2 Feb 2014 12:41:52 -0500 Subject: test/librechroot: test the -N flag --- test/librechroot-test.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh index d458cd9..ae5dd4b 100644 --- a/test/librechroot-test.sh +++ b/test/librechroot-test.sh @@ -44,6 +44,14 @@ it_respects_exit_status_if_out_isnt_a_tty() ( [[ $r == 3 ]] ) +it_disables_networking_when_requested() { + require network sudo || return 0 + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + + testsudo librechroot -l "$roundup_test_name" run curl https://repo.parabolagnulinux.org/ >/dev/null + ! testsudo librechroot -l "$roundup_test_name" -N run curl https://repo.parabolagnulinux.org/ >/dev/null +} + it_displays_help_as_normal_user() { rm -rf "$XDG_CONFIG_HOME" LC_ALL=C librechroot help >$tmpdir/stdout 2>$tmpdir/stderr -- cgit v1.2.3-54-g00ecf From 1a7621e6e3ca4ad7c132d1b9d4f7d5dc67fc1a32 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 2 Feb 2014 12:46:01 -0500 Subject: test/librechroot: test CHROOTEXTRAPKG --- test/librechroot-test.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh index ae5dd4b..f8dd2ba 100644 --- a/test/librechroot-test.sh +++ b/test/librechroot-test.sh @@ -52,6 +52,20 @@ it_disables_networking_when_requested() { ! testsudo librechroot -l "$roundup_test_name" -N run curl https://repo.parabolagnulinux.org/ >/dev/null } +it_handles_CHROOTEXTRAPKG_correctly() { + requuire network sudo || return 0 + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + + ! testsudo librechroot -l "$roundup_test_name" run lsof + echo "CHROOTEXTRAPKG=(lsof)" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf + testsudo librechroot -l "$roundup_test_name" install-name lsof + testsudo librechroot -l "$roundup_test_name" clean-pkgs + testsudo librechroot -l "$roundup_test_name" run lsof + echo "CHROOTEXTRAPKG=()" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf + testsudo librechroot -l "$roundup_test_name" clean-pkgs + ! testsudo librechroot -l "$roundup_test_name" run lsof +} + it_displays_help_as_normal_user() { rm -rf "$XDG_CONFIG_HOME" LC_ALL=C librechroot help >$tmpdir/stdout 2>$tmpdir/stderr -- cgit v1.2.3-54-g00ecf From e4ccc15cccf46e6265347f4fdee598b0561c4c74 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 2 Feb 2014 20:20:20 -0500 Subject: librechroot-test: check for the existance of ca-certificates.crt --- test/librechroot-test.sh | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh index f8dd2ba..3896005 100644 --- a/test/librechroot-test.sh +++ b/test/librechroot-test.sh @@ -44,6 +44,12 @@ it_respects_exit_status_if_out_isnt_a_tty() ( [[ $r == 3 ]] ) +it_creates_ca_certificates() { + require network sudo || return 0 + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo librechroot -l "$roundup_test_name" run test -r /etc/ssl/certs/ca-certificates.crt +} + it_disables_networking_when_requested() { require network sudo || return 0 libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty -- cgit v1.2.3-54-g00ecf From ef7a330eae68da2f47c617502b28a2f8c9eeb792 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 2 Feb 2014 20:54:07 -0500 Subject: libremakepkg-test: test the -N flag --- test/libremakepkg-test.sh | 25 +++++++++++++++++++++++++ test/libremakepkg.d/PKGBUILD-netbuild | 16 ++++++++++++++++ test/libremakepkg.d/PKGBUILD-netpackage | 12 ++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 test/libremakepkg.d/PKGBUILD-netbuild create mode 100644 test/libremakepkg.d/PKGBUILD-netpackage (limited to 'test') diff --git a/test/libremakepkg-test.sh b/test/libremakepkg-test.sh index 7b64dc0..06cf695 100644 --- a/test/libremakepkg-test.sh +++ b/test/libremakepkg-test.sh @@ -33,6 +33,31 @@ it_builds_a_trivial_package() { [[ -f $(echo libretools-hello-1.0-1-any.pkg.tar.?z) ]] } + +it_disables_networking_during_build() { + require network sudo || return 0 + cp libremakepkg.d/PKGBUILD-netbuild "$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-netbuild-1.0-1-any.pkg.tar.?z) ]] + testsudo libremakepkg -l "$roundup_test_name" -N + [[ -f $(echo libretools-netbuild-1.0-1-any.pkg.tar.?z) ]] +} + +it_disables_networking_during_package() { + require network sudo || return 0 + cp libremakepkg.d/PKGBUILD-netpackage "$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-netpackage-1.0-1-any.pkg.tar.?z) ]] + testsudo libremakepkg -l "$roundup_test_name" -N + [[ -f $(echo libretools-netpackage-1.0-1-any.pkg.tar.?z) ]] +} + it_cleans_the_chroot_before_building() { require network sudo || return 0 # 1. First, we build testpkg1 diff --git a/test/libremakepkg.d/PKGBUILD-netbuild b/test/libremakepkg.d/PKGBUILD-netbuild new file mode 100644 index 0000000..c1335a6 --- /dev/null +++ b/test/libremakepkg.d/PKGBUILD-netbuild @@ -0,0 +1,16 @@ +pkgname='libretools-netbuild' +pkgver=1.0 +license=('GPL') +url='https://parabolagnulinux.org' + +pkgrel=1 +arch=(any) + +build() { + curl https://repo.parabolagnulinux.org/ > index.html +} + +package() { + cd "$srcdir" + install -Dm644 index.html "$pkgdir"/usr/share/$pkgname/index.html +} diff --git a/test/libremakepkg.d/PKGBUILD-netpackage b/test/libremakepkg.d/PKGBUILD-netpackage new file mode 100644 index 0000000..cbefe8f --- /dev/null +++ b/test/libremakepkg.d/PKGBUILD-netpackage @@ -0,0 +1,12 @@ +pkgname='libretools-netpackage' +pkgver=1.0 +license=('GPL') +url='https://parabolagnulinux.org' + +pkgrel=1 +arch=(any) + +package() { + install -d "$pkgdir"/usr/share/$pkgname + curl https://repo.parabolagnulinux.org/ > "$pkgdir"/usr/share/$pkgname/index.html +} -- cgit v1.2.3-54-g00ecf From 6fb2295a25ee4a24b38f4fce1b652a60cedd1b64 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 2 Feb 2014 22:24:28 -0500 Subject: test: `! true` doesn't trip `set -e`, do subshell magic --- test/aur-test.sh | 2 +- test/is_built-test.sh | 2 +- test/lib-blacklist-test.sh | 10 +++++----- test/lib-messages-test.sh | 4 ++-- test/librechroot-test.sh | 14 +++++++------- test/librelib-test.sh | 4 ++-- test/libremakepkg-test.sh | 12 ++++++------ test/librestage-test.sh | 4 ++-- test/pkgbuild-check-nonfree-test.sh | 10 +++++----- test/test-common.sh | 6 ++++++ 10 files changed, 37 insertions(+), 31 deletions(-) (limited to 'test') diff --git a/test/aur-test.sh b/test/aur-test.sh index 8bcb5ef..5de590b 100644 --- a/test/aur-test.sh +++ b/test/aur-test.sh @@ -24,7 +24,7 @@ it_fails_with_0_args() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } # TODO: Actually test diff --git a/test/is_built-test.sh b/test/is_built-test.sh index af754dc..f7f6c65 100644 --- a/test/is_built-test.sh +++ b/test/is_built-test.sh @@ -24,7 +24,7 @@ it_fails_with_0_args() { [[ $stat -gt 1 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } it_succeeds_with_1_arg() { diff --git a/test/lib-blacklist-test.sh b/test/lib-blacklist-test.sh index 640ed77..9dfd5da 100644 --- a/test/lib-blacklist-test.sh +++ b/test/lib-blacklist-test.sh @@ -53,7 +53,7 @@ it_fails_update_with_no_blacklist_or_network() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } it_fails_cat_with_no_blacklist_or_network() { @@ -64,7 +64,7 @@ it_fails_cat_with_no_blacklist_or_network() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } it_fails_update_when_BLACKLIST_is_unset() { @@ -75,7 +75,7 @@ it_fails_update_when_BLACKLIST_is_unset() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } it_fails_cat_when_syntax_error_in_conf() { @@ -87,7 +87,7 @@ it_fails_cat_when_syntax_error_in_conf() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } it_downloads_the_blacklist_as_needed() { @@ -97,7 +97,7 @@ it_downloads_the_blacklist_as_needed() { libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr - ! empty $tmpdir/stdout + not empty $tmpdir/stdout } it_downloads_the_blacklist_repeatedly() { diff --git a/test/lib-messages-test.sh b/test/lib-messages-test.sh index fffff36..3fcac63 100644 --- a/test/lib-messages-test.sh +++ b/test/lib-messages-test.sh @@ -31,14 +31,14 @@ it_works_with_no_color_and_set_euE() ( ) >$tmpdir/stdout 2>$tmpdir/stderr empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr ) it_can_be_called_without_including() { libremessages msg Foo >$tmpdir/stdout 2>$tmpdir/stderr empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } it_fails_with_msg_and_no_args() { diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh index 3896005..c22ac58 100644 --- a/test/librechroot-test.sh +++ b/test/librechroot-test.sh @@ -54,22 +54,22 @@ it_disables_networking_when_requested() { require network sudo || return 0 libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo librechroot -l "$roundup_test_name" run curl https://repo.parabolagnulinux.org/ >/dev/null - ! testsudo librechroot -l "$roundup_test_name" -N run curl https://repo.parabolagnulinux.org/ >/dev/null + testsudo librechroot -l "$roundup_test_name" run curl https://repo.parabolagnulinux.org/ >/dev/null + not testsudo librechroot -l "$roundup_test_name" -N run curl https://repo.parabolagnulinux.org/ >/dev/null } it_handles_CHROOTEXTRAPKG_correctly() { requuire network sudo || return 0 libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - ! testsudo librechroot -l "$roundup_test_name" run lsof + not testsudo librechroot -l "$roundup_test_name" run lsof echo "CHROOTEXTRAPKG=(lsof)" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf testsudo librechroot -l "$roundup_test_name" install-name lsof testsudo librechroot -l "$roundup_test_name" clean-pkgs testsudo librechroot -l "$roundup_test_name" run lsof echo "CHROOTEXTRAPKG=()" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf testsudo librechroot -l "$roundup_test_name" clean-pkgs - ! testsudo librechroot -l "$roundup_test_name" run lsof + not testsudo librechroot -l "$roundup_test_name" run lsof } it_displays_help_as_normal_user() { @@ -85,7 +85,7 @@ it_otherwise_fails_as_normal_user() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } it_displays_help_and_fails_with_0_args() { @@ -103,7 +103,7 @@ it_fails_for_unknown_commands() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } # requires sudo so we know it's not failing because it needs root @@ -113,5 +113,5 @@ it_fails_for_unknown_flags() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } diff --git a/test/librelib-test.sh b/test/librelib-test.sh index 23c38dc..a74ce0a 100644 --- a/test/librelib-test.sh +++ b/test/librelib-test.sh @@ -26,7 +26,7 @@ it_fails_with_2_args() { librelib a b >$tmpdir/stdout 2>$tmpdir/stderr || ret=$? empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr [[ $ret != 0 ]] } @@ -68,6 +68,6 @@ it_fails_to_find_phony() { librelib phony >$tmpdir/stdout 2>$tmpdir/stderr || ret=$? empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr [[ $ret != 0 ]] } diff --git a/test/libremakepkg-test.sh b/test/libremakepkg-test.sh index 06cf695..811c8ed 100644 --- a/test/libremakepkg-test.sh +++ b/test/libremakepkg-test.sh @@ -40,8 +40,8 @@ it_disables_networking_during_build() { cd "$tmpdir" libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - ! testsudo libremakepkg -l "$roundup_test_name" - ! [[ -f $(echo libretools-netbuild-1.0-1-any.pkg.tar.?z) ]] + not testsudo libremakepkg -l "$roundup_test_name" + not [[ -f $(echo libretools-netbuild-1.0-1-any.pkg.tar.?z) ]] testsudo libremakepkg -l "$roundup_test_name" -N [[ -f $(echo libretools-netbuild-1.0-1-any.pkg.tar.?z) ]] } @@ -52,8 +52,8 @@ it_disables_networking_during_package() { cd "$tmpdir" libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - ! testsudo libremakepkg -l "$roundup_test_name" - ! [[ -f $(echo libretools-netpackage-1.0-1-any.pkg.tar.?z) ]] + not testsudo libremakepkg -l "$roundup_test_name" + not [[ -f $(echo libretools-netpackage-1.0-1-any.pkg.tar.?z) ]] testsudo libremakepkg -l "$roundup_test_name" -N [[ -f $(echo libretools-netpackage-1.0-1-any.pkg.tar.?z) ]] } @@ -83,7 +83,7 @@ it_cleans_the_chroot_before_building() { 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' + not testsudo librechroot -l "$roundup_test_name" run libretools-testpkg1 'second time, fail' } it_handles_PKGDEST_not_existing() { @@ -114,5 +114,5 @@ it_otherwise_fails_as_normal_user() { [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } diff --git a/test/librestage-test.sh b/test/librestage-test.sh index 6728143..460eb58 100644 --- a/test/librestage-test.sh +++ b/test/librestage-test.sh @@ -34,7 +34,7 @@ it_fails_with_0_args() { [[ $stat != 0 ]] empty "$tmpdir/stdout" - ! empty "$tmpdir/stderr" + not empty "$tmpdir/stderr" } it_fails_with_invalid_args() { @@ -42,7 +42,7 @@ it_fails_with_invalid_args() { [[ $stat != 0 ]] empty "$tmpdir/stdout" - ! empty "$tmpdir/stderr" + not empty "$tmpdir/stderr" } # This was an actual bug I hit with md/emacs-mdmua a long time ago; solution was diff --git a/test/pkgbuild-check-nonfree-test.sh b/test/pkgbuild-check-nonfree-test.sh index 6463d64..2af2669 100644 --- a/test/pkgbuild-check-nonfree-test.sh +++ b/test/pkgbuild-check-nonfree-test.sh @@ -39,7 +39,7 @@ it_succeeds_for_free_depends() { $pcn $pcn.d/PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr [[ $stat == 0 ]] } @@ -47,7 +47,7 @@ it_succeeds_for_nonfree_depend_with_replacement() { $pcn $pcn.d/PKGBUILD.nonfree-replacement >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr [[ $stat == 0 ]] } @@ -55,14 +55,14 @@ it_fails_for_nonfree_depend() { $pcn $pcn.d/PKGBUILD.nonfree >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr local pcn_stat=$stat $psn $pcn_stat >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr } it_fails_when_there_is_no_blacklist() { @@ -73,6 +73,6 @@ it_fails_when_there_is_no_blacklist() { $pcn $pcn.d/PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? empty $tmpdir/stdout - ! empty $tmpdir/stderr + not empty $tmpdir/stderr [[ $stat != 0 ]] && [[ $stat != 15 ]] } diff --git a/test/test-common.sh b/test/test-common.sh index 3df7107..c525dd8 100644 --- a/test/test-common.sh +++ b/test/test-common.sh @@ -70,3 +70,9 @@ empty() ( set +x [[ $(stat -c %s "$1") -eq 0 ]] ) + +# Just using '!' doesn't trip `set -e` +not() ( + set +x + ! eval "$@" +) -- cgit v1.2.3-54-g00ecf From 696c05516039b7b93381811451d393b16a8653d1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 9 Feb 2014 20:42:54 -0500 Subject: add a test for the last commit (enabling networking during prepare()) --- test/libremakepkg-test.sh | 9 +++++++++ test/libremakepkg.d/PKGBUILD-netbuild | 1 + test/libremakepkg.d/PKGBUILD-netprepare | 17 +++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 test/libremakepkg.d/PKGBUILD-netprepare (limited to 'test') diff --git a/test/libremakepkg-test.sh b/test/libremakepkg-test.sh index 811c8ed..4d8a7c5 100644 --- a/test/libremakepkg-test.sh +++ b/test/libremakepkg-test.sh @@ -33,6 +33,15 @@ it_builds_a_trivial_package() { [[ -f $(echo libretools-hello-1.0-1-any.pkg.tar.?z) ]] } +it_enables_networking_during_prepare() { + require network sudo || return 0 + cp libremakepkg.d/PKGBUILD-netprepare "$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-netprepare-1.0-1-any.pkg.tar.?z) ]] +} it_disables_networking_during_build() { require network sudo || return 0 diff --git a/test/libremakepkg.d/PKGBUILD-netbuild b/test/libremakepkg.d/PKGBUILD-netbuild index c1335a6..7be896b 100644 --- a/test/libremakepkg.d/PKGBUILD-netbuild +++ b/test/libremakepkg.d/PKGBUILD-netbuild @@ -7,6 +7,7 @@ pkgrel=1 arch=(any) build() { + cd "$srcdir" curl https://repo.parabolagnulinux.org/ > index.html } diff --git a/test/libremakepkg.d/PKGBUILD-netprepare b/test/libremakepkg.d/PKGBUILD-netprepare new file mode 100644 index 0000000..90f3e82 --- /dev/null +++ b/test/libremakepkg.d/PKGBUILD-netprepare @@ -0,0 +1,17 @@ +pkgname='libretools-netprepare' +pkgver=1.0 +license=('GPL') +url='https://parabolagnulinux.org' + +pkgrel=1 +arch=(any) + +prepare() { + cd "$srcdir" + curl https://repo.parabolagnulinux.org/ > index.html +} + +package() { + cd "$srcdir" + install -Dm644 index.html "$pkgdir"/usr/share/$pkgname/index.html +} -- cgit v1.2.3-54-g00ecf From f046abd2a4d169e71ebe8eda14f01789b0bafdb0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 5 Mar 2014 18:03:58 -0500 Subject: fix the librefetch unit tests --- test/librefetch-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/librefetch-test.sh b/test/librefetch-test.sh index 92f67a1..7642f91 100644 --- a/test/librefetch-test.sh +++ b/test/librefetch-test.sh @@ -9,7 +9,7 @@ before() { mkdir -p "$HOME" printf '%s\n' \ - 'DLAGENTS+=({https,libre}'\''::/usr/bin/librefetch -p "$BUILDFILE" -- %u %o'\'')' \ + "DLAGENTS+=({https,libre}'::$(which librefetch) -p \"\$BUILDFILE\" -- %u %o')" \ 'BUILDDIR=""' \ > "$HOME/.makepkg.conf" -- cgit v1.2.3-54-g00ecf From 5656c9706cf6f96e0646e9594750d8239e5fcbea Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 5 Mar 2014 18:09:37 -0500 Subject: Fix librefetch tests more. I should not be committing code this tired. --- test/librefetch-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/librefetch-test.sh b/test/librefetch-test.sh index 7642f91..43b7a69 100644 --- a/test/librefetch-test.sh +++ b/test/librefetch-test.sh @@ -15,7 +15,7 @@ before() { mkdir -p "$XDG_CONFIG_HOME/libretools" printf '%s\n' \ - 'MIRROR="phony://example.com/dir/"' \ + 'MIRRORS=("phony://example.com/dir/")' \ 'DOWNLOADER=/usr/bin/false' \ > "$XDG_CONFIG_HOME/libretools/librefetch.conf" } -- cgit v1.2.3-54-g00ecf From b810795b6689ab9e1635af21a48660305b2a7820 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 10 May 2014 22:48:36 -0400 Subject: test/librechroot: 'exit' isn't an executable program. This test worked before because of work-arounds for systemd bugs, it had invoked bash inside of the chroot. --- test/librechroot-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh index c22ac58..43f3143 100644 --- a/test/librechroot-test.sh +++ b/test/librechroot-test.sh @@ -40,7 +40,7 @@ it_respects_exit_status_if_out_isnt_a_tty() ( set -o pipefail libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty r=0 - { testsudo librechroot -l "$roundup_test_name" run exit 3 | cat; } || r=$? + { testsudo librechroot -l "$roundup_test_name" run bash -c 'exit 3' | cat; } || r=$? [[ $r == 3 ]] ) -- cgit v1.2.3-54-g00ecf From 79e4605a163199344df44b8947a15bac9ece75d0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 10 May 2014 22:59:37 -0400 Subject: Add a rough test of file order from librefetch's tarballs. --- test/librefetch-test.sh | 1 + test/librefetch.d/PKGBUILD | 5 ++++- test/librefetch.d/list.txt | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/librefetch-test.sh b/test/librefetch-test.sh index 43b7a69..675299a 100644 --- a/test/librefetch-test.sh +++ b/test/librefetch-test.sh @@ -31,6 +31,7 @@ it_displays_help() { empty $tmpdir/stderr } +# This test also does a rough test of file order in the PKGBUILD it_cleans_src_libre_first() { cp librefetch.d/* "$tmpdir/" cd "$tmpdir" diff --git a/test/librefetch.d/PKGBUILD b/test/librefetch.d/PKGBUILD index 723d82e..db80db3 100644 --- a/test/librefetch.d/PKGBUILD +++ b/test/librefetch.d/PKGBUILD @@ -7,7 +7,10 @@ source=("libre://$pkgname-$pkgver.tar.gz") mksource() { mkdir "$srcdir/bar" - touch "$srcdir/bar/file" + local file + for file in '~foo' '~a' a A; do + touch "$srcdir/bar/$file" + done } package() { diff --git a/test/librefetch.d/list.txt b/test/librefetch.d/list.txt index b04d5d1..9bd32f4 100644 --- a/test/librefetch.d/list.txt +++ b/test/librefetch.d/list.txt @@ -1,2 +1,5 @@ bar/ -bar/file +bar/A +bar/a +bar/~a +bar/~foo -- cgit v1.2.3-54-g00ecf From 6f5910a55f72c5d01a26b685a7a06a6673a2e9f7 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 11 May 2014 01:36:44 -0400 Subject: test/librefetch: inhibit running an installed copy of librefetch --- test/librefetch-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/librefetch-test.sh b/test/librefetch-test.sh index 675299a..9db836b 100644 --- a/test/librefetch-test.sh +++ b/test/librefetch-test.sh @@ -9,7 +9,7 @@ before() { mkdir -p "$HOME" printf '%s\n' \ - "DLAGENTS+=({https,libre}'::$(which librefetch) -p \"\$BUILDFILE\" -- %u %o')" \ + "DLAGENTS=({https,libre}'::$(which librefetch) -p \"\$BUILDFILE\" -- %u %o')" \ 'BUILDDIR=""' \ > "$HOME/.makepkg.conf" -- cgit v1.2.3-54-g00ecf