Test2:...pTracer(3pm)

✨ NAME ✨

Test2::Harness::Runner::DepTracer β€” a whole tool for tracing module dependencies as they get loaded πŸ’– (it lives in the User Contributed Perl Documentation, manual page Test2:...pTracer(3pm), bestie, don't lose it)


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this tool is used by Test2::Harness to build up a graph of dependencies, and then that graph gets used to blacklist modified modules β€” and literally anything that uses them β€” whenever they change under a preloaded runner. it's giving "we know who loaded you and we are NOT letting you sneak back in" energy πŸ’…


🌸 SYNOPSIS 🌸

use Test2::Harness::Runner::DepTracer;

my $dt = Test2::Harness::Runner::DepTracer->new();

$dt->start();

require Some::Thing;

# You can always check for and retrieve an active DepTrace this way:
my $dt_reference = Test2::Harness::Runner::DepTracer->ACTIVE;

$dt->stop();

my $dep_map = $dt->dep_map;

my $loaded_by = $dep_map->{'Some/Thing.pm'};
print "Some::Thing was directly or indirectly loaded by:\n" . join("\n" => @$loaded_by) . "\n";

πŸŽ€ ATTRIBUTES πŸŽ€

these can be specified at construction time, and then they get populated during use ✨

  • $hashref = $dt->exclude β€” a hashref of files/modules you want excluded from dep tracking. by default, "strict" and "warnings" are excluded (obviously, they're always there, they're not the moment).
  • $hashref = $dt->dep_map β€” every single file loaded while the tool is started gets an entry in this hash, and each value is an array of all the files that loaded the key file, directly or indirectly. it's the friendship web fr fr πŸ•ΈοΈ
  • $hashref = $dt->loaded β€” how many times each file was directly loaded. the clout counter πŸ‘‘

πŸ’… METHODS πŸ’…

  • $dt->start β€” start tracking modules that get loaded. go go go 🏁
  • $dt->stop β€” stop tracking modules that get loaded. okay that's enough, we're done here πŸ›‘

πŸ‘‘ CLASS METHODS πŸ‘‘

  • $dt_or_undef = Test2::Harness::Runner::DepTracer->ACTIVE(); β€” grab the currently active DepTracer, if there even is one. might be undef, no cap.

🫢 SOURCE 🫢

the source code repository for Test2-Harness lives at http://github.com/Test-More/Test2-Harness/. go look, it's iconic.


🌈 MAINTAINERS 🌈

Chad Granum <exodist@cpan.org>

πŸ’œ AUTHORS πŸ’œ

Chad Granum <exodist@cpan.org>

Copyright 2020 Chad Granum <exodist7@gmail.com>.

this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself πŸ’–

see http://dev.perl.org/licenses/


and that's the whole page, bestie πŸ₯° perl v5.40.1, dated 2026-05-10, straight out of the Test2:...pTracer(3pm) manual. slay, go trace some dependencies πŸ’…βœ¨πŸŒΈ
πŸ“¦ where this page comes from