aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rwxr-xr-xt/01-unit.t33
-rwxr-xr-xt/03-travis.t20
-rwxr-xr-xt/04-install.t6
-rwxr-xr-xt/05-upgrade.t22
-rwxr-xr-xt/07-fail.t2
-rwxr-xr-xt/09-multilib.t8
-rwxr-xr-xt/11-git.t33
-rwxr-xr-xt/12-readme.t11
-rwxr-xr-xt/15-usage.t11
-rwxr-xr-xt/17-find.t4
-rwxr-xr-xt/28-race-sboremove.t2
-rwxr-xr-xt/29-unit-sboremove.t35
-rwxr-xr-xt/31-template.t43
-rw-r--r--t/32-info.t55
-rw-r--r--t/LO-multilib/multilibsbowithcommandinreadme/README4
-rw-r--r--t/LO-readme/commandinreadme/README4
-rw-r--r--t/LO-readme/commandinreadmespanslines/README5
-rw-r--r--t/LO-readme/commandinreadmespanslines/commandinreadmespanslines.SlackBuild20
-rw-r--r--t/LO-readme/commandinreadmespanslines/commandinreadmespanslines.info10
-rw-r--r--t/LO-readme/otherreadmes/README1
-rw-r--r--t/LO-readme/otherreadmes/README.SBo1
-rw-r--r--t/LO-readme/otherreadmes/README.SLACKWARE1
-rw-r--r--t/LO-readme/otherreadmes/otherreadmes.SlackBuild15
-rw-r--r--t/LO-readme/otherreadmes/otherreadmes.info10
-rw-r--r--t/LO/locale-versionsbo/README1
-rw-r--r--t/LO/locale-versionsbo/locale-versionsbo.SlackBuild16
-rw-r--r--t/LO/locale-versionsbo/locale-versionsbo.info10
27 files changed, 287 insertions, 96 deletions
diff --git a/t/01-unit.t b/t/01-unit.t
index 13d6e8e..f1aabb0 100755
--- a/t/01-unit.t
+++ b/t/01-unit.t
@@ -11,7 +11,7 @@ use Capture::Tiny qw/ capture_merged /;
use File::Temp 'tempdir';
use Cwd;
-plan tests => 60;
+plan tests => 61;
# 1-2: test script_error();
{
@@ -196,12 +196,6 @@ SKIP: {
is (SBO::Lib::generate_slackbuilds_txt(), 1, 'generate_slackbuilds_txt() returned 1');
system(qw! rm -r /usr/sbo/repo !) if -d '/usr/sbo/repo';
-
- local $config{REPO} = '';
- capture_merged { SBO::Lib::pull_sbo_tree(); };
- ok (!-e '/usr/sbo/repo/SLACKBUILDS.TXT', 'SLACKBUILDS.TXT was not generated by pull_sbo_tree()');
-
- system(qw! rm -r /usr/sbo/repo !) if -d '/usr/sbo/repo';
system(qw! mv /usr/sbo/backup /usr/sbo/repo !) if -d '/usr/sbo/backup';
my $sbohome = '/usr/sbo';
@@ -218,7 +212,7 @@ SKIP: {
system('mv', "$sbohome.bak", $sbohome);
}
-# 38: test get_installed_packages();
+# 37: test get_installed_packages();
{
system(qw!mv /var/log/packages /var/log/packages.backup!);
system(qw!mkdir -p /var/log/packages!);
@@ -228,7 +222,7 @@ SKIP: {
system(qw!mv /var/log/packages.backup /var/log/packages!);
}
-# 39-41: test get_sbo_location() and get_sbo_locations();
+# 38-40: test get_sbo_location() and get_sbo_locations();
{
my $exit;
my $out = capture_merged { $exit = exit_code { get_sbo_location([]); }; };
@@ -245,18 +239,18 @@ SKIP: {
}
}
-# 42: test get_local_outdated_versions();
+# 41: test get_local_outdated_versions();
{
local $config{LOCAL_OVERRIDES} = 'FALSE';
is(scalar get_local_outdated_versions(), 0, 'get_local_outdated_versions() returned an empty list');
}
-# 43: test get_filename_from_link();
+# 42: test get_filename_from_link();
{
is (SBO::Lib::get_filename_from_link('/'), undef, "get_filename_from_link() returned undef");
}
-# 44-47: test revert_slackbuild();
+# 43-46: test revert_slackbuild();
{
my $tmp = tempdir(CLEANUP => 1);
is (SBO::Lib::revert_slackbuild("$tmp/foo"), 1, "revert_slackbuild() returned 1");
@@ -267,7 +261,7 @@ SKIP: {
ok (!-f "$tmp/foo.orig", 'foo.orig is no more');
}
-# 48: test get_src_dir();
+# 47: test get_src_dir();
SKIP: {
skip 'Test invalid if /foo-bar exists.', 1 if -e '/foo-bar';
my $scalar = '';
@@ -277,13 +271,13 @@ SKIP: {
is (scalar @{ SBO::Lib::get_src_dir($fh) }, 0, "get_src_dir() returned an empty array ref");
}
-# 49: test get_readme_contents();
+# 48: test get_readme_contents();
{
my @ret = get_readme_contents(undef);
is ($ret[0], undef, "get_readme_contents() returned undef");
}
-# 50-51: test user_prompt();
+# 49-50: test user_prompt();
{
my $exit;
my $out = capture_merged { $exit = exit_code { user_prompt('foo', undef); }; };
@@ -292,7 +286,7 @@ SKIP: {
is ($out, "Unable to locate foo in the SlackBuilds.org tree.\n", 'user_prompt() gave correct output');
}
-# 52-54: test perform_sbo();
+# 51-53: test perform_sbo();
SKIP: {
skip 'Tests invalid if /foo exists.', 3 if -e "/foo";
@@ -303,7 +297,7 @@ SKIP: {
is ($res[2], 6, 'perform_sbo returned correct exit');
}
-# 55-59: test version_cmp();
+# 54-60: test version_cmp();
{
chomp(my $kv = `uname -r`);
$kv =~ s/-/_/g;
@@ -319,9 +313,12 @@ SKIP: {
local *SBO::Lib::Util::get_kernel_version = sub { "foo_bar" };
is (SBO::Lib::version_cmp('1.0', '1.0_foo_bar'), 0, "version_cmp(1.0, 1.0_foo_bar) returned 0");
+
+ is (SBO::Lib::version_cmp('1.0_en_US', '1.0'), 0, "version_cmp(1.0_en_US, 1.0) returned 0");
+ is (SBO::Lib::version_cmp('1.0', '1.0_en_US'), 0, "version_cmp(1.0, 1.0_en_US) returned 0");
}
-# 60: test check_multilib();
+# 61: test check_multilib();
{
my $file = "/etc/profile.d/32dev.sh";
diff --git a/t/03-travis.t b/t/03-travis.t
index d5bd2d1..4b77313 100755
--- a/t/03-travis.t
+++ b/t/03-travis.t
@@ -26,7 +26,7 @@ SKIP: {
skip 'Not doing online tests without TEST_ONLINE=1', 2 if $ENV{TEST_ONLINE} ne '1';
sbosnap 'fetch', { expected => qr/\APulling SlackBuilds tree\.\.\.\n/ };
- sbofind 'sbotools', { expected => "SBo: sbotools\nPath: /usr/sbo/repo/system/sbotools\n\n" };
+ sbofind 'sbotools', { expected => "SBo: sbotools 1.9\nPath: /usr/sbo/repo/system/sbotools\n\n" };
}
# 4-10: Test alternative REPO
@@ -39,7 +39,7 @@ SKIP: {
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)");
- sbofind 'sbotools', { expected => "SBo: sbotools\nPath: /usr/sbo/repo/system/sbotools\n\n" };
+ sbofind 'sbotools', { expected => qr"SBo: sbotools .*\nPath: /usr/sbo/repo/system/sbotools\n\n" };
}
# 11-17: Test local overrides
@@ -50,30 +50,30 @@ SKIP: {
skip "Online testing disabled (TEST_ONLINE!=1) and could not create dummy SLACKBUILDS.TXT", 9 if $skip;
sbofind 'nonexistentslackbuild', { expected => sub {
-m!\QLocal: nonexistentslackbuild6
+m!\QLocal: nonexistentslackbuild6 1.0
Path: $RealBin/LO/nonexistentslackbuild6!
and
-m!\QLocal: nonexistentslackbuild5
+m!\QLocal: nonexistentslackbuild5 1.0
Path: $RealBin/LO/nonexistentslackbuild5!
and
-m!\QLocal: nonexistentslackbuild4
+m!\QLocal: nonexistentslackbuild4 1.0
Path: $RealBin/LO/nonexistentslackbuild4!
and
-m!\QLocal: nonexistentslackbuild2
+m!\QLocal: nonexistentslackbuild2 1.0
Path: $RealBin/LO/nonexistentslackbuild2!
and
-m!\QLocal: nonexistentslackbuild7
+m!\QLocal: nonexistentslackbuild7 1.0
Path: $RealBin/LO/nonexistentslackbuild7!
and
-m!\QLocal: nonexistentslackbuild
+m!\QLocal: nonexistentslackbuild 1.0
Path: $RealBin/LO/nonexistentslackbuild!
and
-m!\QLocal: nonexistentslackbuild8
+m!\QLocal: nonexistentslackbuild8 1.0
Path: $RealBin/LO/nonexistentslackbuild8!
} };
sboinstall qw/ -r nonexistentslackbuild /,
- { expected => qr/nonexistentslackbuild added to install queue[.].*perf[.]dummy' saved.*Cleaning for nonexistentslackbuild-1[.]0/s };
+ { expected => qr/nonexistentslackbuild added to install queue[.].*perf[.]dummy.* saved.*Cleaning for nonexistentslackbuild-1[.]0/s };
sboremove qw/ --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');
sbocheck { expected => qr/Updating SlackBuilds tree.*Checking for updated SlackBuilds.*nonexistentslackbuild 0[.]9.*needs updating/s };
diff --git a/t/04-install.t b/t/04-install.t
index ea7b07c..f1f922f 100755
--- a/t/04-install.t
+++ b/t/04-install.t
@@ -10,7 +10,7 @@ use lib $RealBin;
use Test::Sbotools qw/ make_slackbuilds_txt set_lo sboinstall sboremove restore_perf_dummy /;
if ($ENV{TEST_INSTALL}) {
- plan tests => 20;
+ plan tests => 22;
} else {
plan skip_all => 'Only run these tests if TEST_INSTALL=1';
}
@@ -112,6 +112,10 @@ sboinstall 'perl-nonexistentcpan', { input => "n", expected => qr/Proceed with p
sboinstall '-p', 'foo', { expected => "compat32 only works on x86_64.\n", exit => 1 };
}
+# 21-22: check --reinstall option
+sboinstall '--reinstall', 'nonexistentslackbuild', { input => "n", expected => qr/\Qnonexistentslackbuild (nonexistentslackbuild-1.0-noarch-1_SBo) is already installed. Do you want to reinstall from SBo? [n]\E/ };
+sboinstall '--reinstall', 'nonexistentslackbuild', { input => "y\ny\ny", expected => qr/nonexistentslackbuild .* is already installed[.] Do you want to reinstall.*Install queue: nonexistentslackbuild/s };
+
# Cleanup
END {
cleanup();
diff --git a/t/05-upgrade.t b/t/05-upgrade.t
index b7e1e29..44037c6 100755
--- a/t/05-upgrade.t
+++ b/t/05-upgrade.t
@@ -11,7 +11,7 @@ use Test::Sbotools qw/ make_slackbuilds_txt set_lo sboconfig sboinstall sboupgra
use File::Temp 'tempdir';
if ($ENV{TEST_INSTALL}) {
- plan tests => 20;
+ plan tests => 21;
} else {
plan skip_all => 'Only run these tests if TEST_INSTALL=1';
}
@@ -25,12 +25,14 @@ sub cleanup {
system(qw!/sbin/removepkg nonexistentslackbuild5!);
system(qw!/sbin/removepkg nonexistentslackbuild6!);
system(qw!/sbin/removepkg weird-versionsbo!);
+ system(qw!/sbin/removepkg locale-versionsbo!);
unlink "$RealBin/LO/nonexistentslackbuild/perf.dummy";
unlink "$RealBin/LO/nonexistentslackbuild2/perf.dummy";
unlink "$RealBin/LO/nonexistentslackbuild4/perf.dummy";
unlink "$RealBin/LO/nonexistentslackbuild5/perf.dummy";
unlink "$RealBin/LO/nonexistentslackbuild6/perf.dummy";
unlink "$RealBin/LO/weird-versionsbo/perf.dummy";
+ unlink "$RealBin/LO/locale-versionsbo/perf.dummy";
unlink "$RealBin/LO2/nonexistentslackbuild/perf.dummy";
unlink "$RealBin/LO2/nonexistentslackbuild2/perf.dummy";
unlink "$RealBin/LO2/nonexistentslackbuild4/perf.dummy";
@@ -50,6 +52,7 @@ sub cleanup {
system(qw!rm -rf /tmp/SBo/nonexistentslackbuild5-1.0!);
system(qw!rm -rf /tmp/SBo/nonexistentslackbuild6-1.0!);
system(qw!rm -rf /tmp/SBo/weird-versionsbo-1.0!);
+ system(qw!rm -rf /tmp/SBo/locale-versionsbo-1.0!);
system(qw!rm -rf /tmp/SBo/nonexistentslackbuild-1.1!);
system(qw!rm -rf /tmp/SBo/nonexistentslackbuild2-1.1!);
system(qw!rm -rf /tmp/SBo/nonexistentslackbuild4-1.1!);
@@ -61,6 +64,7 @@ sub cleanup {
system(qw!rm -rf /tmp/package-nonexistentslackbuild5!);
system(qw!rm -rf /tmp/package-nonexistentslackbuild6!);
system(qw!rm -rf /tmp/package-weird-versionsbo!);
+ system(qw!rm -rf /tmp/package-locale-versionsbo!);
};
}
@@ -112,13 +116,13 @@ sboupgrade 'nonexistentslackbuild4', { input => "y\ny", expected => qr/Proceed w
install( 'LO3', 'nonexistentslackbuild5', 'nonexistentslackbuild4' );
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-15: sboupgrade --all
+# 13-16: sbosnap + sboupgrade --all
my $temp = tempdir(CLEANUP => 1);
set_repo("file://$temp");
capture_merged { system <<"END"; };
cd $temp; git init;
END
-sbosnap 'fetch', { test => 0 };
+sbosnap 'fetch', { expected => qr/Pulling SlackBuilds tree[.][.][.]/ };
install( 'LO2', 'nonexistentslackbuild' );
my @sbos = glob("/var/log/packages/*_SBo");
sboupgrade '--all', { input => ("n\n" x (@sbos+1)), expected => qr/Proceed with nonexistentslackbuild\b/ };
@@ -129,19 +133,19 @@ sboupgrade '--all', { expected => "Checking for updated SlackBuilds...\nNothing
cleanup();
-# 16: sboupgrade --all shouldn't pick up weird-versionsbo
-install('LO', 'weird-versionsbo');
-sboupgrade '--all', { input => ("n\n" x (@sbos+1)), expected => sub { not /weird-versionsbo/ } };
+# 17: sboupgrade --all shouldn't pick up weird-versionsbo or locale-versionsbo
+install('LO', 'weird-versionsbo', 'locale-versionsbo');
+sboupgrade '--all', { input => ("n\n" x (@sbos+1)), expected => sub { not /weird-versionsbo/ and not /locale-versionsbo/ } };
-# 17-18: sboupgrade -r -f both something installed and something not installed
+# 18-19: sboupgrade -r -f both something installed and something not installed
install('LO', 'nonexistentslackbuild');
sboupgrade qw/ -r -f nonexistentslackbuild /, { expected => qr/^Upgrade queue: nonexistentslackbuild$/m };
sboupgrade qw/ -r -f nonexistentslackbuild2 /, { expected => "" };
-# 19: sboupgrade -r on something already up to date
+# 20: sboupgrade -r on something already up to date
sboupgrade qw/ -r nonexistentslackbuild /, { expected => "" };
-# 20: sboupgrade and answer weirdly and use a default and then answer no twice
+# 21: sboupgrade and answer weirdly and use a default and then answer no twice
install('LO2', 'nonexistentslackbuild', 'nonexistentslackbuild5');
sboupgrade qw/nonexistentslackbuild nonexistentslackbuild5/, { input => "foo\n\nn\nn\n", expected => qr/Proceed with nonexistentslackbuild\?.*Proceed with nonexistentslackbuild\?.*Proceed with nonexistentslackbuild5\?.*Upgrade queue: nonexistentslackbuild$/sm };
diff --git a/t/07-fail.t b/t/07-fail.t
index a7d2a45..6798446 100755
--- a/t/07-fail.t
+++ b/t/07-fail.t
@@ -126,7 +126,7 @@ sboinstall 'malformed-noinfo', { expected => "get_from_info: could not read $Rea
# 11-13: Malformed slackbuild - malformed .info
sboinstall 'malformed-info', { input => "y\ny\nn", expected => qr!Failures:\n malformed-info: Unable to get download info from $RealBin/LO-fail/malformed-info/malformed-info[.]info\n!, exit => 7 };
sboinstall 'malformed-info2', { input => "y\ny\nn", expected => qr!Failures:\n malformed-info2: Unable to get download info from $RealBin/LO-fail/malformed-info2/malformed-info2[.]info\n!, exit => 7 };
-sboinstall 'malformed-info3', { exit => 2, expected => "A fatal script error has occurred:\nerror when parsing malformed-info3.info file. Line: FAIL\nExiting.\n" };
+sboinstall 'malformed-info3', { exit => 2, expected => "A fatal script error has occurred:\nerror when parsing malformed-info3.info file.\nExiting.\n" };
# 14-15: Malformed slackbuild - no readme
sboinstall 'malformed-readme', { expected => "Unable to open README for malformed-readme.\n", exit => 6 };
diff --git a/t/09-multilib.t b/t/09-multilib.t
index 470b0a9..22306c0 100755
--- a/t/09-multilib.t
+++ b/t/09-multilib.t
@@ -7,12 +7,12 @@ use Test::More;
use Capture::Tiny qw/ capture_merged /;
use FindBin '$RealBin';
use lib $RealBin;
-use Test::Sbotools qw/ make_slackbuilds_txt set_lo sboinstall sboclean restore_perf_dummy /;
+use Test::Sbotools qw/ make_slackbuilds_txt set_lo sboinstall sboclean sboremove restore_perf_dummy /;
use File::Temp 'tempdir';
$ENV{TEST_MULTILIB} //= 0;
if ($ENV{TEST_INSTALL} and ($ENV{TEST_MULTILIB} == 2)) {
- plan tests => 10;
+ plan tests => 11;
} else {
plan skip_all => 'Only run these tests if TEST_INSTALL=1 and TEST_MULTILIB=2';
}
@@ -77,6 +77,10 @@ sboinstall qw/ -p multilibsbo /, { input => "n", expected => qr/Proceed with mul
# 10: multilibsbo with command in readme
sboinstall qw/ -p multilibsbowithcommandinreadme /, { input => "y\ny\nn\nn\nn", expected => qr/It looks like.*Shall I run.*Proceed.*It looks like.*Shall I run.*Proceed.*Are you sure/s };
+# 11: sboremove multilibsbo
+sboinstall qw/ -p multilibsbo /, { input => "y\ny\ny", test => 0 };
+sboremove qw/ multilibsbo /, { input => "y\ny\ny", expected => qr/Remove multilibsbo\b.*Removing 1 package\(s\)/s };
+
# Cleanup
END {
cleanup();
diff --git a/t/11-git.t b/t/11-git.t
index f1f9ebe..3f57f46 100755
--- a/t/11-git.t
+++ b/t/11-git.t
@@ -10,14 +10,18 @@ use lib $RealBin;
use Test::Sbotools qw/ set_repo sbosnap /;
if ($ENV{TEST_INSTALL}) {
- plan tests => 3;
+ plan tests => 5;
} else {
plan skip_all => 'Only run these tests if TEST_INSTALL=1';
}
sub cleanup {
capture_merged {
- system(qw!rm -rf !, "$RealBin/gitrepo");
+ system(qw!rm -rf !, "$RealBin/gitrepo");
+ if (defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true') {
+ system(qw!userdel test!);
+ system(qw!groupdel test!);
+ }
};
}
@@ -40,20 +44,39 @@ git checkout -b b1; echo 'echo "Hello World."' > test; git commit -am 'branch co
git checkout master; echo 'echo "Hello World"' > test; git commit -am 'master commit';
END
-set_repo("file://$RealBin/gitrepo/");
+if (defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true') {
+capture_merged { system(<<"END"); };
+groupadd -g 199 test
+useradd -u 199 -g 199 -d /tmp test
+chown -R 199:199 $RealBin/gitrepo
+END
+}
+
+set_repo("$RealBin/gitrepo/");
# 1: sbosnap get initial repo
sbosnap 'fetch', { expected => qr!Pulling SlackBuilds tree.*Cloning into '/usr/sbo/repo'!s };
+# 2-3: check ownership of repodir if under TRAVIS
+SKIP: {
+ skip "Only run under Travis CI", 2 unless defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true';
+
+ my @fnames = glob "$RealBin/gitrepo/.git/objects/*/*";
+
+ my @stat = stat shift @fnames;
+ is ($stat[4], 199, "Correct owner uid for $RealBin/gitrepo");
+ is ($stat[5], 199, "Correct owner gid for $RealBin/gitrepo");
+}
+
# make a conflict
capture_merged { system(<<"END"); };
cd "$RealBin"; cd gitrepo; git reset --hard b1
END
-# 2: sbosnap update through merge conflict
+# 4: sbosnap update through merge conflict
sbosnap 'update', { expected => qr!Updating SlackBuilds tree.*master.*->.*origin/master.*forced update.*HEAD is now at!s };
-# 3: make sure test repo is merged correctly
+# 5: make sure test repo is merged correctly
is (slurp('/usr/sbo/repo/test'), <<"END", 'repo test file updated correctly');
echo "Hello World."
END
diff --git a/t/12-readme.t b/t/12-readme.t
index ff69ac2..d95c7cf 100755
--- a/t/12-readme.t
+++ b/t/12-readme.t
@@ -10,7 +10,7 @@ use lib $RealBin;
use Test::Sbotools qw/ make_slackbuilds_txt set_lo sboinstall sboremove restore_perf_dummy /;
if ($ENV{TEST_INSTALL}) {
- plan tests => 10;
+ plan tests => 11;
} else {
plan skip_all => 'Only run these tests if TEST_INSTALL=1';
}
@@ -19,12 +19,16 @@ sub cleanup {
capture_merged {
system(qw!/sbin/removepkg envsettingtest!);
system(qw!/sbin/removepkg envsettingtest2!);
+ system(qw!/sbin/removepkg otherreadmes!);
unlink "$RealBin/LO-readme/envsettingtest/perf.dummy";
unlink "$RealBin/LO-readme/envsettingtest2/perf.dummy";
+ unlink "$RealBin/LO-readme/otherreadmes/perf.dummy";
system(qw!rm -rf /tmp/SBo/envsettingtest-1.0!);
system(qw!rm -rf /tmp/SBo/envsettingtest2-1.0!);
+ system(qw!rm -rf /tmp/SBo/otherreadmes-1.0!);
system(qw!rm -rf /tmp/package-envsettingtest!);
system(qw!rm -rf /tmp/package-envsettingtest2!);
+ system(qw!rm -rf /tmp/package-otherreadmes!);
};
}
@@ -62,7 +66,7 @@ SKIP: {
skip "Only run useradd/groupadd commands under Travis CI", 2 unless (defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true');
skip "Only run useradd/groupadd commands if there is no test user/group", 2, if (defined getgrnam('test') or defined getpwnam('test'));
- sboinstall 'commandinreadme', { input => "y\ny\ny", expected => qr{It looks like this slackbuild requires the following command\(s\) to be run first:.*groupadd -g 200 test.*useradd -u 200 -g 200 -d /tmp test.*Shall I run them prior to building.*}s };
+ sboinstall 'commandinreadme', { input => "y\ny\ny", expected => qr{It looks like this slackbuild requires the following command\(s\) to be run first:.*groupadd -g 199 test.*useradd -u 199 -g 199 -d /tmp test.*Shall I run them prior to building.*}s };
sboremove 'commandinreadme', { input => "y\ny", test => 0 };
sboinstall 'commandinreadme', { input => "y\ny\ny", expected => qr/groupadd.*exited non-zero/ };
@@ -70,6 +74,9 @@ SKIP: {
capture_merged { system(qw/ userdel test /); system(qw/ groupdel test /); };
}
+# 11: sboinstall otherreadmes
+sboinstall 'otherreadmes', { input => "y\ny\ny", expected => qr/It looks like.*Would you like to see.*README.*SlackBuilds[.]org.*SLACKWARE/s };
+
# Cleanup
END {
cleanup();
diff --git a/t/15-usage.t b/t/15-usage.t
index 4a9b61c..f14ef84 100755
--- a/t/15-usage.t
+++ b/t/15-usage.t
@@ -50,9 +50,12 @@ my $sboconfig = <<'SBOCONFIG';
Usage: sboconfig [options] [arguments]
Options:
- -h: this screen.
- -v: version information.
- -l: show current options.
+ -h|--help:
+ this screen.
+ -v|--version:
+ version information.
+ -l|--list:
+ show current options.
Config options (defaults shown):
-c|--clean FALSE:
@@ -127,6 +130,8 @@ Options (defaults shown first where applicable):
non-interactive; skips README and all prompts.
-R|--norequirements:
view the README but do not parse requirements, commands, or options.
+ --reinstall:
+ Ask to reinstall any already-installed packages in the requirement list.
--create-template (FILE):
create a template with specified requirements, commands, and options.
--use-template (FILE):
diff --git a/t/17-find.t b/t/17-find.t
index 5ea3e74..2be2a56 100755
--- a/t/17-find.t
+++ b/t/17-find.t
@@ -16,14 +16,14 @@ make_slackbuilds_txt();
set_lo("$RealBin/LO");
# 1: basic sbofind testing
-sbofind 'nonexistentslackbuild4', { expected => qr!Local:\s+nonexistentslackbuild4\nPath:\s+\Q$RealBin/LO/nonexistentslackbuild4! };
+sbofind 'nonexistentslackbuild4', { expected => qr!Local:\s+nonexistentslackbuild4 .*\nPath:\s+\Q$RealBin/LO/nonexistentslackbuild4! };
# 2: basic sbofind testing - nothing found
sbofind 'nonexistentslackbuild3', { expected => "Nothing found for search term: nonexistentslackbuild3\n" };
# 3: find something using a tag
replace_tags_txt("nonexistentslackbuild2: testingtag\n");
-sbofind 'testingtag', { expected => qr!Local:\s+nonexistentslackbuild2\nPath:\s+\Q$RealBin/LO/nonexistentslackbuild2! };
+sbofind 'testingtag', { expected => qr!Local:\s+nonexistentslackbuild2 .*\nPath:\s+\Q$RealBin/LO/nonexistentslackbuild2! };
# 4: show build queue
sbofind '-q', 'nonexistentslackbuild2', { expected => qr/Queue:\s+nonexistentslackbuild3 nonexistentslackbuild2/ };
diff --git a/t/28-race-sboremove.t b/t/28-race-sboremove.t
index ebc707f..3c7e026 100755
--- a/t/28-race-sboremove.t
+++ b/t/28-race-sboremove.t
@@ -52,4 +52,4 @@ tie *STDIN, 'STDINTIE';
my $res = load('sboremove', argv => ['nonexistentslackbuild8']);
like ($res->{out}, qr/Unable to open README for nonexistentslackbuild8\./, 'sboremove output with race condition correct');
-is ($res->{exit}, 0, 'sboremove exited with 0');
+is ($res->{exit}, 0, 'sboremove did not exit in error');
diff --git a/t/29-unit-sboremove.t b/t/29-unit-sboremove.t
deleted file mode 100755
index a968dc7..0000000
--- a/t/29-unit-sboremove.t
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/env perl
-
-use strict;
-use warnings;
-use Test::More;
-use Test::Exit;
-use FindBin '$RealBin';
-use lib $RealBin;
-use Test::Sbotools qw/ load /;
-use Capture::Tiny qw/ capture_merged /;
-use File::Temp 'tempdir';
-use Cwd;
-
-plan tests => 1;
-
-# 1: sboremove unit test...
-{
- load('sboremove');
-
- no warnings 'redefine', 'once';
-
- my $sentinel = 0;
- local *main::in = sub {
- my $find = shift;
- my @ret = grep { $find eq $_ } @_;
- $sentinel++ if @ret;
- return 1 if @ret;
- return 0;
- };
-
- main::confirm_remove('foo');
- main::confirm_remove('foo');
-
- is ($sentinel, 1, "confirm_remove() checks for duplicates.");
-}
diff --git a/t/31-template.t b/t/31-template.t
index 982c08f..250e2f6 100755
--- a/t/31-template.t
+++ b/t/31-template.t
@@ -11,7 +11,7 @@ use Test::Sbotools qw/ make_slackbuilds_txt set_lo sboinstall sboremove restore_
use File::Temp qw/ tempdir /;
if ($ENV{TEST_INSTALL}) {
- plan tests => 26;
+ plan tests => 29;
} else {
plan skip_all => 'Only run these tests if TEST_INSTALL=1';
}
@@ -20,12 +20,20 @@ sub cleanup {
capture_merged {
system(qw!/sbin/removepkg envsettingtest!);
system(qw!/sbin/removepkg envsettingtest2!);
+ system(qw!/sbin/removepkg commandinreadme!);
+ system(qw!/sbin/removepkg commandinreadmespanslines!);
unlink "$RealBin/LO-readme/envsettingtest/perf.dummy";
unlink "$RealBin/LO-readme/envsettingtest2/perf.dummy";
+ unlink "$RealBin/LO-readme/commandinreadme/perf.dummy";
+ unlink "$RealBin/LO-readme/commandinreadmespanslines/perf.dummy";
system(qw!rm -rf /tmp/SBo/envsettingtest-1.0!);
system(qw!rm -rf /tmp/SBo/envsettingtest2-1.0!);
+ system(qw!rm -rf /tmp/SBo/commandinreadme-1.0!);
+ system(qw!rm -rf /tmp/SBo/commandinreadmespanslines-1.0!);
system(qw!rm -rf /tmp/package-envsettingtest!);
system(qw!rm -rf /tmp/package-envsettingtest2!);
+ system(qw!rm -rf /tmp/package-commandinreadme!);
+ system(qw!rm -rf /tmp/package-commandinreadmespanslines!);
};
}
@@ -143,8 +151,8 @@ SKIP: {
],
"commands" : {
"commandinreadme" : [
- "groupadd -g 200 test",
- "useradd -u 200 -g 200 -d /tmp test"
+ "groupadd -g 199 test",
+ "useradd -u 199 -g 199 -d /tmp test"
]
},
"options" : {
@@ -173,6 +181,35 @@ sboinstall '--use-template', '', { expected => qr/Usage/, exit => 1 };
sboinstall '--use-template', '', '', { expected => qr/Usage/, exit => 1 };
sboinstall '--create-template', '', '', { expected => qr/Usage/, exit => 1 };
+# 27-29: sboinstall commandinreadmespanslines
+SKIP: {
+ skip "Only run useradd/groupadd commands under Travis CI", 3 unless (defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true');
+ skip "Only run useradd/groupadd commands if there is no test user/group", 3 if (defined getgrnam('test') or defined getpwnam('test'));
+
+ sboinstall '-i', '--create-template', "$tempdir/10.temp", 'commandinreadmespanslines', { input => "y\ny\ny", expected => qr!Template \Q$tempdir/10.temp saved.\E\n! };
+ capture_merged { system(qw/ userdel test /); system(qw/ groupdel test /); };
+ is (scalar capture_merged { system cat => "$tempdir/10.temp" }, <<'TEMP10', "10.temp is correct");
+{
+ "build_queue" : [
+ "commandinreadmespanslines"
+ ],
+ "commands" : {
+ "commandinreadmespanslines" : [
+ "groupadd -g 199 test",
+ "useradd -u 199 -g 199 -d /tmp \\\n -s /bin/sh test"
+ ]
+ },
+ "options" : {
+ "commandinreadmespanslines" : 0
+ }
+}
+TEMP10
+ sboinstall '--use-template', "$tempdir/10.temp", { expected => sub { ! m/exited non-zero/ } };
+ sboremove 'commandinreadmespanslines', { input => "y\ny", test => 0 };
+
+ capture_merged { system(qw/ userdel test /); system(qw/ groupdel test /); };
+}
+
# Cleanup
END {
cleanup();
diff --git a/t/32-info.t b/t/32-info.t
new file mode 100644
index 0000000..0f5e4bd
--- /dev/null
+++ b/t/32-info.t
@@ -0,0 +1,55 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use FindBin '$RealBin';
+use lib "$RealBin/../SBO-Lib/lib";
+use SBO::Lib 'parse_info';
+
+plan tests => 23;
+
+my %parse = parse_info(<<"END");
+FOO="bar"
+BAR="foo bar
+baz"
+BAZ="barf foof
+ bazf"
+QUUX="finf"
+FLAR_f="trailing whitespace"
+FLINGLE="\
+glorg \
+glorg \
+and\
+a\
+ gloob\
+blorx\
+"
+END
+
+is ($parse{FOO}[0], 'bar', 'bar value gotten from FOO key');
+is ($parse{FOO}[1], undef, 'FOO key has correct length');
+is ($parse{BAR}[0], 'foo', 'foo value gotten from BAR key');
+is ($parse{BAR}[1], 'bar', 'bar value gotten from BAR key');
+is ($parse{BAR}[2], 'baz', 'baz value gotten from BAR key');
+is ($parse{BAR}[3], undef, 'BAR key has correct length');
+is ($parse{BAZ}[0], 'barf', 'barf value gotten from BAZ key');
+is ($parse{BAZ}[1], 'foof', 'foof value gotten from BAZ key');
+is ($parse{BAZ}[2], 'bazf', 'bazf value gotten from BAZ key');
+is ($parse{BAZ}[3], undef, 'BAZ key has correct length');
+is ($parse{QUUX}[0], 'finf', 'finf value gotten from QUUX key');
+is ($parse{QUUX}[1], undef, 'QUUX key has correct length');
+is ($parse{FLAR_f}[0], 'trailing', 'trailing value gotten from FLAR_f key');
+is ($parse{FLAR_f}[1], 'whitespace', 'whitespace value gotten from FLAR_f key');
+is ($parse{FLAR_f}[2], undef, 'FLAR_f key has correct length');
+is ($parse{FLINGLE}[0], 'glorg', 'glorg value gotten from FLINGLE key');
+is ($parse{FLINGLE}[1], 'glorg', 'glorg value gotten from FLINGLE key');
+is ($parse{FLINGLE}[2], 'and', 'and value gotten from FLINGLE key');
+is ($parse{FLINGLE}[3], 'a', 'a value gotten from FLINGLE key');
+is ($parse{FLINGLE}[4], 'gloob', 'gloob value gotten from FLINGLE key');
+is ($parse{FLINGLE}[5], 'blorx', 'blorx value gotten from FLINGLE key');
+is ($parse{FLINGLE}[6], undef, 'FLINGLE key has correct length');
+delete @parse{qw/ FOO BAR BAZ QUUX FLAR_f FLINGLE /};
+is (scalar %parse, 0, 'no additional keys were parsed');
diff --git a/t/LO-multilib/multilibsbowithcommandinreadme/README b/t/LO-multilib/multilibsbowithcommandinreadme/README
index 6e51784..db5d140 100644
--- a/t/LO-multilib/multilibsbowithcommandinreadme/README
+++ b/t/LO-multilib/multilibsbowithcommandinreadme/README
@@ -1,4 +1,4 @@
This doesn't exist!
- groupadd -g 200 test
- useradd -u 200 -g 200 -d /tmp test
+ groupadd -g 199 test
+ useradd -u 199 -g 199 -d /tmp test
diff --git a/t/LO-readme/commandinreadme/README b/t/LO-readme/commandinreadme/README
index 6e51784..db5d140 100644
--- a/t/LO-readme/commandinreadme/README
+++ b/t/LO-readme/commandinreadme/README
@@ -1,4 +1,4 @@
This doesn't exist!
- groupadd -g 200 test
- useradd -u 200 -g 200 -d /tmp test
+ groupadd -g 199 test
+ useradd -u 199 -g 199 -d /tmp test
diff --git a/t/LO-readme/commandinreadmespanslines/README b/t/LO-readme/commandinreadmespanslines/README
new file mode 100644
index 0000000..696c2fe
--- /dev/null
+++ b/t/LO-readme/commandinreadmespanslines/README
@@ -0,0 +1,5 @@
+This doesn't exist!
+
+ groupadd -g 199 test
+ useradd -u 199 -g 199 -d /tmp \
+ -s /bin/sh test
diff --git a/t/LO-readme/commandinreadmespanslines/commandinreadmespanslines.SlackBuild b/t/LO-readme/commandinreadmespanslines/commandinreadmespanslines.SlackBuild
new file mode 100644
index 0000000..0ff4195
--- /dev/null
+++ b/t/LO-readme/commandinreadmespanslines/commandinreadmespanslines.SlackBuild
@@ -0,0 +1,20 @@
+#!/bin/bash
+PRGNAM="commandinreadmespanslines"
+VERSION=${VERSION:-1.0}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_SBo}
+TMP=${TMP:-/tmp/SBo}
+OUTPUT=${OUTPUT:-/tmp}
+
+if ! getent passwd "test"; then
+ echo "test user doesn't exist!"
+ exit 1
+fi
+
+mkdir -p $TMP/$PRGNAM-$VERSION
+cp README $TMP/$PRGNAM-$VERSION
+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-readme/commandinreadmespanslines/commandinreadmespanslines.info b/t/LO-readme/commandinreadmespanslines/commandinreadmespanslines.info
new file mode 100644
index 0000000..e6f71b6
--- /dev/null
+++ b/t/LO-readme/commandinreadmespanslines/commandinreadmespanslines.info
@@ -0,0 +1,10 @@
+PRGNAM="commandinreadmespanslines"
+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-readme/otherreadmes/README b/t/LO-readme/otherreadmes/README
new file mode 100644
index 0000000..6d388bb
--- /dev/null
+++ b/t/LO-readme/otherreadmes/README
@@ -0,0 +1 @@
+This doesn't exist!
diff --git a/t/LO-readme/otherreadmes/README.SBo b/t/LO-readme/otherreadmes/README.SBo
new file mode 100644
index 0000000..7ff669b
--- /dev/null
+++ b/t/LO-readme/otherreadmes/README.SBo
@@ -0,0 +1 @@
+this is the README for SlackBuilds.org
diff --git a/t/LO-readme/otherreadmes/README.SLACKWARE b/t/LO-readme/otherreadmes/README.SLACKWARE
new file mode 100644
index 0000000..9539839
--- /dev/null
+++ b/t/LO-readme/otherreadmes/README.SLACKWARE
@@ -0,0 +1 @@
+this is the README for SLACKWARE!
diff --git a/t/LO-readme/otherreadmes/otherreadmes.SlackBuild b/t/LO-readme/otherreadmes/otherreadmes.SlackBuild
new file mode 100644
index 0000000..4466ded
--- /dev/null
+++ b/t/LO-readme/otherreadmes/otherreadmes.SlackBuild
@@ -0,0 +1,15 @@
+#!/bin/bash
+PRGNAM="otherreadmes"
+VERSION=${VERSION:-1.0}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_SBo}
+TMP=${TMP:-/tmp/SBo}
+OUTPUT=${OUTPUT:-/tmp}
+
+mkdir -p $TMP/$PRGNAM-$VERSION
+cp README $TMP/$PRGNAM-$VERSION
+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-readme/otherreadmes/otherreadmes.info b/t/LO-readme/otherreadmes/otherreadmes.info
new file mode 100644
index 0000000..3dcaf67
--- /dev/null
+++ b/t/LO-readme/otherreadmes/otherreadmes.info
@@ -0,0 +1,10 @@
+PRGNAM="otherreadmes"
+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/locale-versionsbo/README b/t/LO/locale-versionsbo/README
new file mode 100644
index 0000000..6d388bb
--- /dev/null
+++ b/t/LO/locale-versionsbo/README
@@ -0,0 +1 @@
+This doesn't exist!
diff --git a/t/LO/locale-versionsbo/locale-versionsbo.SlackBuild b/t/LO/locale-versionsbo/locale-versionsbo.SlackBuild
new file mode 100644
index 0000000..f146a92
--- /dev/null
+++ b/t/LO/locale-versionsbo/locale-versionsbo.SlackBuild
@@ -0,0 +1,16 @@
+#!/bin/bash
+PRGNAM="locale-versionsbo"
+VERSION=${VERSION:-1.0}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_SBo}
+TMP=${TMP:-/tmp/SBo}
+OUTPUT=${OUTPUT:-/tmp}
+KERNEL=$(uname -r)
+
+mkdir -p $TMP/$PRGNAM-$VERSION
+cp README $TMP/$PRGNAM-$VERSION
+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\_en_US-noarch-$BUILD$TAG.tgz
diff --git a/t/LO/locale-versionsbo/locale-versionsbo.info b/t/LO/locale-versionsbo/locale-versionsbo.info
new file mode 100644
index 0000000..787a2ef
--- /dev/null
+++ b/t/LO/locale-versionsbo/locale-versionsbo.info
@@ -0,0 +1,10 @@
+PRGNAM="locale-versionsbo"
+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"