From c91f7e14f11795d3c077182b6d475990b288f35a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 30 Sep 2018 03:25:41 -0400 Subject: test: Add globfile() to make it easy to check if a file matching a glob exists --- test/libremakepkg-test.sh | 28 ++++++++++++++-------------- test/librestage-test.sh | 8 ++++---- test/test-common.sh | 4 ++++ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/test/libremakepkg-test.sh b/test/libremakepkg-test.sh index a1955bc..fd4c742 100644 --- a/test/libremakepkg-test.sh +++ b/test/libremakepkg-test.sh @@ -11,7 +11,7 @@ it_builds_a_trivial_package() { 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) ]] + globfile libretools-hello-1.0-1-any.pkg.tar.?z } it_disables_networking_during_prepare() { @@ -21,9 +21,9 @@ it_disables_networking_during_prepare() { libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty not testsudo libremakepkg -l "$roundup_test_name" - not [[ -f $(echo libretools-netprepare-1.0-1-any.pkg.tar.?z) ]] + not globfile libretools-netprepare-1.0-1-any.pkg.tar.?z testsudo libremakepkg -l "$roundup_test_name" -N - [[ -f $(echo libretools-netprepare-1.0-1-any.pkg.tar.?z) ]] + globfile libretools-netprepare-1.0-1-any.pkg.tar.?z } it_disables_networking_during_build() { @@ -33,9 +33,9 @@ it_disables_networking_during_build() { libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty not testsudo libremakepkg -l "$roundup_test_name" - not [[ -f $(echo libretools-netbuild-1.0-1-any.pkg.tar.?z) ]] + not globfile 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) ]] + globfile libretools-netbuild-1.0-1-any.pkg.tar.?z } it_disables_networking_during_package() { @@ -45,9 +45,9 @@ it_disables_networking_during_package() { libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty not testsudo libremakepkg -l "$roundup_test_name" - not [[ -f $(echo libretools-netpackage-1.0-1-any.pkg.tar.?z) ]] + not globfile 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) ]] + globfile libretools-netpackage-1.0-1-any.pkg.tar.?z } it_cleans_the_chroot_before_building() { @@ -93,7 +93,7 @@ it_handles_PKGDEST_not_existing() { 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) ]] + globfile dest/pkgdest/libretools-hello-1.0-1-any.pkg.tar.?z } it_displays_help_as_normal_user() { @@ -145,14 +145,14 @@ it_detects_distcc_files() { # first make sure that the engine works testsudo libremakepkg -l "$roundup_test_name" - [[ -f $(echo libretools-hello-1.0-1-any.pkg.tar.?z) ]] + globfile libretools-hello-1.0-1-any.pkg.tar.?z rm -f -- libretools-hello-1.0-1-any.pkg.tar.?z # now throw a wrench in it testsudo librechroot -l "$roundup_test_name" run touch /bin/distcc-tool # and make sure that the engine broke testsudo libremakepkg -l "$roundup_test_name" || status=$? [[ $status != 0 ]] - not [[ -f $(echo libretools-hello-1.0-1-any.pkg.tar.?z) ]] + not globfile libretools-hello-1.0-1-any.pkg.tar.?z } it_doesnt_symlink_outputs() { @@ -175,8 +175,8 @@ it_doesnt_symlink_outputs() { not stat libretools-hello-1.0-1-any.pkg.tar.?z not stat libretools-hello-1.0-1-any.src.tar.?z - [[ -f $(echo "$tmpdir/workdir/pkgdest"/libretools-hello-1.0-1-any.pkg.tar.?z) ]] - [[ -f $(echo "$tmpdir/workdir/srcpkgdest"/libretools-hello-1.0-1-any.src.tar.?z) ]] + globfile "$tmpdir/workdir/pkgdest"/libretools-hello-1.0-1-any.pkg.tar.?z + globfile "$tmpdir/workdir/srcpkgdest"/libretools-hello-1.0-1-any.src.tar.?z } it_succeeds_with_good_signatures() { @@ -214,8 +214,8 @@ it_does_not_run_pkgver() { libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty testsudo libremakepkg -l "$roundup_test_name" - [[ -f $(echo libretools-pkgver-1-1-any.pkg.tar.?z) ]] - not [[ -f $(echo libretools-pkgver-2-1-any.pkg.tar.?z) ]] + globfile libretools-pkgver-1-1-any.pkg.tar.?z + not globfile libretools-pkgver-2-1-any.pkg.tar.?z popd diff -u libremakepkg.d/PKGBUILD-pkgver "$tmpdir/PKGBUILD" } diff --git a/test/librestage-test.sh b/test/librestage-test.sh index 4f617ca..d52cbea 100644 --- a/test/librestage-test.sh +++ b/test/librestage-test.sh @@ -59,8 +59,8 @@ it_guesses_the_repo() { 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) ]] + globfile $tmpdir/workdir/staging/reponame/libretools-hello-1.0-1-any.pkg.tar.?z + $nochroot || globfile $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar.?z } it_stages_packages_without_PKGDEST() { @@ -83,6 +83,6 @@ it_stages_packages_without_PKGDEST() { 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) ]] + globfile $tmpdir/workdir/staging/repo1/libretools-hello-1.0-1-any.pkg.tar.?z + $nochroot || globfile $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar.?z } diff --git a/test/test-common.sh b/test/test-common.sh index 64ff660..81c8557 100755 --- a/test/test-common.sh +++ b/test/test-common.sh @@ -112,3 +112,7 @@ equals() { IFS= read -rd '' stdin || : [[ $1 == "$stdin" ]] } + +globfile() { + [[ -f $1 ]] +} -- cgit v1.2.2