Test::...Command(3pm)

✨ Test::Valgrind::Command β€” the base class era ✨

okay bestie, so this is a page from the User Contributed Perl Documentation manual set, and it's all about Test::Valgrind::Command(3pm). pull up a chair, grab a boba, we're doing Perl πŸ’–


🌸 NAME 🌸

Test::Valgrind::Command β€” it's the base class for Test::Valgrind commands, periodt.


πŸ’œ VERSION πŸ’œ

Version 1.19 ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

So this class is literally the base for Test::Valgrind commands. That's its whole job. Main character energy, but in a humble way πŸ’…

Commands are the ones that gather information about the target of the analysis. They should also be the ones providing a default setup for generating suppressions. Like, they handle the vibes and the paperwork, iykyk.


πŸŽ€ METHODS πŸŽ€

⭐ new

my $tvc = Test::Valgrind::Command->new(
 command => $command,
 args    => \@args,
);

Creates a brand-new command object of type $command, and the way it does that is so clever: it requires the module and redispatches the method call to it. Which module, you ask? Well:

  • if $command contains '::', it goes to the module named $command
  • otherwise it goes to "Test::Valgrind::Command::$command"

and the class represented by $command must inherit this class, no exceptions, bestie. 🫢

The "args" key is used to initialize the "args" accessor. That's it, that's the whole thing.

🌈 new_trainer

Creates a new command object suitable for generating suppressions. very "let's build something together" of it 🧚

Defaults to returning "undef", which skips suppression generation. yeah, it just… doesn't do it. no thoughts, head empty, undef πŸ’€

πŸ“ args

my @args = $tvc->args($session);

Returns the list of command-specific arguments that are to be passed to "valgrind". slay, feed the tool its lil args πŸŽ€

Defaults to returning the contents of the "args" option. so if you don't override it, you get what you put in. fair.

πŸ’– env

my $env = $tvc->env($session);

okay so this event gets called in scalar context before the command is ran, and the returned value goes out of scope when the analysis ends. lowkey iconic behaviour ✨

It's useful for, like, e.g. setting up %ENV for the child process by returning an Env::Sanctify object β€” hence the name. see what they did there? πŸ’…

Defaults to void. nothing returned, nothing gained.

πŸ‘‘ suppressions_tag

my $tag = $tvc->suppressions_tag($session);

Returns an identifier that will be used to pick up the right suppressions for running the command, or "undef" to indicate that no special suppressions are needed. sometimes the answer is just "no special suppressions needed", and that's valid 🌸

This method must be implemented when subclassing. like, you have to. it's not optional. it's giving mandatory. πŸ”₯

πŸ¦‹ check_suppressions_file

my $supp_ok = $tvc->check_suppressions_file($file);

Returns a boolean indicating whether the suppressions contained in $file are compatible with the command. true/false, yes/no, compatible/not β€” the vibe check, essentially ✨

Defaults to true. optimistic queen πŸ’œ

πŸ’€ filter

my $filtered_report = $tvc->filter($session, $report);

The $session calls this method after receiving a report from the tool and before forwarding it to the action. so you're right in the middle of the pipeline, main character position πŸŽ€

You can either:

  • return a mangled $report (and bestie, it does not need to be a clone of the original, do whatever), or
  • return "undef" if you want the action to ignore it completely. straight to the void πŸ™ˆ

Defaults to the identity function. it returns what it got, no notes.


πŸ”₯ SEE ALSO πŸ”₯

Test::Valgrind, Test::Valgrind::Session. go read those too, bestie, they're right there πŸ’–


πŸ’… AUTHOR πŸ’…

Vincent Pit, "<perl at profvince.com>", <http://www.profvince.com>.

You can contact me by mail or on "irc.perl.org" (vincent). yes the IRC, we love a retro communication channel ✨


πŸ› BUGS πŸ›

Please report any bugs or feature requests to "bug-test-valgrind at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Valgrind>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. it's giving "we're in this together" 🫢


🌈 SUPPORT 🌈

You can find documentation for this module with the perldoc command.

perldoc Test::Valgrind::Command

literally the easiest thing you'll do all day πŸ’œ


Copyright 2009,2010,2011,2013,2015,2016 Vincent Pit, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. so go forth and redistribute, bestie, legally πŸ’…


and that's the whole page!! πŸŽ€ this came from the perl v5.40.1 docs, dated 2025-04-13, under the name Test::...Command(3pm). bye babe, go write some subclasses πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from