diff options
author | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2016-08-28 18:34:17 +0200 |
---|---|---|
committer | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2016-08-28 18:34:17 +0200 |
commit | e77acc913f47bce50ad00fddf484faf6baf92df9 (patch) | |
tree | db4581d1fc0d4053b98aa71ca21cacf46840b9e1 /t/02.2-unit-repo.t | |
parent | 9eb86ec4cf83a23cac36adf5289bd65bef1b5b37 (diff) | |
download | sbotools2-e77acc913f47bce50ad00fddf484faf6baf92df9.tar.xz |
02*.t: add another unit test file with new tests
Diffstat (limited to 't/02.2-unit-repo.t')
-rwxr-xr-x | t/02.2-unit-repo.t | 91 |
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; |