sbotools2

Maintenance fork of the original sbotools version 2
git clone git://git.server.ky/slackcoder/sbotools2
Log | Files | Refs | README

04-install.t (6076B)


      1 #!/usr/bin/env perl
      2 
      3 use 5.16.0;
      4 use strict;
      5 use warnings FATAL => 'all';
      6 use Test::More;
      7 use Capture::Tiny qw/ capture_merged /;
      8 use FindBin '$RealBin';
      9 use lib $RealBin;
     10 use Test::Sbotools qw/ make_slackbuilds_txt set_lo sboinstall sboremove restore_perf_dummy /;
     11 
     12 if ($ENV{TEST_INSTALL}) {
     13 	plan tests => 22;
     14 } else {
     15 	plan skip_all => 'Only run these tests if TEST_INSTALL=1';
     16 }
     17 $ENV{TEST_ONLINE} //= 0;
     18 
     19 sub cleanup {
     20 	capture_merged {
     21 		system(qw!/sbin/removepkg nonexistentslackbuild!);
     22 		system(qw!/sbin/removepkg nonexistentslackbuild4!);
     23 		system(qw!/sbin/removepkg nonexistentslackbuild5!);
     24 		system(qw!/sbin/removepkg nonexistentslackbuild6!);
     25 		unlink "$RealBin/LO/nonexistentslackbuild/perf.dummy";
     26 		unlink "$RealBin/LO/nonexistentslackbuild4/perf.dummy";
     27 		unlink "$RealBin/LO/nonexistentslackbuild5/perf.dummy";
     28 		unlink "$RealBin/LO/nonexistentslackbuild6/perf.dummy";
     29 		system(qw!rm -rf /tmp/SBo/nonexistentslackbuild-1.0!);
     30 		system(qw!rm -rf /tmp/SBo/nonexistentslackbuild4-1.0!);
     31 		system(qw!rm -rf /tmp/SBo/nonexistentslackbuild5-1.0!);
     32 		system(qw!rm -rf /tmp/SBo/nonexistentslackbuild6-1.0!);
     33 		system(qw!rm -rf /tmp/package-nonexistentslackbuild!);
     34 		system(qw!rm -rf /tmp/package-nonexistentslackbuild4!);
     35 		system(qw!rm -rf /tmp/package-nonexistentslackbuild5!);
     36 		system(qw!rm -rf /tmp/package-nonexistentslackbuild6!);
     37 	};
     38 }
     39 
     40 cleanup();
     41 make_slackbuilds_txt();
     42 set_lo("$RealBin/LO");
     43 system("mv /usr/sbo/repo/* /usr/sbo");
     44 restore_perf_dummy();
     45 
     46 # 1-3: sboinstall nonexistentslackbuild
     47 sboinstall 'nonexistentslackbuild', { input => "y\ny", expected => qr/nonexistentslackbuild added to install queue.*Install queue: nonexistentslackbuild/s };
     48 ok (! -e "$RealBin/LO/nonexistentslackbuild/perf.dummy", "Source symlink removed");
     49 ok (-e "/usr/sbo/repo/SLACKBUILDS.TXT", "SLACKBUILDS.TXT has been migrated back to its proper place");
     50 sboremove 'nonexistentslackbuild', { input => "y\ny", test => 0 };
     51 
     52 # 4: sboinstall nonexistentslackbuild2
     53 sboinstall 'nonexistentslackbuild2', { exit => 0, expected => "Unable to locate nonexistentslackbuild3 in the SlackBuilds.org tree.\nDo you want to ignore it and continue? [n] ", input => "n" };
     54 
     55 # 5: sboinstall nonexistentslackbuild3
     56 sboinstall 'nonexistentslackbuild3', { exit => 1, expected => "Unable to locate nonexistentslackbuild3 in the SlackBuilds.org tree.\n" };
     57 
     58 # 6: sboinstall nonexistentslackbuild4
     59 sboinstall 'nonexistentslackbuild4', { input => "y\ny\ny",
     60 	expected => qr/nonexistentslackbuild5 added to install queue.*nonexistentslackbuild4 added to install queue.*Install queue: nonexistentslackbuild5 nonexistentslackbuild4/s };
     61 sboremove 'nonexistentslackbuild5', { input => "y\ny", test => 0 };
     62 
     63 # 7: sboinstall nonexistentslackbuild5
     64 sboinstall 'nonexistentslackbuild5', { input => "y\ny", expected => qr/nonexistentslackbuild5 added to install queue.*Install queue: nonexistentslackbuild5/s };
     65 sboremove 'nonexistentslackbuild4', { input => "y\ny\ny", test => 0 };
     66 
     67 # 8: sboinstall nonexistentslackbuild4
     68 sboinstall 'nonexistentslackbuild4', { input => "y\ny\ny",
     69 	expected => qr/nonexistentslackbuild5 added to install queue.*nonexistentslackbuild4 added to install queue.*Install queue: nonexistentslackbuild5 nonexistentslackbuild4/s };
     70 sboremove 'nonexistentslackbuild5', { input => "y\ny", test => 0 };
     71 
     72 # 9: sboinstall nonexistentslackbuild4
     73 sboinstall 'nonexistentslackbuild4', { input => "y\ny", expected => qr/nonexistentslackbuild5 added to install queue.*Install queue: nonexistentslackbuild5/s };
     74 sboremove 'nonexistentslackbuild4', 'nonexistentslackbuild5', { input => "y\ny\ny", test => 0 };
     75 
     76 # 10: sboinstall nonexistentslackbuild6
     77 sboinstall 'nonexistentslackbuild6', { input => "y\ny", expected => qr/aaa_base \(aaa_base-[^)]+\) is already installed.*nonexistentslackbuild6 added to install queue.*Install queue: nonexistentslackbuild6/s };
     78 
     79 # 11-12: sboinstall -i nonexistentslackbuild
     80 sboinstall qw/ -i nonexistentslackbuild /, { input => "y\ny", expected => qr/nonexistentslackbuild added to install queue/ };
     81 ok(!-e "/var/log/packages/nonexistentslackbuild-1.0-noarch-1_SBo", "nonexistentslackbuild wasn't installed with -i");
     82 
     83 # 13-14: sboinstall nonexistentslackbuild
     84 sboinstall 'nonexistentslackbuild', { input => "y\nn", expected => qr/nonexistentslackbuild added to install queue/ };
     85 ok(!-e "/var/log/packages/nonexistentslackbuild-1.0-noarch-1_SBo", "nonexistentslackbuild wasn't installed when saying no");
     86 
     87 # 15: sboinstall nonexistentslackbuild
     88 sboinstall 'nonexistentslackbuild', { input => "n", expected => sub { not /nonexistentslackbuild added to install queue/ } };
     89 
     90 # 16: sboinstall nonexistentslackbuild4
     91 sboinstall qw/ -R nonexistentslackbuild4 /, { input => "y\ny", expected => sub { not /nonexistentslackbuild5 added to install queue/ } };
     92 sboremove 'nonexistentslackbuild4', { input => "y\ny\n", test => 0 };
     93 
     94 # 17: sboinstall perl-Capture-Tiny
     95 sboinstall 'perl-Capture-Tiny', { expected => "perl-Capture-Tiny installed via the cpan.\n" };
     96 
     97 # 18: sboinstall perl-nonexistentcpan
     98 sboinstall 'perl-nonexistentcpan', { input => "n", expected => qr/Proceed with perl-nonexistentcpan/ };
     99 
    100 # 19: check node status of slackbuild script
    101 {
    102 	my $sbo = "$RealBin/LO/nonexistentslackbuild/nonexistentslackbuild.SlackBuild";
    103 	my $inode = (stat($sbo))[1];
    104 	sboinstall 'nonexistentslackbuild', { input => "y\ny", test => 0 };
    105 	is((stat($sbo))[1], $inode, "inode didn't change");
    106 }
    107 
    108 # 20: check correct exit for compat32 on fake 32bit
    109 {
    110 	local $ENV{PATH} = "$RealBin/bin:$ENV{PATH}";
    111 
    112 	sboinstall '-p', 'foo', { expected => "compat32 only works on x86_64.\n", exit => 1 };
    113 }
    114 
    115 # 21-22: check --reinstall option
    116 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/ };
    117 sboinstall '--reinstall', 'nonexistentslackbuild', { input => "y\ny\ny", expected => qr/nonexistentslackbuild .* is already installed[.] Do you want to reinstall.*Install queue: nonexistentslackbuild/s };
    118 
    119 # Cleanup
    120 END {
    121 	cleanup();
    122 }