File Coverage

tests/test-tree-1
Criterion Covered Total %
statement 13 54 24.0
branch 1 4 25.0
condition 0 3 0.0
subroutine 4 4 100.0
pod n/a
total 18 65 27.6


line stmt bran cond sub pod time code
1             #!/usr/bin/perl -w
2              
3             # The script tests Arch::Test::Tree methods.
4              
5 1     1   902 use FindBin;
  1         1172  
  1         52  
6 1     1   782 use lib "$FindBin::Bin/../perllib";
  1         718  
  1         8  
7              
8 1     1   1233 use Test::More;
  1         21061  
  1         11  
9 1     1   892 use Arch::Util qw(is_tla_functional);
  1         3  
  1         2331  
10              
11 1 50       7 plan skip_all => "No functional arch backend" unless is_tla_functional;
12 0         0 plan tests => 14;
13              
14 0         0 use_ok("Arch::Test::Framework");
15 0         0 use_ok("Arch::Backend", "is_baz", "arch_backend_version");
16              
17 0         0 my $fw = Arch::Test::Framework->new;
18 0         0 isa_ok($fw, 'Arch::Test::Framework', 'environment');
19 0         0 my $ar = $fw->make_archive;
20 0         0 isa_ok($ar, 'Arch::Test::Archive', 'archive');
21              
22 0         0 my $version = $ar->make_version();
23 0         0 my $tree = $fw->make_tree($version);
24 0         0 isa_ok($tree, 'Arch::Test::Tree', 'tree');
25              
26 0         0 my $dir1 = $tree->add_dir();
27 0         0 my $dir2 = $tree->add_dir($dir1, 'mydir');
28 0         0 my $file1 = $tree->add_file();
29 0         0 my $file2 = $tree->add_file($dir1, 'myfile', 'howdiw ho');
30              
31 0         0 my @inv = map { './' . $_ }
  0         0  
32             $tree->run_tla('inventory', '-Bs');
33              
34 0         0 ok(
35             eq_set(
36             [@inv],
37             [$dir1, $dir2, $file1, $file2]
38             ),
39             "inventory is correct"
40             );
41              
42 0 0 0     0 SKIP: {
43 0         0 skip("buggy baz-1.2", 8) if is_baz() && arch_backend_version() =~ /^1\.2\b/;
44              
45 0         0 $tree->import('initial import');
46              
47 0         0 my @lines = $fw->run_tla('revisions', '-s', $version);
48 0         0 is(scalar @lines, 2, 'single revision');
49 0         0 is($lines[0], 'base-0', 'base-0 import');
50 0         0 is($lines[1], ' initial import', 'import summary');
51              
52 0         0 my $file3 = $tree->add_file($dir2, undef, 'stuff');
53 0         0 my @inv2 = map { './' . $_ }
  0         0  
54             $tree->run_tla('inventory', '-Bs');
55              
56 0         0 ok(
57             eq_set(
58             [@inv2],
59             [$dir1, $dir2, $file1, $file2, $file3]
60             ),
61             "inventory is correct"
62             );
63              
64 0         0 $tree->commit('commit');
65              
66 0         0 @lines = $fw->run_tla('revisions', '-s', $version);
67 0         0 is(scalar @lines, 4, 'two revisions');
68 0         0 is($lines[2], 'patch-1', 'patch-1 commit');
69 0         0 is($lines[3], ' commit', 'patch summary');
70              
71 0         0 $tree->remove_file($file3);
72 0         0 $tree->remove_dir($dir2);
73 0         0 $tree->remove_file($file2);
74              
75 0         0 $dir1 = $tree->rename_dir($dir1, 'test-dir');
76 0         0 $file1 = $tree->rename_file($file1, $dir1);
77              
78 0         0 my @inv3 = map { './' . $_ }
  0         0  
79             $tree->run_tla('inventory', '-Bs');
80              
81 0         0 ok(
82             eq_set(
83             [@inv3],
84             [$dir1, $file1]
85             ),
86             "inventory is correct after remove/rename"
87             );
88              
89             }