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/libremakepkg-test.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'test/libremakepkg-test.sh') 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 -- cgit v1.2.3-2-g168b 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/libremakepkg-test.sh') 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-2-g168b 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 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test/libremakepkg-test.sh') 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 -- cgit v1.2.3-2-g168b 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/libremakepkg-test.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test/libremakepkg-test.sh') 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 } -- cgit v1.2.3-2-g168b 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 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/libremakepkg-test.sh') 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 -- cgit v1.2.3-2-g168b