aboutsummaryrefslogtreecommitdiff
path: root/t/17-find.t
blob: c911d4c7629937cd6345384230d54f11985b468f (plain)
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
#!/usr/bin/env perl

use 5.16.0;
use strict;
use warnings FATAL => 'all';
use Test::More;
use Capture::Tiny qw/ capture_merged /;
use FindBin '$RealBin';
use lib $RealBin;
use Test::Sbotools qw/ make_slackbuilds_txt set_lo sbofind replace_tags_txt set_repo sbosnap /;
use File::Temp 'tempdir';

plan tests => 10;

make_slackbuilds_txt();
set_lo("$RealBin/LO");

# 1: basic sbofind testing
sbofind 'nonexistentslackbuild4', { expected => qr!Local:\s+nonexistentslackbuild4 .*\nPath:\s+\Q$RealBin/LO/nonexistentslackbuild4! };

# 2: basic sbofind testing - nothing found
sbofind 'nonexistentslackbuild3', { expected => "Nothing found for search term: nonexistentslackbuild3\n" };

# 3: find something using a tag
replace_tags_txt("nonexistentslackbuild2: testingtag\n");
sbofind 'testingtag', { expected => qr!Local:\s+nonexistentslackbuild2 .*\nPath:\s+\Q$RealBin/LO/nonexistentslackbuild2! };

# 4: show build queue
sbofind '-q', 'nonexistentslackbuild2', { expected => qr/Queue:\s+nonexistentslackbuild3 nonexistentslackbuild2/ };

# 5: show readme
sbofind '-r', 'nonexistentslackbuild4', { expected => qr/README: \n      This doesn't exist!/ };

# 6: show info
sbofind '-i', 'nonexistentslackbuild4', { expected => qr/info:   \n      PRGNAM="nonexistentslackbuild4"/ };

# 7: find even if SLACKBUILDS.TXT doesn't have LOCATION as second entry
my $tempdir = tempdir(CLEANUP => 1);
note capture_merged { system <<"GIT"; };
cd $tempdir
git init
mkdir -p test
cp -a "$RealBin/LO/nonexistentslackbuild" test/
cp -a "$RealBin/LO-R/R" test/
cp -a "$RealBin/LO-R/foo" test/
cp -a "$RealBin/LO-R/bar" test/
echo "SLACKBUILD NAME: nonexistentslackbuild" > SLACKBUILDS.TXT
echo "SLACKBUILD FOO: bar" >> SLACKBUILDS.TXT
echo "SLACKBUILD LOCATION: ./test/nonexistentslackbuild" >> SLACKBUILDS.TXT
echo "SLACKBUILD NAME: R" >> SLACKBUILDS.TXT
echo "SLACKBUILD LOCATION: ./test/R" >> SLACKBUILDS.TXT
echo "SLACKBUILD NAME: foo" >> SLACKBUILDS.TXT
echo "SLACKBUILD LOCATION: ./test/foo" >> SLACKBUILDS.TXT
echo "SLACKBUILD NAME: bar" >> SLACKBUILDS.TXT
echo "SLACKBUILD LOCATION: ./test/bar" >> SLACKBUILDS.TXT
git add test SLACKBUILDS.TXT
git commit -m 'initial'
GIT
set_repo("file://$tempdir");
set_lo('FALSE');
sbosnap 'fetch', { test => 0, note => 1 };

sbofind 'nonexistentslackbuild', { expected => qr!\Q/usr/sbo/repo/test/nonexistentslackbuild! };

replace_tags_txt("R: r\nfoo: r\nbar: rar");

# 8: non-restricted search finds a lot
sbofind qw/R/, { expected => <<"END" };
SBo:    R 1.0
Path:   /usr/sbo/repo/test/R

SBo:    foo 1.0
Path:   /usr/sbo/repo/test/foo

SBo:    bar 1.0
Path:   /usr/sbo/repo/test/bar

END

# 9: checking for exact matches (including tags)
sbofind qw/ -e R /, { expected => <<"END" };
SBo:    R 1.0
Path:   /usr/sbo/repo/test/R

SBo:    foo 1.0
Path:   /usr/sbo/repo/test/foo

END

# 10: exact matches (excluding tags)
sbofind qw/ -et R /, { expected => <<"END" };
SBo:    R 1.0
Path:   /usr/sbo/repo/test/R

END