BEGIN {
unshift @INC, 't/lib/';
}
chdir 't';
use File::Spec;
use Test::More tests => 22;
use Config;
use TieOut;
use MakeMaker::Test::Utils;
use MakeMaker::Test::Setup::BFD;
use ExtUtils::MakeMaker;
chdir 't';
perl_lib();
ok( setup_recurs(), 'setup' );
END {
ok( chdir File::Spec->updir );
ok( teardown_recurs(), 'teardown' );
}
ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
diag("chdir failed: $!");
{
local $/ = "foo";
local $\ = "bar";
MY->fixin("bin/program");
is $/, "foo", '$/ not clobbered';
is $\, "bar", '$\ not clobbered';
}
sub test_fixin {
my($code, $test) = @_;
my $file = "fixin_test";
ok(open(my $fh, ">", $file), "write $file") or diag "Can't write $file: $!";
print $fh $code;
close $fh;
MY->fixin($file);
ok(open($fh, "<", $file), "read $file") or diag "Can't read $file: $!";
my @lines = <$fh>;
close $fh;
$test->(@lines);
1 while unlink $file;
ok !-e $file, "cleaned up $file";
}
test_fixin(<<END,
blah blah blah
END
sub {
my @lines = @_;
unlike $lines[0], qr[/foo/bar/perl], "#! replaced";
like $lines[0], qr[ -w\b], "switch retained";
is $lines[-1], "blah blah blah\n", "Program text retained";
}
);
test_fixin(<<END,
blah blah blah
END
sub {
my @lines = @_;
unlike $lines[0], qr[/foo/bar/perl5.8.8], "#! replaced";
like $lines[0], qr[ -w\b], "switch retained";
is $lines[-1], "blah blah blah\n", "Program text retained";
}
);
test_fixin(<<END,
blah blah blah
END
sub {
is join("", @_), <<END;
blah blah blah
END
}
);