sbotools2

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

06-remove.t (4960B)


      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 => 14;
     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 nonexistentslackbuild7!);
     25 		system(qw!/sbin/removepkg nonexistentslackbuild8!);
     26 		unlink "$RealBin/LO/nonexistentslackbuild/perf.dummy";
     27 		unlink "$RealBin/LO/nonexistentslackbuild4/perf.dummy";
     28 		unlink "$RealBin/LO/nonexistentslackbuild5/perf.dummy";
     29 		unlink "$RealBin/LO/nonexistentslackbuild7/perf.dummy";
     30 		unlink "$RealBin/LO/nonexistentslackbuild8/perf.dummy";
     31 		system(qw!rm -rf /tmp/SBo/nonexistentslackbuild-1.0!);
     32 		system(qw!rm -rf /tmp/SBo/nonexistentslackbuild4-1.0!);
     33 		system(qw!rm -rf /tmp/SBo/nonexistentslackbuild5-1.0!);
     34 		system(qw!rm -rf /tmp/SBo/nonexistentslackbuild7-1.0!);
     35 		system(qw!rm -rf /tmp/SBo/nonexistentslackbuild8-1.0!);
     36 		system(qw!rm -rf /tmp/package-nonexistentslackbuild!);
     37 		system(qw!rm -rf /tmp/package-nonexistentslackbuild4!);
     38 		system(qw!rm -rf /tmp/package-nonexistentslackbuild5!);
     39 		system(qw!rm -rf /tmp/package-nonexistentslackbuild7!);
     40 		system(qw!rm -rf /tmp/package-nonexistentslackbuild8!);
     41 	};
     42 }
     43 
     44 cleanup();
     45 make_slackbuilds_txt();
     46 set_lo("$RealBin/LO");
     47 restore_perf_dummy();
     48 
     49 # 1: sboremove nonexistentslackbuild
     50 sboinstall 'nonexistentslackbuild', { input => "y\ny", test => 0 };
     51 sboremove 'nonexistentslackbuild', { input => "y\ny", expected => qr/Remove nonexistentslackbuild\b.*Removing 1 package\(s\)/s };
     52 
     53 # 2: sboremove nonexistentslackbuild5
     54 sboinstall 'nonexistentslackbuild4', { input => "y\ny\ny", test => 0 };
     55 sboremove 'nonexistentslackbuild5', { input => "y\ny", expected => qr/Remove nonexistentslackbuild5\b.*Removing 1 package\(s\)/s };
     56 
     57 # 3: sboremove nonexistentslackbuild4
     58 sboinstall 'nonexistentslackbuild5', { input => "y\ny", test => 0 };
     59 sboremove 'nonexistentslackbuild4', { input => "y\ny\ny", expected => qr/Remove nonexistentslackbuild4\b.*Remove nonexistentslackbuild5\b.*Removing 2 package\(s\)/s };
     60 
     61 # 4: sboremove nonexistentslackbuild4 nonexistentslackbuild5
     62 sboinstall 'nonexistentslackbuild4', { input => "y\ny\ny", test => 0 };
     63 sboremove qw/ nonexistentslackbuild4 nonexistentslackbuild5 /, { input => "y\ny\ny",
     64 	expected => qr/Remove nonexistentslackbuild4\b.*Remove nonexistentslackbuild5\b.*Removing 2 package\(s\)/s };
     65 
     66 # 5: sboremove namethatdoesntexist slackbuildthatisntinstalld
     67 sboremove qw/ nonexistentslackbuildwhosenamedoesntexist nonexistentslackbuild /,
     68 	{ exit => 1, expected => "Unable to locate nonexistentslackbuildwhosenamedoesntexist in the SlackBuilds.org tree.\nnonexistentslackbuild is not installed from SlackBuilds.org.\n" };
     69 
     70 # 6-7: sboremove nonexistentslackbuild [x2] and say no
     71 sboinstall 'nonexistentslackbuild', { input => "y\ny", test => 0 };
     72 sboremove qw/ nonexistentslackbuild nonexistentslackbuild /, { input => "y\nn", expected => qr/Remove nonexistentslackbuild\b.*want to continue.*Exiting/s };
     73 sboremove 'nonexistentslackbuild', { input => "n", expected => qr/Ignoring.*Nothing to remove/s };
     74 sboremove 'nonexistentslackbuild', { input => "y\ny", test => 0 };
     75 
     76 # 8-12: sboremove check that still needed sbos aren't removed
     77 sboinstall qw/ nonexistentslackbuild4 nonexistentslackbuild7 /, { input => "y\ny\ny\ny", test => 0 };
     78 sboremove 'nonexistentslackbuild4', { input => "y\nn", expected => sub { ! /nonexistentslackbuild5 / } };
     79 TODO: {
     80 	todo_skip 'sboremove: not able to see if a dep needed by more than one installed thing is still needed', 1;
     81 	sboremove qw/ nonexistentslackbuild4 nonexistentslackbuild7 /, { input => "\n\n\n\n\n", expected => qr/nonexistentslackbuild5/ };
     82 }
     83 sboremove qw/ nonexistentslackbuild4 nonexistentslackbuild5 /, { input => "y\ny\nn", expected => qr/nonexistentslackbuild4 nonexistentslackbuild5/ };
     84 sboremove qw/ -a nonexistentslackbuild4 /, { input => "y\nn\ny", expected => qr/nonexistentslackbuild5 : required by nonexistentslackbuild7/ };
     85 sboremove 'nonexistentslackbuild7', { input => "y\ny\ny", expected => qr/nonexistentslackbuild5/ };
     86 
     87 # 13: sboremove shows readme for %README% dep
     88 sboinstall 'nonexistentslackbuild8', { input => "y\ny", test => 0 };
     89 sboremove 'nonexistentslackbuild8', { input => "y\ny\ny", expected => qr/But has to be read/ };
     90 
     91 # 14: sboremove nointeractive
     92 sboinstall 'nonexistentslackbuild', { input => "y\ny", test => 0 };
     93 sboremove qw'--nointeractive nonexistentslackbuild nonexistentslackbuild', { input => "y\ny", expected => qr/Removing 1 package\(s\)\nnonexistentslackbuild\n.*All operations/s };
     94 
     95 # Cleanup
     96 END {
     97 	cleanup();
     98 }