TAP::P...::Perl(3perl)

🌸 NAME 🌸

TAP::Parser::SourceHandler::Perl β€” stream TAP straight outta a Perl executable, bestie πŸ’–

(and yeah, this lives in the TAP::P...::Perl(3perl) manpage, ilysm Perl Programmers Reference Guide)


✨ VERSION ✨

Version 3.52 β€” she's current, she's cute πŸŽ€


🫢 SYNOPSIS 🫢

  use TAP::Parser::Source;
  use TAP::Parser::SourceHandler::Perl;

  my $source = TAP::Parser::Source->new->raw( \'script.pl' );
  $source->assemble_meta;

  my $class = 'TAP::Parser::SourceHandler::Perl';
  my $vote  = $class->can_handle( $source );
  my $iter  = $class->make_iterator( $source );

πŸ’… DESCRIPTION πŸ’…

So this is a Perl TAP::Parser::SourceHandler, and she has literally 2 jobs, no more no less:

  1. Figure out if the TAP::Parser::Source she's handed is actually a Perl script (can_handle). πŸ‘€
  2. Create an iterator for Perl sources (make_iterator). πŸ—οΈ
Heads up bestie: unless you're out here writing a plugin or subclassing TAP::Parser, you lowkey will not need to touch this module directly. She's backstage crew, not main character energy. πŸ™ˆ

πŸ‘‘ METHODS πŸ‘‘

🌟 Class Methods 🌟

πŸ”₯ can_handle πŸ”₯

  my $vote = $class->can_handle( $source );

She only votes if $source looks like a file, periodt. And then she casts these votes, fr fr:

  • 0.9 β€” if it has a shebang ala #!...perl
  • 0.3 β€” if it has any shebang
  • 0.8 β€” if it's a .t file
  • 0.9 β€” if it's a .pl file
  • 0.75 β€” if it's in a 't' directory
  • 0.25 β€” by default (backwards compat, the nostalgia vote πŸ₯²)

πŸ¦‹ make_iterator πŸ¦‹

  my $iterator = $class->make_iterator( $source );

Constructs & returns a brand new TAP::Parser::Iterator::Process for the source. She's assuming $source->raw holds a reference to the perl script. And if the file couldn't be found? She croaks. 😭 no file, no vibes.

The command she runs gets built like this:

  $perl @switches $perl_script @test_args

Which perl command gets used is decided by get_perl. And the command she generates is guaranteed to preserve these, no cap:

  PERL5LIB
  PERL5OPT
  Taint Mode, if set in the script's shebang
⚠️ Note, and this part matters: the command generated will not respect any shebang line defined in your Perl script. This is only a problem if you've compiled a custom version of Perl, or if you wanna use one specific Perl version for one test and a different one for another, like:
  #!/path/to/a/custom_perl --some --args
  #!/usr/local/perl-5.6/bin/perl -w

Currently you need to write a plugin to get around this. That's just how it is rn. 🧚

πŸ“ get_taint πŸ“

Decodes any taint switches from a Perl shebang line. Detective work, but make it cute πŸ”

  # $taint will be 't'
  my $taint = TAP::Parser::SourceHandler::Perl->get_taint( '#!/usr/bin/perl -t' );

  # $untaint will be undefined
  my $untaint = TAP::Parser::SourceHandler::Perl->get_taint( '#!/usr/bin/perl' );

⭐ get_perl ⭐

Gets the version of Perl currently running the test suite. That's it, that's the whole function πŸ’


🌈 SUBCLASSING 🌈

Please see "SUBCLASSING" in TAP::Parser for a subclassing overview. Go read that first, bestie, don't skip it 🫢

πŸŽ€ Example πŸŽ€

  package MyPerlSourceHandler;

  use strict;

  use TAP::Parser::SourceHandler::Perl;

  use base 'TAP::Parser::SourceHandler::Perl';

  # use the version of perl from the shebang line in the test file
  sub get_perl {
      my $self = shift;
      if (my $shebang = $self->shebang( $self->{file} )) {
          $shebang =~ /^#!(.*\bperl.*?)(?:(?:\s)|(?:$))/;
          return $1 if $1;
      }
      return $self->SUPER::get_perl(@_);
  }

πŸ’œ SEE ALSO πŸ’œ

  • TAP::Object
  • TAP::Parser
  • TAP::Parser::IteratorFactory
  • TAP::Parser::SourceHandler
  • TAP::Parser::SourceHandler::Executable
  • TAP::Parser::SourceHandler::File
  • TAP::Parser::SourceHandler::Handle
  • TAP::Parser::SourceHandler::RawTAP

okay that's the whole page, you ate it, go slay some tests πŸ’–βœ¨ this was perl v5.44.0, dated 2026-10-17, and it's the TAP::P...::Perl(3perl) page β€” bye bestie, love u, drink water πŸ§šπŸŒΈπŸ‘‘

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms