Debian Codegraph @

t/findorule.t

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 #!perl
2
3 use strictscip-perl cpan File-Find-Object-Rule 0.0313 strict/;
4 use warningsscip-perl cpan File-Find-Object-Rule 0.0313 warnings/;
5
6 use Test::Morescip-perl cpan File-Find-Object-Rule 0.0313 Test/More/ tests => 5;
7 use File::Specscip-perl cpan File-Find-Object-Rule 0.0313 File/Spec/;
8
9 use File::Pathscip-perl cpan File-Find-Object-Rule 0.0313 File/Path/;
10 use File::TreeCreatescip-perl cpan File-Find-Object-Rule 0.0313 File/TreeCreate/ ();
11
12 my $tree_creator = File::TreeCreate->newscip-perl cpan File-Find-Object-Rule 0.0313 File/TreeCreate/new().();
13
14 {
15 my $tree = {
16 'name' => "findorule-t-copy-to/",
17 'subs' => [
18 {
19 'name' => "File-Find-Rule.t",
20 'contents' => "content",
21 },
22 {
23 'name' => "findorule.t",
24 'contents' => "content",
25 },
26 {
27 'name' => "foobar",
28 'contents' => "content",
29
30 },
31 {
32 'name' => "lib/",
33 'subs' => [
34 {
35 'name' => "File/",
36 'subs' => [
37 {
38 name => "Find/",
39 subs => [
40 {
41 name => "Object/",
42 subs => [
43 {
44 name => "Rule/",
45 subs => [
46 {
47 name => "Test/",
48 subs => [
49 {
50 name =>
51 "ATeam.pm",
52 content =>
53 "content",
54 }
55 ],
56 },
57 ],
58 }
59 ],
60 },
61 ],
62 },
63 ],
64 },
65 ],
66 },
67 ],
68 };
69
70 $tree_creator->create_treescip-perl cpan File-Find-Object-Rule 0.0313 File/TreeCreate/create_tree().( "./t/sample-data/", $tree );
71 }
72
73 # extra tests for findorule. these are more for testing the parsing code.
74
75 sub runscip-perl cpan File-Find-Object-Rule 0.0313 main/run().
76 {
77 my $expr = shiftscip-perl cpan File-Find-Object-Rule 0.0313 main/shift().;
78 my $script =
79 File::Spec->catfilescip-perl cpan File-Find-Object-Rule 0.0313 File/Spec/catfile().( File::Spec->curdirscip-perl cpan File-Find-Object-Rule 0.0313 File/Spec/curdir().(), "bin", "findorule" );
•80 $script = '/usr/bin/findorule' if $ENVscip-perl cpan File-Find-Object-Rule 0.0313 main/`%ENV`.{AUTOPKGTEST_TMP};
81
82 [ sortscip-perl cpan File-Find-Object-Rule 0.0313 main/sort(). splitscip-perl cpan File-Find-Object-Rule 0.0313 main/split(). /\n/, `$^X -Mblib $script $expr` ];
83 }
84
85 my $copy_fn = $tree_creator->get_pathscip-perl cpan File-Find-Object-Rule 0.0313 File/TreeCreate/get_path().("./t/sample-data/findorule-t-copy-to/");
86
87 my $FFR_t = $tree_creator->get_pathscip-perl cpan File-Find-Object-Rule 0.0313 File/TreeCreate/get_path().(
88 "./t/sample-data/findorule-t-copy-to/File-Find-Rule.t");
89 my $findorule_t =
90 $tree_creator->get_pathscip-perl cpan File-Find-Object-Rule 0.0313 File/TreeCreate/get_path().("./t/sample-data/findorule-t-copy-to/findorule.t");
91 my $foobar_fn =
92 $tree_creator->get_pathscip-perl cpan File-Find-Object-Rule 0.0313 File/TreeCreate/get_path().("./t/sample-data/findorule-t-copy-to/foobar");
93
94 # TEST
95 is_deeplyscip-perl cpan File-Find-Object-Rule 0.0313 main/is_deeply().( runscip-perl cpan File-Find-Object-Rule 0.0313 main/run().( $copy_fn . ' -file -name foobar' ),
96 [$foobar_fn], '-file -name foobar' );
97
98 # TEST
99 is_deeplyscip-perl cpan File-Find-Object-Rule 0.0313 main/is_deeply().( runscip-perl cpan File-Find-Object-Rule 0.0313 main/run().( $copy_fn . ' -maxdepth 0 -directory' ),
100 [$copy_fn], 'last clause has no args' );
101
102 {
103 local $TODOscip-perl cpan File-Find-Object-Rule 0.0313 main/$TODO. = "Win32 cmd.exe hurts my brain"
104 if ( $^Oscip-perl cpan File-Find-Object-Rule 0.0313 main/`$^O`. =~ m/Win32/ || $^Oscip-perl cpan File-Find-Object-Rule 0.0313 main/`$^O`. eq 'dos' );
105
106 # TEST
107 is_deeplyscip-perl cpan File-Find-Object-Rule 0.0313 main/is_deeply().(
108 runscip-perl cpan File-Find-Object-Rule 0.0313 main/run().( $copy_fn . ' -file -name \( foobar \*.t \)' ),
109 [ $FFR_t, $findorule_t, $foobar_fn ],
110 'grouping ()'
111 );
112
113 # TEST
114 is_deeplyscip-perl cpan File-Find-Object-Rule 0.0313 main/is_deeply().( runscip-perl cpan File-Find-Object-Rule 0.0313 main/run().( $copy_fn . ' -name \( -foo foobar \)' ),
115 [$foobar_fn], 'grouping ( -literal )' );
116 }
117
118 # Remming out due to capturing STDERR using unixisms. In the future, we
119 # may implement this using Test::Trap.
120 # is_deeply(run $copy_fn . ' -file -name foobar baz',
121 # [ "unknown option 'baz'" ], 'no implicit grouping');
122
123 # TEST
124 is_deeplyscip-perl cpan File-Find-Object-Rule 0.0313 main/is_deeply().( runscip-perl cpan File-Find-Object-Rule 0.0313 main/run().( $copy_fn . ' -maxdepth 0 -name -file' ),
125 [], 'terminate at next -' );
126
127 rmtreescip-perl cpan File-Find-Object-Rule 0.0313 main/rmtree().($copy_fn);