forked from pink-mist/sbotools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02.2-unit-repo.t
executable file
·114 lines (86 loc) · 3.94 KB
/
02.2-unit-repo.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/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 get_sbo_downloads /;
use Capture::Tiny qw/ capture_merged /;
use File::Path qw/ remove_tree /;
if (defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true') {
plan tests => 13;
} 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/";
my $rsync_res;
note "Unit repo: $url";
note "rsync $url:\n" . capture_merged {
no warnings 'redefine';
local *SBO::Lib::Repo::get_slack_version = sub { '14.1' };
$rsync_res = exit_code { rsync_sbo_tree($url); };
};
if (defined $rsync_res) {
note "rsync exit status: $rsync_res";
rename "$repo.orig", $repo if $moved;
BAIL_OUT("rsync_sbo_tree exited");
}
# 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.");
}
# 13: test get_sbo_downloads() which thinks it's on 32bit
{
no warnings 'redefine';
local *SBO::Lib::Download::get_arch = sub { return 'i586' };
my $ret = get_sbo_downloads(LOCATION => "/usr/sbo/repo/test/test2");
ok (exists $ret->{'http://pink-mist.github.io/sbotools/testing/32/perf.dummy'}, "get_sbo_downloads() returned the correct link for 32bit.")
or diag explain $ret;
}
remove_tree($repo);
rename "$repo.orig", $repo if $moved;