File: trace.t

package info (click to toggle)
libapp-fatpacker-perl 0.010008-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 144 kB
  • sloc: perl: 325; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 789 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use strict;
use warnings FATAL => 'all';
use Test::More qw(no_plan);

test_trace("t/mod/ModuleA.pm" => ("ModuleB.pm", "ModuleC.pm"));
test_trace("t/mod/ModuleB.pm" => ("ModuleC.pm"));
test_trace("t/mod/ModuleC.pm" => ());
test_trace("t/mod/ModuleD.pl" => ("ModuleD.pm"));

# Attempts to conditionally load a module that isn't present
test_trace("t/mod/ModuleCond.pm" => ());

sub test_trace {
  my($file, @loaded) = @_;
  local $Test::Builder::Level = $Test::Builder::Level + 1;

  unlink "fatpacker.trace";
  system($^X, "-Mblib", '-It/mod', "-MApp::FatPacker::Trace", $file);

  open my $trace, "<", "fatpacker.trace";
  my @traced = sort map { chomp; $_ } <$trace>;
  close $trace;

  is_deeply \@traced, \@loaded, "All expected modules loaded for $file";
  unlink "fatpacker.trace";
}