Acme-EyeDrops

 view release on metacpan or  search on metacpan

t/19_surrounds.t  view on Meta::CPAN

#!/usr/bin/perl
# 19_surrounds.t
# Generate a new EyeDrops.pm as described in the doco:
# "EyeDropping EyeDrops.pm" section.
# Run various tests on the EyeDrop'ed EyeDrops.pm.
# Also generate sightly versions of 0..18 tests with a 'z' prefix.
# Since this test is very slow only run if the
# PERL_SMOKE environment variable is set.
#
# zsightly.t test works but the following might be written to stderr:
# Scalar found where operator expected at (eval 2) line 41, near "regex_eval_sightly($hellostr"
# This seems to happen only on Perl versions before 5.6.1. Is this a Perl bug?

use strict;
use File::Basename ();
use File::Copy ();
use File::Path ();
use Acme::EyeDrops qw(sightly);
use Test::Harness ();

$|=1;

# --------------------------------------------------

sub skip_test { print "1..0 # Skipped: $_[0]\n"; exit }

sub build_file {
   my ($f, $d) = @_;
   local *F; open(F, '>'.$f) or die "open '$f': $!";
   print F $d or die "write '$f': $!"; close(F);
}

sub get_first_line {
   my $f = shift; local *T; open(T, $f) or die "open '$f': $!";
   my $s = <T>; close(T); $s;
}

sub rm_f_dir
{
   my $d = shift;
   -d $d or return;
   File::Path::rmtree($d, 0, 0);
   -d $d and die "error: could not delete everything in '$d': $!";
}

# --------------------------------------------------

skip_test('Skipping long running generator tests unless $ENV{PERL_SMOKE} is true')
   unless $ENV{PERL_SMOKE};

print STDERR "Long running generated tests running...\n";
print STDERR "(these are only run if PERL_SMOKE environment variable is true).\n";

print "1..4\n";

# --------------------------------------------------

sub eye_drop_eyedrops_pm {
   # Slurp EyeDrops.pm into $orig string.
   my $orig = Acme::EyeDrops::slurp_yerself();
   # Split $orig into the source ($src) and the pod ($doc).
   my ($src, $doc) = split(/\n1;\n/, $orig, 2);
   # Remove the line containing $eye_dir = __FILE__ ...
   # because this line confuses eval.



( run in 2.459 seconds using v1.01-cache-2.11-cpan-5b529ec07f3 )