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 unlink "fatpacker.trace";
19 system($^X, "-Mblib", "-MApp::FatPacker::Trace", $file);
21 open my $trace, "<", "fatpacker.trace";
22 my @traced = sort map { chomp; $_ } <$trace>;
24 is_deeply \@traced, \@loaded, "All expected modules loaded for $file";
25 unlink "fatpacker.trace";
28 test_trace("t/mod/a.pm" => ("t/mod/b.pm", "t/mod/c.pm"));
30 sub test_trace_stderr {
31 my($file, @loaded) = @_;
32 local $Test::Builder::Level = $Test::Builder::Level + 1;
35 $^X, "-Mblib", "-MApp::FatPacker::Trace", '--to-stderr', $file,
36 '>', 'fatpacker.trace', '2>&1'));
38 open my $trace, "<", "fatpacker.trace";
42 @loaded = grep { $load ne $_ } @loaded;
45 ok !@loaded, "All expected modules loaded for $file";
46 unlink "fatpacker.trace";