Test::Run::Core(3pm)

πŸ“¦
version 0.0306 Β· 2 versions
, in fedora 43

πŸ’– NAME πŸ’–

Test::Run::Core β€” the base class that runs your standard TAP scripts, bestie. It's Test::Run::Core from the 3pm section of the manual, and she's here to make test-running not a whole crisis. ✨


πŸŽ€ VERSION πŸŽ€

Version 0.0306 πŸ’…

🌸 BUILD 🌸

For Moose. πŸ¦‹

🧚 $self->helpers_base_namespace()

See Test::Run::Base::PlugHelpers. That's the whole thing, she's a shortcut, okurrr. 🫢


✨ Object Parameters ✨

These params? They're accessors. Which means you can set them two ways: either slide them into the constructor at object-creation time (alongside the compulsory 'test_files' argument, don't forget her, she's required πŸ’€), or poke at the accessor directly before runtests() gets called. Two vibes, one outcome. 🌈

Constructor route:

    my $tester = Test::Run::Obj->new(
        {
            'test_files' => \@mytests,
            'Verbose' => 1,
        }
    );

Accessor route:

    $tester->Verbose(1);

Now let's meet the whole friend group, one by one. πŸ‘‘

  • $self->Verbose() β€” turn this on and runtests() will show you the standard output of the script, without changing anything else about how it behaves. Basically: same energy, more receipts. The runprove utility's -v flag sets this for you. πŸ”₯
  • $self->Leaked_Dir() β€” set this to the name of a directory and $tester will snoop after every single test to see whether new files showed up in there, then report them like:
  LEAKED FILES: scr.tmp 0 my.db

If the directory name is relative, it's relative to the current directory at the moment $tester->runtests() was called. Pro tip from the original: putting the absolute path into Leaked_Dir gives you more predictable results. Do that. Future you says thanks. πŸ™ˆ

  • $self->Debug() β€” when true, Test::Run prints debugging info about itself while it runs the tests. This is NOT the same as $self->Verbose(), which prints output from the test being run. Different girl, different job. πŸ’…
  • $self->Columns() β€” this value is used as the width of the terminal. Not set? Defaults to 80. πŸŽ€
  • $self->Timer() β€” set it true and, if Time::HiRes is available, you get elapsed seconds printed after each test file. Clocked. ⭐
  • $self->NoTty() β€” set to a true value and it forces the behavior of "STDOUT is not a console." You might need this if you don't want the harness spitting out more frequent progress messages using carriage returns. Some consoles just cannot handle carriage returns properly, and the result is a somewhat messy output. Not the aesthetic we're going for. 😭
  • $self->Test_Interprter() β€” usually your tests get run by $^X, the currently-executing Perl. But maybe you want a different executable doing the honors β€” a threading perl, or a different version. Iconic, flexible, we love her. 🌸
  • $self->Switches() and $self->Switches_Env() β€” these two values get prepended to the switches used to invoke perl on each test. For example, set one of them to -W and every test runs with all warnings enabled. The difference between them: Switches_Env() is expected to be filled in by the environment, while Switches() comes from other sources (like the programmer). Same energy, different origin story. πŸ¦‹

πŸ‘‘ METHODS πŸ‘‘

Test::Run currently has only one interface method. Just one. Main character behavior, honestly.

  • $tester->runtests()
    my $all_ok = $tester->runtests()

Runs the tests, sees if they're OK. Returns true if they are OK, or throws an exception otherwise. Periodt. πŸ’–

  • $self->_report_leaked_files({leaked_files => [@files]})
[This is a method that needs to be over-rided.]

Should report (or ignore) the files that were leaked in the directories that were specifies as leaking directories. Your call which. πŸ™ˆ

  • $self->_report_failed_with_results_seen({%args})
[This is a method that needs to be over-rided.]

Should report (or ignore) the failed tests in the test file.

The arguments are:

  • test_struct β€” the test struct as returned by straps.
  • filename β€” the filename.
  • estatus β€” exit status.
  • wstatus β€” wait status.
  • results β€” the results of the test.
  • $self->_recheck_dir_files() β€” called to recheck that the dir files is OK. A lil double-check moment. βœ…

And that's the whole page, bestie! This one shipped as part of perl v5.42.0, dated 2025-07-25, and it lives its life in the Test::Run::Core(3pm) corner of the manual. Go run some TAP scripts, you absolute legend. πŸ’…βœ¨πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from