aboutsummaryrefslogtreecommitdiff
path: root/t/travis.t
diff options
context:
space:
mode:
Diffstat (limited to 't/travis.t')
-rwxr-xr-xt/travis.t66
1 files changed, 39 insertions, 27 deletions
diff --git a/t/travis.t b/t/travis.t
index feb25f3..11f4c69 100755
--- a/t/travis.t
+++ b/t/travis.t
@@ -22,6 +22,9 @@ sub run {
exit => 0,
cmd => [],
input => undef,
+ test => 1,
+ expected => undef,
+ test => undef,
@_
);
my $cmd = shift @{ $args{cmd} };
@@ -38,40 +41,53 @@ sub run {
}
$ret;
};
- return $output if $return == $exit;
- return "Command $cmd ($path/$cmd) exited with $return instead of $exit";
+ return unless $args{test};
+
+ my $test = $args{test} // "Testing run of $cmd (@{ $args{cmd} })";
+ subtest $test {
+ plan tests => 2;
+
+ is ($return, $exit, "$cmd (@{ $args{cmd} }) exited with correct exitcode");
+
+ my $expected = $args{expected};
+ if (defined $expected and ref $expected eq 'Regexp') {
+ like ($output, $expected, "$cmd produced the correct output");
+ } else {
+ is ($output, $expected, "$cmd produced the correct output");
+ }
+ };
}
# 1-3: Test SLACKWARE_VERSION
-is (run(cmd => [qw/ sboconfig -V 14.1 /]), "Setting SLACKWARE_VERSION to 14.1...\n", 'setting SLACKWARE_VERSION works');
+run (cmd => [qw/ sboconfig -V 14.1 /], expected => "Setting SLACKWARE_VERSION to 14.1...\n");
SKIP: {
skip 'Not doing online tests without TEST_ONLINE=1', 2 if $ENV{TEST_ONLINE} ne '1';
- is (run(cmd => [qw/ sbosnap fetch /]), "Pulling SlackBuilds tree...\n", 'sbosnap fetch works');
- is (run(cmd => [qw/ sbofind sbotools /]), "SBo: sbotools\nPath: /usr/sbo/repo/system/sbotools\n\n", 'sbofind works');
+ run (cmd => [qw/ sbosnap fetch /], expected => "Pulling SlackBuilds tree...\n");
+ run (cmd => [qw/ sbofind sbotools /], expected => "SBo: sbotools\nPath: /usr/sbo/repo/system/sbotools\n\n");
}
# 4-10: Test alternative REPO
is (system(qw!rm -rf /usr/sbo!), 0, 'Removing /usr/sbo works');
ok (! -e "/usr/sbo/repo/SLACKBUILDS.TXT", "SLACKBUILDS.TXT doesn't exist");
-is (run(cmd => [qw! sboconfig -r https://github.com/Ponce/slackbuilds.git !]), "Setting REPO to https://github.com/Ponce/slackbuilds.git...\n", 'setting REPO works');
+run (cmd => [qw! sboconfig -r https://github.com/Ponce/slackbuilds.git !], expected => "Setting REPO to https://github.com/Ponce/slackbuilds.git...\n", test => 'Alternative REPO');
SKIP: {
skip 'Not doing online tests without TEST_ONLINE=1', 4 if $ENV{TEST_ONLINE} ne '1';
- like (run(cmd => [qw/ sbosnap fetch /]), qr!Pulling SlackBuilds tree.*Cloning into '/usr/sbo/repo'!s, 'sbosnap fetch works from alternative REPO');
+ run (cmd => [qw/ sbosnap fetch /], expected => qr!Pulling SlackBuilds tree.*Cloning into '/usr/sbo/repo'!s);
ok (-e "/usr/sbo/repo/SLACKBUILDS.TXT", "SLACKBUILDS.TXT exists (REPO)");
ok (! -e "/usr/sbo/repo/SLACKBUILDS.TXT.gz", "SLACKBUILDS.TXT.gz doesn't exist (REPO)");
- is (run(cmd => [qw/ sbofind sbotools /]), "SBo: sbotools\nPath: /usr/sbo/repo/system/sbotools\n\n", 'sbofind works');
+ run (cmd => [qw/ sbofind sbotools /], expected => "SBo: sbotools\nPath: /usr/sbo/repo/system/sbotools\n\n");
}
# 11-17: Test local overrides
-is (run(cmd => [qw/ sboconfig -o /, "$RealBin/LO"]), "Setting LOCAL_OVERRIDES to $RealBin/LO...\n", 'setting LOCAL_OVERRIDES works');
+run (cmd => [qw/ sboconfig -o /, "$RealBin/LO"], expected => "Setting LOCAL_OVERRIDES to $RealBin/LO...\n", test => 'LOCAL_OVERRIDES');
my $skip = 0;
SKIP: {
if ($ENV{TEST_ONLINE} ne '1') { $skip = !(system(qw! mkdir -p /usr/sbo/repo !) == 0 and system(qw! touch /usr/sbo/repo/SLACKBUILDS.TXT !) == 0) }
skip "Online testing disabled (TEST_ONLINE!=1) and could not create dummy SLACKBUILDS.TXT", 9 if $skip;
- is (run(cmd => [qw/ sbofind nonexistentslackbuild /]), <<"LOCAL", "sbofind finds local overrides");
+ run (cmd => [qw/ sbofind nonexistentslackbuild /], expected => <<"LOCAL");
Local: nonexistentslackbuild5
Path: /home/travis/build/pink-mist/sbotools/t/LO/nonexistentslackbuild5
@@ -85,17 +101,15 @@ Local: nonexistentslackbuild
Path: $RealBin/LO/nonexistentslackbuild
LOCAL
- like (run(cmd => [qw/ sboinstall -r nonexistentslackbuild /]),
- qr/nonexistentslackbuild added to install queue[.].*perf[.]dummy' saved.*Cleaning for nonexistentslackbuild-1[.]0/s, 'sboinstall works (LOCAL_OVERRIDES)');
- like (run(cmd => [qw/ sboremove --nointeractive nonexistentslackbuild /]), qr/Removing 1 package\(s\).*nonexistentslackbuild.*All operations have completed/s, 'sboremove works');
+ run (cmd => [qw/ sboinstall -r nonexistentslackbuild /]),
+ expected => qr/nonexistentslackbuild added to install queue[.].*perf[.]dummy' saved.*Cleaning for nonexistentslackbuild-1[.]0/s);
+ run (cmd => [qw/ sboremove --nointeractive nonexistentslackbuild /], expected => qr/Removing 1 package\(s\).*nonexistentslackbuild.*All operations have completed/s);
is (system(qw!/sbin/installpkg nonexistentslackbuild-0.9-noarch-1_SBo.tgz!), 0, 'Old version fake installed');
- like (run(cmd => [qw/ sbocheck /]), qr/Updating SlackBuilds tree.*Checking for updated SlackBuilds.*nonexistentslackbuild 0[.]9.*needs updating/s, 'sbocheck finds old version');
- like (run(cmd => [qw/ sboupgrade -r nonexistentslackbuild /]),
- qr/nonexistentslackbuild added to upgrade queue.*Upgrade queue: nonexistentslackbuild/s, 'sboupgrade upgrades old version');
+ run (cmd => [qw/ sbocheck /], expected => qr/Updating SlackBuilds tree.*Checking for updated SlackBuilds.*nonexistentslackbuild 0[.]9.*needs updating/s);
+ run (cmd => [qw/ sboupgrade -r nonexistentslackbuild /]), expected => qr/nonexistentslackbuild added to upgrade queue.*Upgrade queue: nonexistentslackbuild/s);
# 18: Test missing dep
- is (run(cmd => [qw/ sboinstall nonexistentslackbuilds2 /], input => 'y', exit => 1),
- "Unable to locate nonexistentslackbuild3 in the SlackBuilds.org tree.\n", 'sboinstall nonexistentslackbuild2 has correct output and exitcode');
+ run(cmd => [qw/ sboinstall nonexistentslackbuilds2 /], input => 'y', exit => 1, expected => "Unable to locate nonexistentslackbuild3 in the SlackBuilds.org tree.\n");
}
# 19-23: Test sboupgrade --all
@@ -112,26 +126,24 @@ SKIP: {
skip 'Cannot test if nonexistentslackbuild is already installed', 4 if @files;
is (system(qw!/sbin/installpkg nonexistentslackbuild-0.9-noarch-1_SBo.tgz!), 0, 'installpkg old version works');
- like (run(cmd => [qw/ sboupgrade -r --all /]),
- qr/Checking for updated SlackBuilds.*nonexistentslackbuild added to upgrade queue.*Cleaning for nonexistentslackbuild/s, 'sboupgrade --all works');
+ run (cmd => [qw/ sboupgrade -r --all /], expected => qr/Checking for updated SlackBuilds.*nonexistentslackbuild added to upgrade queue.*Cleaning for nonexistentslackbuild/s);
ok (-e "/var/log/packages/nonexistentslackbuild-1.0-noarch-1_SBo", 'updated package is installed');
ok (! -e "/var/log/packages/nonexistentslackbuild-0.9-noarch-1_SBo", 'old package is removed');
}
if (not glob("/var/log/packages/nonexistentslackbuild-*")) {
- run(cmd => [qw/ sboinstall -r nonexistentslackbuild /]);
+ run (cmd => [qw/ sboinstall -r nonexistentslackbuild /], test => 0);
}
if (not glob("/var/log/packages/nonexistentslackbuild4-*")) {
- run(cmd => [qw/ sboinstall nonexistentslackbuild4 /], input => "y\ny\ny");
+ run (cmd => [qw/ sboinstall nonexistentslackbuild4 /], input => "y\ny\ny", test => 0);
}
# 24-25: Test sboupgrade -f
-like (run(cmd => [qw/ sboupgrade -f nonexistentslackbuild /], input => "y\ny"), qr/Proceed with nonexistentslackbuild\?.*Upgrade queue: nonexistentslackbuild\n/s, 'sboupgrade -f works');
-like (run(cmd => [qw/ sboupgrade -f nonexistentslackbuild4 /], input => "y\ny"), qr/Proceed with nonexistentslackbuild4\?.*Upgrade queue: nonexistentslackbuild4\n/s, 'sboupgrade -f with requirements works');
+run (cmd => [qw/ sboupgrade -f nonexistentslackbuild /], input => "y\ny", expected => qr/Proceed with nonexistentslackbuild\?.*Upgrade queue: nonexistentslackbuild\n/s);
+run (cmd => [qw/ sboupgrade -f nonexistentslackbuild4 /], input => "y\ny"), expected => qr/Proceed with nonexistentslackbuild4\?.*Upgrade queue: nonexistentslackbuild4\n/s);
# 26: Test sboupgrade -f -z
-like (run(cmd => [qw/ sboupgrade -f -z nonexistentslackbuild4 /], input => "y\ny\ny"),
- qr/nonexistentslackbuild5 added to upgrade queue.*nonexistentslackbuild4 added to upgrade queue.*Upgrade queue: nonexistentslackbuild5 nonexistentslackbuild4\n/s,
- 'sboupgrade -f -z works with requirements');
+run (cmd => [qw/ sboupgrade -f -z nonexistentslackbuild4 /], input => "y\ny\ny",
+ expected => qr/nonexistentslackbuild5 added to upgrade queue.*nonexistentslackbuild4 added to upgrade queue.*Upgrade queue: nonexistentslackbuild5 nonexistentslackbuild4\n/s);
# Cleanup
capture_merged {