Debian Codegraph @

t/bin/scan_also.t

raw
1 use strict;
2 use warnings;
3 use FindBin;
4 use lib "$FindBin::Bin/../../";
5 use Test::More;
6 use t::Util;
7
8 test_bin('also scan extlib', sub {
9 my $tmpdir = shift;
10
11 test_file("$tmpdir/MyTest.pm", <<'END');
12 use strict;
13 use warnings;
14 use Foo;
15 END
16
17 test_file("$tmpdir/extlib/MyTest2.pm", <<'END');
18 use strict;
19 use warnings;
20 use Bar;
21 END
22 }, [qw/--scan-also extlib/], <<'CPANFILE');
23 requires 'Bar';
24 requires 'Foo';
25 requires 'strict';
26 requires 'warnings';
27 CPANFILE
28
29 test_bin('also and local', sub {
30 my $tmpdir = shift;
31
32 test_file("$tmpdir/MyTest.pm", <<'END');
33 use strict;
34 use warnings;
35 use Foo; # --scan-also makes this a local module
36 END
37
38 test_file("$tmpdir/extlib/Foo.pm", <<'END');
39 use strict;
40 use warnings;
41 use Bar;
42 END
43 }, [qw/--also extlib/], <<'CPANFILE');
44 requires 'Bar';
45 requires 'strict';
46 requires 'warnings';
47 CPANFILE
48
49 test_bin('also and test files', sub {
50 my $tmpdir = shift;
51
52 test_file("$tmpdir/MyTest.pm", <<'END');
53 use strict;
54 use warnings;
55 use Foo; # t/Foo.pm is not a local file
56 END
57
58 test_file("$tmpdir/extlib/Foo/t/load.t", <<'END');
59 use strict;
60 use warnings;
61 use Test::More;
62 END
63
64 # this is not used from .t files and thus ignored
65 test_file("$tmpdir/extlib/Foo/t/Foo.pm", <<'END');
66 use strict;
67 use warnings;
68 use Bar;
69 END
70 }, [qw/--scan-also extlib/], <<'CPANFILE');
71 requires 'Foo';
72 requires 'strict';
73 requires 'warnings';
74
75 on test => sub {
76 requires 'Test::More';
77 requires 'strict';
78 requires 'warnings';
79 };
80 CPANFILE
81
82 done_testing;