aboutsummaryrefslogtreecommitdiff
path: root/t/02.2-unit-repo.t
diff options
context:
space:
mode:
Diffstat (limited to 't/02.2-unit-repo.t')
-rwxr-xr-xt/02.2-unit-repo.t91
1 files changed, 91 insertions, 0 deletions
diff --git a/t/02.2-unit-repo.t b/t/02.2-unit-repo.t
new file mode 100755
index 0000000..2b71fcf
--- /dev/null
+++ b/t/02.2-unit-repo.t
@@ -0,0 +1,91 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::More;
+use Test::Exit;
+use FindBin '$RealBin';
+use lib "$RealBin/../SBO-Lib/lib";
+use SBO::Lib qw/ do_slackbuild rsync_sbo_tree /;
+use Capture::Tiny qw/ capture_merged /;
+use File::Path qw/ remove_tree /;
+
+if (defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true') {
+ plan tests => 12;
+} else {
+ plan skip_all => 'Only run these tests under Travis CI (TRAVIS=true)';
+}
+
+# first set up the repo
+my $repo = "/usr/sbo/repo";
+my $moved = rename $repo, "$repo.orig";
+my $url = "$RealBin/02.2-unit-repo/";
+
+capture_merged {
+ rsync_sbo_tree($url);
+};
+
+# 1-3: test do_slackbuild() without /etc/profile.d/32dev.sh
+{
+ my $file = "/etc/profile.d/32dev.sh";
+ my $moved = rename $file, "$file.orig";
+
+ my ($exit, @ret);
+ my $out = capture_merged { $exit = exit_code { @ret = do_slackbuild(LOCATION => "/usr/sbo/repo/test/test", COMPAT32 => 1); }; };
+
+ is ($exit, undef, "do_slackbuild() didn't exit without $file.");
+ is ($out, "", "do_slackbuild() didn't output anything without $file.");
+ is_deeply (\@ret, ["compat32 requires multilib.\n", undef, undef, 9], "do_slackbuild() returned the correct things without $file.");
+
+ rename "$file.orig", $file if $moved;
+}
+
+# 4-6: test do_slackbuild() without /usr/sbin/convertpkg-compat32
+SKIP: {
+ skip "These tests require /etc/profile.d/32dev.sh to be an existing file.", 3 unless -f "/etc/profile.d/32dev.sh";
+
+ my $file = "/usr/sbin/convertpkg-compat32";
+ my $moved = rename $file, "$file.orig";
+
+ my ($exit, @ret);
+ my $out = capture_merged { $exit = exit_code { @ret = do_slackbuild(LOCATION => "/usr/sbo/repo/test/test", COMPAT32 => 1); }; };
+
+ is ($exit, undef, "do_slackbuild() didn't exit without $file.");
+ is ($out, "", "do_slackbuild() didn't output anything without $file.");
+ is_deeply (\@ret, ["compat32 requires $file.\n", undef, undef, 11], "do_slackbuild() returned the correct things without $file.");
+
+ rename "$file.orig", $file if $moved;
+}
+
+# 7-9: test do_slackbuild() without needed multilib
+{
+ no warnings 'redefine';
+
+ local *SBO::Lib::Build::get_arch = sub { return 'x86_64' };
+ local *SBO::Lib::Build::check_multilib = sub { return (); };
+
+ my ($exit, @ret);
+ my $out = capture_merged { $exit = exit_code { @ret = do_slackbuild(LOCATION => "/usr/sbo/repo/test/test" ); }; };
+
+ is ($exit, undef, "do_slackbuild() didn't exit without needed multilib.");
+ is ($out, "", "do_slackbuild() didn't output anything without needed multilib.");
+ is_deeply (\@ret, ["test is 32-bit which requires multilib on x86_64.\n", undef, undef, 9], "do_slackbuild() returned the correct things without needed multilib.");
+}
+
+# 10-12: test do_slackbuild() which thinks it's on 32bit
+{
+ no warnings 'redefine';
+
+ local *SBO::Lib::Build::get_arch = sub { return 'i586' };
+ local *SBO::Lib::Build::perform_sbo = sub { return 'sentinel', undef, -1 };
+
+ my ($exit, @ret);
+ my $out = capture_merged { $exit = exit_code { @ret = do_slackbuild(LOCATION => "/usr/sbo/repo/test/test" ); }; };
+
+ is ($exit, undef, "do_slackbuild() didn't exit when it's on 32bit.");
+ is ($out, "", "do_slackbuild() didn't output anything when it's on 32bit.");
+ is_deeply (\@ret, ["sentinel", undef, undef, -1], "do_slackbuild() returned the correct things when it's on 32bit.");
+}
+
+remove_tree($repo);
+rename "$repo.orig", $repo if $moved;