aboutsummaryrefslogtreecommitdiff
path: root/t/05-upgrade.t
diff options
context:
space:
mode:
authorAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-04-22 16:19:34 +0200
committerAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-04-22 16:19:34 +0200
commit92ea9dd42661252181b2d6f2751f8821b567f44e (patch)
tree1d7ec1ec5bc26d46ac572c80bb45a6b844cc0060 /t/05-upgrade.t
parent6e84ae78bc34a7e02ea5f0f8a63b8dac22097877 (diff)
downloadsbotools2-92ea9dd42661252181b2d6f2751f8821b567f44e.tar.xz
t/05-upgrade.t: rewrite to use Test::Sbotools
Diffstat (limited to 't/05-upgrade.t')
-rwxr-xr-xt/05-upgrade.t67
1 files changed, 19 insertions, 48 deletions
diff --git a/t/05-upgrade.t b/t/05-upgrade.t
index 00aa444..7082483 100755
--- a/t/05-upgrade.t
+++ b/t/05-upgrade.t
@@ -7,8 +7,7 @@ use Test::More;
use Capture::Tiny qw/ capture_merged /;
use FindBin '$RealBin';
use lib $RealBin;
-use lib "$RealBin/../SBO-Lib/lib";
-use Test::Execute;
+use Test::Sbotools qw/ make_slackbuilds_txt set_lo sboconfig sboinstall sboupgrade /;
if ($ENV{TEST_INSTALL}) {
plan tests => 14;
@@ -17,8 +16,6 @@ if ($ENV{TEST_INSTALL}) {
}
$ENV{TEST_ONLINE} //= 0;
-$path = "$RealBin/../";
-
sub cleanup {
capture_merged {
system(qw!/sbin/removepkg nonexistentslackbuild!);
@@ -55,87 +52,61 @@ sub cleanup {
};
}
-sub make_slackbuilds_txt {
- state $made = 0;
- my $fname = "/usr/sbo/repo/SLACKBUILDS.TXT";
- if ($_[0]) {
- if ($made) { return system(qw!rm -rf!, $fname); }
- } else {
- if (not -e $fname) { $made = 1; system('mkdir', '-p', '/usr/sbo/repo'); system('touch', $fname); }
- }
-}
-
-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", { test => 0 });
- }
-}
-
cleanup();
make_slackbuilds_txt();
-set_lo();
+set_lo("$RealBin/LO");
sub install {
cleanup();
my $lo = shift;
my @pkgs = @_;
- script (qw/ sboconfig -o /, "$RealBin/LO", { test => 0 });
+ sboconfig '-o', "$RealBin/LO", { test => 0 };
for my $pkg (@pkgs) {
- script (qw/ sboinstall -r /, $pkg, { test => 0 });
+ sboinstall '-r', $pkg, { test => 0 };
}
- script (qw/ sboconfig -o /, "$RealBin/$lo", { test => 0 });
+ sboconfig '-o', "$RealBin/$lo", { test => 0 };
}
# 1-2: sboupgrade nonexistentslackbuild when it doesn't need to be upgraded
install( 'LO', 'nonexistentslackbuild' );
-script (qw/ sboupgrade nonexistentslackbuild /, { expected => '' });
-script (qw/ sboupgrade -f nonexistentslackbuild /, { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild\b.*Upgrade queue: nonexistentslackbuild\n/s });
+sboupgrade 'nonexistentslackbuild', { expected => '' };
+sboupgrade qw/ -f nonexistentslackbuild /, { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild\b.*Upgrade queue: nonexistentslackbuild\n/s };
# 3-7: sboupgrade nonexistentslackbuild4 and 5 when they don't need to be upgraded
install( 'LO', 'nonexistentslackbuild5', 'nonexistentslackbuild4' );
-script (qw/ sboupgrade nonexistentslackbuild4 /, { expected => '' });
-script (qw/ sboupgrade nonexistentslackbuild5 /, { expected => '' });
-script (qw/ sboupgrade -f nonexistentslackbuild4 /, { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild4\b.*Upgrade queue: nonexistentslackbuild4\n/s });
-script (qw/ sboupgrade -f nonexistentslackbuild5 /, { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild5\b.*Upgrade queue: nonexistentslackbuild5\n/s });
-script (qw/ sboupgrade -f -z nonexistentslackbuild4 /, { input => "y\ny\ny", expected => qr/Proceed with nonexistentslackbuild5\b.*Proceed with nonexistentslackbuild4\b.*Upgrade queue: nonexistentslackbuild5 nonexistentslackbuild4\n/s });
+sboupgrade 'nonexistentslackbuild4', { expected => '' };
+sboupgrade qw/ nonexistentslackbuild5 /, { expected => '' };
+sboupgrade qw/ -f nonexistentslackbuild4 /, { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild4\b.*Upgrade queue: nonexistentslackbuild4\n/s };
+sboupgrade qw/ -f nonexistentslackbuild5 /, { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild5\b.*Upgrade queue: nonexistentslackbuild5\n/s };
+sboupgrade qw/ -f -z nonexistentslackbuild4 /, { input => "y\ny\ny", expected => qr/Proceed with nonexistentslackbuild5\b.*Proceed with nonexistentslackbuild4\b.*Upgrade queue: nonexistentslackbuild5 nonexistentslackbuild4\n/s };
# 8: sboupgrade works with nonexistentslackbuild6
install( 'LO2', 'nonexistentslackbuild6' );
-script (qw/ sboupgrade nonexistentslackbuild6 /, { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild6\b.*Upgrade queue: nonexistentslackbuild6\n/s });
+sboupgrade 'nonexistentslackbuild6', { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild6\b.*Upgrade queue: nonexistentslackbuild6\n/s };
# 9: sboupgrade nonexistentslackbuild when it needs to be upgraded
install( 'LO2', 'nonexistentslackbuild' );
-script (qw/ sboupgrade nonexistentslackbuild /, { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild\b.*Upgrade queue: nonexistentslackbuild\n/s });
+sboupgrade 'nonexistentslackbuild', { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild\b.*Upgrade queue: nonexistentslackbuild\n/s };
# 10: sboupgrade nonexistentslackbuild4 and 5 when they need to be upgraded
install( 'LO2', 'nonexistentslackbuild5', 'nonexistentslackbuild4' );
-script (qw/ sboupgrade nonexistentslackbuild4 /, { input => "y\ny\ny", expected => qr/Proceed with nonexistentslackbuild5\b.*Proceed with nonexistentslackbuild4\b.*Upgrade queue: nonexistentslackbuild5 nonexistentslackbuild4\n/s });
+sboupgrade 'nonexistentslackbuild4', { input => "y\ny\ny", expected => qr/Proceed with nonexistentslackbuild5\b.*Proceed with nonexistentslackbuild4\b.*Upgrade queue: nonexistentslackbuild5 nonexistentslackbuild4\n/s };
# 11-12: sboupgrade nonexistentslackbuild4 and 5 when only 5 needs an update
install( 'LO3', 'nonexistentslackbuild5', 'nonexistentslackbuild4' );
-script (qw/ sboupgrade nonexistentslackbuild4 /, { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild5\b.*Upgrade queue: nonexistentslackbuild5\n/s });
+sboupgrade 'nonexistentslackbuild4', { input => "y\ny", expected => qr/Proceed with nonexistentslackbuild5\b.*Upgrade queue: nonexistentslackbuild5\n/s };
install( 'LO3', 'nonexistentslackbuild5', 'nonexistentslackbuild4' );
-script (qw/ sboupgrade -f nonexistentslackbuild4 /, { input => "y\ny\ny", expected => qr/Proceed with nonexistentslackbuild5\b.*Proceed with nonexistentslackbuild4\b.*Upgrade queue: nonexistentslackbuild5 nonexistentslackbuild4\n/s });
+sboupgrade qw/ -f nonexistentslackbuild4 /, { input => "y\ny\ny", expected => qr/Proceed with nonexistentslackbuild5\b.*Proceed with nonexistentslackbuild4\b.*Upgrade queue: nonexistentslackbuild5 nonexistentslackbuild4\n/s };
# 13-14: sboupgrade --all
install( 'LO2', 'nonexistentslackbuild' );
my @sbos = glob("/var/log/packages/*_SBo");
-script (qw/ sboupgrade --all /, { input => ("n\n" x (@sbos+1)), expected => qr/Proceed with nonexistentslackbuild\b/ });
+sboupgrade '--all', { input => ("n\n" x (@sbos+1)), expected => qr/Proceed with nonexistentslackbuild\b/ };
install( 'LO2', 'nonexistentslackbuild', 'nonexistentslackbuild5', 'nonexistentslackbuild4' );
-script(qw/ sboupgrade --all /, { input => ("n\n" x (@sbos+3)), expected => qr/Proceed with nonexistentslackbuild\b.*Proceed with nonexistentslackbuild5\b.*Proceed with nonexistentslackbuild4\b/s });
+sboupgrade '--all', { input => ("n\n" x (@sbos+3)), expected => qr/Proceed with nonexistentslackbuild\b.*Proceed with nonexistentslackbuild5\b.*Proceed with nonexistentslackbuild4\b/s };
# Cleanup
END {
- set_lo('delete');
- make_slackbuilds_txt('delete');
cleanup();
}