aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xt/02.1-unit-args.t (renamed from t/02-unit-args.t)0
-rwxr-xr-xt/02.2-unit-repo.t91
-rw-r--r--t/02.2-unit-repo/SLACKBUILDS.TXT2
-rw-r--r--t/02.2-unit-repo/test/test/README1
-rw-r--r--t/02.2-unit-repo/test/test/test.SlackBuild15
-rw-r--r--t/02.2-unit-repo/test/test/test.info10
6 files changed, 119 insertions, 0 deletions
diff --git a/t/02-unit-args.t b/t/02.1-unit-args.t
index bb70939..bb70939 100755
--- a/t/02-unit-args.t
+++ b/t/02.1-unit-args.t
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;
diff --git a/t/02.2-unit-repo/SLACKBUILDS.TXT b/t/02.2-unit-repo/SLACKBUILDS.TXT
new file mode 100644
index 0000000..f6cebcf
--- /dev/null
+++ b/t/02.2-unit-repo/SLACKBUILDS.TXT
@@ -0,0 +1,2 @@
+SLACKBUILD NAME: test
+SLACKBUILD LOCATION: ./test/test
diff --git a/t/02.2-unit-repo/test/test/README b/t/02.2-unit-repo/test/test/README
new file mode 100644
index 0000000..6d388bb
--- /dev/null
+++ b/t/02.2-unit-repo/test/test/README
@@ -0,0 +1 @@
+This doesn't exist!
diff --git a/t/02.2-unit-repo/test/test/test.SlackBuild b/t/02.2-unit-repo/test/test/test.SlackBuild
new file mode 100644
index 0000000..78f1fd2
--- /dev/null
+++ b/t/02.2-unit-repo/test/test/test.SlackBuild
@@ -0,0 +1,15 @@
+#!/bin/bash
+PRGNAM="test"
+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/02.2-unit-repo/test/test/test.info b/t/02.2-unit-repo/test/test/test.info
new file mode 100644
index 0000000..294378c
--- /dev/null
+++ b/t/02.2-unit-repo/test/test/test.info
@@ -0,0 +1,10 @@
+PRGNAM="test"
+VERSION="1.0"
+HOMEPAGE="http://www.example.com"
+DOWNLOAD="http://pink-mist.github.io/sbotools/testing/perf.dummy"
+MD5SUM="9cba6c70fb57a22a155073d54748b614"
+DOWNLOAD_x86_64="UNSUPPORTED"
+MD5SUM_x86_64=""
+REQUIRES=""
+MAINTAINER="Andreas Guldstrand"
+EMAIL="doesnt@matter.org"