17-find.t (2973B)
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_gpg_verify set_lo sbofind replace_tags_txt set_repo sbosnap /; 11 use File::Temp 'tempdir'; 12 13 plan tests => 10; 14 15 make_slackbuilds_txt(); 16 set_gpg_verify('FALSE'); 17 set_lo("$RealBin/LO"); 18 19 # 1: basic sbofind testing 20 sbofind 'nonexistentslackbuild4', { expected => qr!Local:\s+nonexistentslackbuild4 .*\nPath:\s+\Q$RealBin/LO/nonexistentslackbuild4! }; 21 22 # 2: basic sbofind testing - nothing found 23 sbofind 'nonexistentslackbuild3', { expected => "Nothing found for search term: nonexistentslackbuild3\n" }; 24 25 # 3: find something using a tag 26 replace_tags_txt("nonexistentslackbuild2: testingtag\n"); 27 sbofind 'testingtag', { expected => qr!Local:\s+nonexistentslackbuild2 .*\nPath:\s+\Q$RealBin/LO/nonexistentslackbuild2! }; 28 29 # 4: show build queue 30 sbofind '-q', 'nonexistentslackbuild2', { expected => qr/Queue:\s+nonexistentslackbuild3 nonexistentslackbuild2/ }; 31 32 # 5: show readme 33 sbofind '-r', 'nonexistentslackbuild4', { expected => qr/README: \n This doesn't exist!/ }; 34 35 # 6: show info 36 sbofind '-i', 'nonexistentslackbuild4', { expected => qr/info: \n PRGNAM="nonexistentslackbuild4"/ }; 37 38 # 7: find even if SLACKBUILDS.TXT doesn't have LOCATION as second entry 39 my $tempdir = tempdir(CLEANUP => 1); 40 note capture_merged { system <<"GIT"; }; 41 cd $tempdir 42 git init 43 mkdir -p test 44 cp -a "$RealBin/LO/nonexistentslackbuild" test/ 45 cp -a "$RealBin/LO-R/R" test/ 46 cp -a "$RealBin/LO-R/foo" test/ 47 cp -a "$RealBin/LO-R/bar" test/ 48 echo "SLACKBUILD NAME: nonexistentslackbuild" > SLACKBUILDS.TXT 49 echo "SLACKBUILD FOO: bar" >> SLACKBUILDS.TXT 50 echo "SLACKBUILD LOCATION: ./test/nonexistentslackbuild" >> SLACKBUILDS.TXT 51 echo "SLACKBUILD NAME: R" >> SLACKBUILDS.TXT 52 echo "SLACKBUILD LOCATION: ./test/R" >> SLACKBUILDS.TXT 53 echo "SLACKBUILD NAME: foo" >> SLACKBUILDS.TXT 54 echo "SLACKBUILD LOCATION: ./test/foo" >> SLACKBUILDS.TXT 55 echo "SLACKBUILD NAME: bar" >> SLACKBUILDS.TXT 56 echo "SLACKBUILD LOCATION: ./test/bar" >> SLACKBUILDS.TXT 57 git add test SLACKBUILDS.TXT 58 git commit -m 'initial' 59 GIT 60 set_repo("file://$tempdir"); 61 set_lo('FALSE'); 62 sbosnap 'fetch', { test => 0, note => 1 }; 63 64 sbofind 'nonexistentslackbuild', { expected => qr!\Q/usr/sbo/repo/test/nonexistentslackbuild! }; 65 66 replace_tags_txt("R: r\nfoo: r\nbar: rar"); 67 68 # 8: non-restricted search finds a lot 69 sbofind qw/R/, { expected => <<"END" }; 70 SBo: R 1.0 71 Path: /usr/sbo/repo/test/R 72 73 SBo: foo 1.0 74 Path: /usr/sbo/repo/test/foo 75 76 SBo: bar 1.0 77 Path: /usr/sbo/repo/test/bar 78 79 END 80 81 # 9: checking for exact matches (including tags) 82 sbofind qw/ -e R /, { expected => <<"END" }; 83 SBo: R 1.0 84 Path: /usr/sbo/repo/test/R 85 86 SBo: foo 1.0 87 Path: /usr/sbo/repo/test/foo 88 89 END 90 91 # 10: exact matches (excluding tags) 92 sbofind qw/ -et R /, { expected => <<"END" }; 93 SBo: R 1.0 94 Path: /usr/sbo/repo/test/R 95 96 END