line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# The script tests Arch::Inventory methods. |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
728
|
use FindBin; |
|
1
|
|
|
|
|
1162
|
|
|
1
|
|
|
|
|
55
|
|
6
|
1
|
|
|
1
|
|
823
|
use lib "$FindBin::Bin/../perllib"; |
|
1
|
|
|
|
|
710
|
|
|
1
|
|
|
|
|
8
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1391
|
use Test::More; |
|
1
|
|
|
|
|
20996
|
|
|
1
|
|
|
|
|
11
|
|
9
|
1
|
|
|
1
|
|
1112
|
use Arch::Util qw(is_tla_functional); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3342
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
50
|
|
|
|
7
|
plan skip_all => "No functional arch backend" unless is_tla_functional; |
12
|
0
|
|
|
|
|
0
|
plan tests => 11; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
0
|
use_ok("Arch::Inventory"); |
15
|
0
|
|
|
|
|
0
|
use_ok("Arch::Test::Framework"); |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
0
|
my $framework = Arch::Test::Framework->new; |
18
|
0
|
|
|
|
|
0
|
my $archive = $framework->make_archive; |
19
|
0
|
|
|
|
|
0
|
my $version = $archive->make_version; |
20
|
0
|
|
|
|
|
0
|
my $tree = Arch::Test::Cases::generate_complex_tree($framework, $version); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
0
|
my $inv = Arch::Inventory->new($tree->root); |
24
|
0
|
|
|
|
|
0
|
isa_ok($inv, 'Arch::Inventory', 'new inventory'); |
25
|
0
|
|
|
|
|
0
|
is($inv->directory, $tree->root, 'correct root directory'); |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
0
|
my $root = $inv->get_root_entry; |
28
|
0
|
|
|
|
|
0
|
isa_ok($root, 'HASH', 'root entry'); |
29
|
0
|
|
|
|
|
0
|
is($inv->to_string($root), "T d \t???", 'correct root entry string'); |
30
|
0
|
|
|
|
|
0
|
is($inv->get_entry(''), $root, 'root entry via ->get_entry'); |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
0
|
my @inv_listing = $tree->run_tla('inventory', '-Btspbju', '--kind', '--ids'); |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
0
|
my ($ok, $cnt); |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
$cnt = 0; |
37
|
0
|
|
|
0
|
|
0
|
$inv->foreach(sub { ++$cnt }); |
|
0
|
|
|
|
|
0
|
|
38
|
0
|
|
|
|
|
0
|
is($cnt, scalar @inv_listing + 1, '->foreach count'); |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
$ok = 1; |
41
|
0
|
|
|
|
|
0
|
foreach my $line (@inv_listing) { |
42
|
0
|
|
|
|
|
0
|
my (undef, undef, $path) = split /\s+/, $line; |
43
|
0
|
|
|
|
|
0
|
my $entry = $inv->get_entry($path); |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
0
|
|
|
0
|
$ok &&= $entry->{path} eq $path; |
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
0
|
ok($ok, 'scalar ->get_entry'); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
0
|
$ok = 1; |
50
|
0
|
|
|
|
|
0
|
foreach my $line (@inv_listing) { |
51
|
0
|
|
|
|
|
0
|
my (undef, undef, $path) = split /\s+/, $line; |
52
|
0
|
|
|
|
|
0
|
my $entry = $inv->get_entry(split /\//, $path); |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
0
|
|
|
0
|
$ok &&= $entry->{path} eq $path; |
55
|
|
|
|
|
|
|
} |
56
|
0
|
|
|
|
|
0
|
ok($ok, 'list ->get_entry'); |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
0
|
ok( |
59
|
|
|
|
|
|
|
eq_set( |
60
|
|
|
|
|
|
|
[split /\n/, $inv->get_listing], |
61
|
|
|
|
|
|
|
[@inv_listing] |
62
|
|
|
|
|
|
|
), |
63
|
|
|
|
|
|
|
'correct inventory listing' |
64
|
|
|
|
|
|
|
); |