diff options
Diffstat (limited to 't')
-rwxr-xr-x | t/14-jobs.t | 97 | ||||
-rw-r--r-- | t/LO-jobs/nonexistentslackbuild/Makefile | 8 | ||||
-rw-r--r-- | t/LO-jobs/nonexistentslackbuild/README | 1 | ||||
-rw-r--r-- | t/LO-jobs/nonexistentslackbuild/nonexistentslackbuild.SlackBuild | 20 | ||||
-rw-r--r-- | t/LO-jobs/nonexistentslackbuild/nonexistentslackbuild.info | 10 | ||||
-rw-r--r-- | t/LO-jobs/nonexistentslackbuild/timer1.touch | 0 | ||||
-rw-r--r-- | t/LO-jobs/nonexistentslackbuild/timer2.touch | 0 |
7 files changed, 136 insertions, 0 deletions
diff --git a/t/14-jobs.t b/t/14-jobs.t new file mode 100755 index 0000000..082a419 --- /dev/null +++ b/t/14-jobs.t @@ -0,0 +1,97 @@ +#!/usr/bin/env perl + +use 5.16.0; +use strict; +use warnings FATAL => 'all'; +use Test::More; +use Capture::Tiny qw/ capture_merged /; +use FindBin '$RealBin'; +use lib $RealBin; +use lib "$RealBin/../SBO-Lib/lib"; +use Test::Execute; + +if ($ENV{TEST_INSTALL}) { + plan tests => 4; +} else { + plan skip_all => "Only run these tests if TEST_INSTALL=1"; +} + +$path = "$RealBin/../"; + +sub cleanup { + capture_merged { + system(qw!/sbin/removepkg nonexistentslackbuild!); + unlink "$RealBin/LO-jobs/nonexistentslackbuild/perf.dummy"; + system(qw!rm -rf /tmp/SBo/nonexistentslackbuild-1.0!); + system(qw!rm -rf /tmp/package-nonexistentslackbuild!); + }; +} + +sub set_lo { + state $set = 0; + state $lo; + if ($_[0]) { + if ($set) { script (qw/ sboconfig -o /, $lo, { test => 0 }); } + } else { + ($lo) = script (qw/ sboconfig -l /, { expected => qr/LOCAL_OVERRIDES=(.*)/, test => 0 }); + $lo //= 'FALSE'; + note "Saving original value of LOCAL_OVERRIDES: $lo"; + $set = 1; + script (qw/ sboconfig -o /, "$RealBin/LO-jobs", { test => 0 }); + } +} + +sub set_jobs { + state $set = 0; + state $jobs; + if ($_[0]) { + if ($set) { script (qw/ sboconfig -j /, $jobs, { test => 0 }); } + } else { + ($jobs) = script (qw/ sboconfig -l /, { expected => qr/JOBS=(.*)/, test => 0 }); + $jobs //= 'FALSE'; + note "Saving original value of JOBS: $jobs"; + $set = 1; + script (qw/ sboconfig -j FALSE /, { test => 0 }); + } +} + +cleanup(); +set_lo(); +set_jobs(); + +# 1: sboinstall with jobs set to FALSE +{ + my ($time) = script (qw/ sboinstall -r nonexistentslackbuild /, { expected => qr/\nreal\s+\d+m([0-9.]+)s\n/, test => 0, }); + ok ($time > 5, "jobs set to FALSE took the expected amount of time"); +} +script (qw/ sboremove nonexistentslackbuild /, { input => "y\ny", test => 0 }); + +# 2: sboinstall with jobs set to 2 +script (qw/ sboconfig -j 2 /, { test => 0 }); +{ + my ($time) = script (qw/ sboinstall -r nonexistentslackbuild /, { expected => qr/^real\s+\d+m([\d.]+)s$/m, test => 0 }); + ok ($time < 5, "jobs set to 2 took less time than otherwise"); +} +script (qw/ sboremove nonexistentslackbuild /, { input => "y\ny", test => 0 }); + +# 3: sboinstall -j FALSE with jobs set to 2 +{ + my ($time) = script (qw/ sboinstall -j FALSE -r nonexistentslackbuild /, { expected => qr/^real\s+\d+m([\d.]+)s$/m, test => 0 }); + ok ($time > 5, "-j FALSE took the expected amount of time"); +} +script (qw/ sboremove nonexistentslackbuild /, { input => "y\ny", test => 0 }); + +# 4: sboinstall -j 2 with jobs set to FALSE +script (qw/ sboconfig -j FALSE /, { test => 0 }); +{ + my ($time) = script (qw/ sboinstall -j 2 -r nonexistentslackbuild /, { expected => qr/^real\s+\d+m([\d.]+)s$/m, test => 0 }); + ok ($time < 5, "-j 2 took less time than otherwise"); +} +script (qw/ sboremove nonexistentslackbuild /, { input => "y\ny", test => 0 }); + +# Cleanup +END { + set_jobs('delete'); + set_lo('delete'); + cleanup(); +} diff --git a/t/LO-jobs/nonexistentslackbuild/Makefile b/t/LO-jobs/nonexistentslackbuild/Makefile new file mode 100644 index 0000000..ab04c6c --- /dev/null +++ b/t/LO-jobs/nonexistentslackbuild/Makefile @@ -0,0 +1,8 @@ +timers: timer1 timer2 + rm timer1 timer2 + +timer1: timer1.touch + sleep 3 && touch timer1 + +timer2: timer2.touch + sleep 3 && touch timer2 diff --git a/t/LO-jobs/nonexistentslackbuild/README b/t/LO-jobs/nonexistentslackbuild/README new file mode 100644 index 0000000..6d388bb --- /dev/null +++ b/t/LO-jobs/nonexistentslackbuild/README @@ -0,0 +1 @@ +This doesn't exist! diff --git a/t/LO-jobs/nonexistentslackbuild/nonexistentslackbuild.SlackBuild b/t/LO-jobs/nonexistentslackbuild/nonexistentslackbuild.SlackBuild new file mode 100644 index 0000000..9c30654 --- /dev/null +++ b/t/LO-jobs/nonexistentslackbuild/nonexistentslackbuild.SlackBuild @@ -0,0 +1,20 @@ +#!/bin/bash +PRGNAM="nonexistentslackbuild" +VERSION=${VERSION:-1.0} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} +TMP=${TMP:-/tmp/SBo} +OUTPUT=${OUTPUT:-/tmp} + +mkdir -p $TMP/$PRGNAM-$VERSION +cp README Makefile timer1.touch timer2.touch $TMP/$PRGNAM-$VERSION +cd $TMP/$PRGNAM-$VERSION + +time \ +make + +mkdir -p $OUTPUT/package-$PRGNAM/usr/doc/$PRGNAM-$VERSION +cp README $OUTPUT/package-$PRGNAM/usr/doc/$PRGNAM-$VERSION +cd $OUTPUT/package-$PRGNAM + +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-noarch-$BUILD$TAG.tgz diff --git a/t/LO-jobs/nonexistentslackbuild/nonexistentslackbuild.info b/t/LO-jobs/nonexistentslackbuild/nonexistentslackbuild.info new file mode 100644 index 0000000..3454e71 --- /dev/null +++ b/t/LO-jobs/nonexistentslackbuild/nonexistentslackbuild.info @@ -0,0 +1,10 @@ +PRGNAM="nonexistentslackbuild" +VERSION="1.0" +HOMEPAGE="http://www.example.com" +DOWNLOAD="http://pink-mist.github.io/sbotools/testing/perf.dummy" +MD5SUM="9cba6c70fb57a22a155073d54748b614" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +REQUIRES="" +MAINTAINER="Andreas Guldstrand" +EMAIL="doesnt@matter.org" diff --git a/t/LO-jobs/nonexistentslackbuild/timer1.touch b/t/LO-jobs/nonexistentslackbuild/timer1.touch new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/t/LO-jobs/nonexistentslackbuild/timer1.touch diff --git a/t/LO-jobs/nonexistentslackbuild/timer2.touch b/t/LO-jobs/nonexistentslackbuild/timer2.touch new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/t/LO-jobs/nonexistentslackbuild/timer2.touch |