3 use warnings FATAL => 'all';
4 use Test::More qw(no_plan);
6 test_trace("t/mod/a.pm" => ("t/mod/b.pm", "t/mod/c.pm"));
7 test_trace("t/mod/b.pm" => ("t/mod/c.pm"));
8 test_trace("t/mod/c.pm" => ());
9 test_trace("t/mod/d.pl" => ("t/mod/d.pm"));
11 # Attempts to conditionally load a module that isn't present
12 test_trace("t/mod/cond.pm" => ());
15 my($file, @loaded) = @_;
16 local $Test::Builder::Level = $Test::Builder::Level + 1;
18 system($^X, "-Mblib", "-MApp::FatPacker::Trace", $file);
20 open my $trace, "<", "fatpacker.trace";
21 my @traced = sort map { chomp; $_ } <$trace>;
23 is_deeply \@loaded, \@traced, "All expected modules loaded for $file";
24 unlink "fatpacker.trace";
27 test_trace("t/mod/a.pm" => ("t/mod/b.pm", "t/mod/c.pm"));
29 sub test_trace_stderr {
30 my($file, @loaded) = @_;
31 local $Test::Builder::Level = $Test::Builder::Level + 1;
34 $^X, "-Mblib", "-MApp::FatPacker::Trace", '--to-stderr', $file,
35 '>', 'fatpacker.trace', '2>&1'));
37 open my $trace, "<", "fatpacker.trace";
41 @loaded = grep { $load ne $_ } @loaded;
44 ok !@loaded, "All expected modules loaded for $file";
45 unlink "fatpacker.trace";