sbotools2

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

13-local-check.t (7448B)


      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 set_repo sboconfig sbosnap sbocheck sboinstall sbofind restore_perf_dummy /;
     11 
     12 if ($ENV{TEST_INSTALL} and $ENV{TRAVIS}) {
     13 	plan tests => 14;
     14 } else {
     15 	plan skip_all => "Only run these tests if TEST_INSTALL=1 and we're running under Travis CI";
     16 }
     17 
     18 sub cleanup {
     19 	capture_merged {
     20 		system(qw!/sbin/removepkg nonexistentslackbuild!);
     21 		system(qw!/sbin/removepkg nonexistentslackbuild5!);
     22 		system(qw!/sbin/removepkg nonexistentslackbuild8!);
     23 		system(qw!/sbin/removepkg nonexistentslackbuildwithareallyverylongnameasyoucansee!);
     24 		system(qw!/sbin/removepkg s!);
     25 		system(qw!/sbin/removepkg nonexistentslackbuildwithareallyverylo!);
     26 		system(qw!/sbin/removepkg nonexistentslackbuildwithareallyverylon!);
     27 		system(qw!/sbin/removepkg nonexistentslackbuildwithareallyverylong!);
     28 		system(qw!/sbin/removepkg s2!);
     29 		system(qw!/sbin/removepkg weird-versionsbo!);
     30 		unlink "$RealBin/LO/nonexistentslackbuild/perf.dummy";
     31 		unlink "$RealBin/LO/weird-versionsbo/perf.dummy";
     32 		system(qw!rm -rf /tmp/SBo/nonexistentslackbuild-1.0!);
     33 		system(qw!rm -rf /tmp/SBo/nonexistentslackbuild5-1.0!);
     34 		system(qw!rm -rf /tmp/SBo/nonexistentslackbuild8-1.0!);
     35 		system(qw!rm -rf /tmp/SBo/nonexistentslackbuildwithareallyverylongnameasyoucansee-1.0!);
     36 		system(qw!rm -rf /tmp/SBo/s-1.0!);
     37 		system(qw!rm -rf /tmp/SBo/nonexistentslackbuildwithareallyverylo-1.0!);
     38 		system(qw!rm -rf /tmp/SBo/nonexistentslackbuildwithareallyverylon-1.0!);
     39 		system(qw!rm -rf /tmp/SBo/nonexistentslackbuildwithareallyverylon-1.0g!);
     40 		system(qw!rm -rf /tmp/SBo/s2-1.0!);
     41 		system(qw!rm -rf /tmp/SBo/weird-versionsbo-1.0!);
     42 		system(qw!rm -rf /tmp/package-nonexistentslackbuild!);
     43 		system(qw!rm -rf /tmp/package-nonexistentslackbuild5!);
     44 		system(qw!rm -rf /tmp/package-nonexistentslackbuild8!);
     45 		system(qw!rm -rf /tmp/package-nonexistentslackbuildwithareallyverylongnameasyoucansee!);
     46 		system(qw!rm -rf /tmp/package-s!);
     47 		system(qw!rm -rf /tmp/package-nonexistentslackbuildwithareallyverylo!);
     48 		system(qw!rm -rf /tmp/package-nonexistentslackbuildwithareallyverylon!);
     49 		system(qw!rm -rf /tmp/package-nonexistentslackbuildwithareallyverylong!);
     50 		system(qw!rm -rf /tmp/package-s2!);
     51 		system(qw!rm -rf /tmp/package-weird-versionsbo!);
     52 		system(qw!rm -rf!, "$RealBin/gitrepo");
     53 	};
     54 }
     55 
     56 sub setup_gitrepo {
     57 	capture_merged { system(<<"END"); };
     58 		cd "$RealBin"; rm -rf gitrepo; mkdir gitrepo; cd gitrepo;
     59 		git init;
     60 
     61 		mkdir -p "test/nonexistentslackbuild" "test/nonexistentslackbuild5";
     62 		cp "$RealBin/LO2/nonexistentslackbuild/nonexistentslackbuild.info" "test/nonexistentslackbuild"
     63 		cp "$RealBin/LO/nonexistentslackbuild5/nonexistentslackbuild5.info" "test/nonexistentslackbuild5"
     64 		git add "test"; git commit -m 'initial';
     65 END
     66 }
     67 
     68 cleanup();
     69 make_slackbuilds_txt();
     70 set_lo("$RealBin/LO");
     71 setup_gitrepo();
     72 set_repo("file://$RealBin/gitrepo/");
     73 restore_perf_dummy();
     74 
     75 # Disable GPG verification
     76 sboconfig(qw/ --gpg-key FALSE /, { test => 0 } );
     77 
     78 # 1-2: sbofind without having a repo yet
     79 sbofind 'nonexistentslackbuild', { input => "n", expected => qr/It looks like you haven't run "sbosnap fetch" yet\.\nWould you like me to do this now\?.*Please run "sbosnap fetch"/ };
     80 sbofind 'nonexistentslackbuild', { input => "y", expected => qr/It looks like you haven't run "sbosnap fetch" yet\.\nWould you like me to do this now\?/ };
     81 
     82 # 3: sbocheck without having installed nonexistentslackbuild should not show it
     83 sbocheck { expected => sub { $_[0] !~ /nonexistentslackbuild/} };
     84 
     85 # 4: sbocheck should list nonexistentslackbuild as being newer on SBo after we've installed it
     86 sboinstall 'nonexistentslackbuild', { input => "y\ny", test => 0 };
     87 sboinstall 'nonexistentslackbuild5', { input => "y\ny", test => 0 };
     88 sbocheck { expected => sub { /nonexistentslackbuild/ and not /nonexistentslackbuild5/ } };
     89 
     90 # 5-7: sbocheck should make lines match up as best it can
     91 sboinstall 'nonexistentslackbuildwithareallyverylongnameasyoucansee', { input => "y\ny", test => 0 };
     92 sboinstall 's', { input => "y\ny", test => 0 };
     93 sbocheck { expected => sub { /Updating SlackBuilds tree/ and not /nonexistentslackbuildwithareallyverylongnameasyoucansee/ } };
     94 
     95 capture_merged { system <<"GIT"; };
     96 	cd "$RealBin/gitrepo"
     97 
     98 	mkdir -p test/nonexistentslackbuildwithareallyverylongnameasyoucansee test/s
     99 	cp "$RealBin"/LO2/nonexistentslackbuildwithareallyverylongnameasyoucansee/* test/nonexistentslackbuildwithareallyverylongnameasyoucansee
    100 	cp "$RealBin"/LO2/s/* test/s
    101 	git add "test"; git commit -m 'updates';
    102 GIT
    103 
    104 sbocheck { expected => qr/\Qs 1.0                      <  override outdated (1.1 from SBo)/ };
    105 
    106 capture_merged { system <<"GIT"; };
    107 	cd "$RealBin/gitrepo"
    108 
    109 	mkdir -p test/nonexistentslackbuildwithareallyverylo
    110 	cp "$RealBin"/LO2/nonexistentslackbuildwithareallyverylo/* test/nonexistentslackbuildwithareallyverylo
    111 	git add "test"; git commit -m '2nd update'
    112 GIT
    113 
    114 sboinstall 'nonexistentslackbuildwithareallyverylo', { input => "y\ny", test => 0 };
    115 sbocheck { expected => qr/\Qs 1.0                                       <  override outdated (1.1 from SBo)/ };
    116 
    117 capture_merged { system <<"GIT"; };
    118 	cd "$RealBin/gitrepo"
    119 
    120 	mkdir -p test/nonexistentslackbuildwithareallyverylon
    121 	cp "$RealBin"/LO2/nonexistentslackbuildwithareallyverylon/* test/nonexistentslackbuildwithareallyverylon
    122 	git add "test"; git commit -m '3rd update'
    123 GIT
    124 
    125 sboinstall 'nonexistentslackbuildwithareallyverylon', { input => "y\ny", test => 0 };
    126 sbocheck { expected => qr/\Qs 1.0                                        <  override outdated (1.1 from SBo)/ };
    127 
    128 capture_merged { system <<"GIT"; };
    129 	cd "$RealBin/gitrepo"
    130 
    131 	mkdir -p test/nonexistentslackbuildwithareallyverylong
    132 	cp "$RealBin"/LO2/nonexistentslackbuildwithareallyverylong/* test/nonexistentslackbuildwithareallyverylong
    133 	git add "test"; git commit -m '4th update'
    134 GIT
    135 
    136 sboinstall 'nonexistentslackbuildwithareallyverylong', { input => "y\ny", test => 0 };
    137 sbocheck { expected => qr/\Qs 1.0                                        <  override outdated (1.1 from SBo)/ };
    138 
    139 # 10: check different version in repo and LO and installed
    140 set_lo("$RealBin/LO3");
    141 sbocheck { expected => qr/\Qs 1.0                       <  needs updating (0.9 from overrides, 1.1 from SBo)/ };
    142 
    143 # 11: check different version on SBo than what's installed
    144 set_lo('FALSE');
    145 sbocheck { expected => qr/\Qs 1.0                                         <  needs updating (1.1 from SBo)/ };
    146 
    147 # 12: check s2 being the same version in SBo but newer in LO
    148 capture_merged { system <<"GIT"; };
    149 	cd "$RealBin/gitrepo"
    150 
    151 	cp -a "$RealBin"/LO/s2 test/
    152 	git add "test/s2"; git commit -m '5th update'
    153 GIT
    154 sbosnap 'update', { test => 0 };
    155 sboinstall 's2', { input => "y\ny", test => 0 };
    156 set_lo("$RealBin/LO2");
    157 sbocheck { expected => qr/\Qs2 1.0                      <  needs updating (1.1 from overrides)/ };
    158 
    159 # 13: check weird-versionsbo isn't picked up erroneously
    160 set_lo("$RealBin/LO");
    161 sboinstall 'weird-versionsbo', { input => "y\ny", test => 0 };
    162 sbocheck { expected => sub { not /weird-versionsbo/ } };
    163 
    164 # 14: check sbo no longer available
    165 cleanup();
    166 setup_gitrepo();
    167 sbosnap 'update', { test => 0 };
    168 sboinstall 'nonexistentslackbuild8', { input => "y\ny", test => 0 };
    169 set_lo("$RealBin/LO2");
    170 sbocheck { expected => qr/No updates available[.]/ };
    171 
    172 # Cleanup
    173 END {
    174 	cleanup();
    175 }