Created
May 1, 2014 11:14
-
-
Save hideo55/1e837e3d4ec4d2fc7930 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test::More; | |
use Config; | |
use File::Spec::Functions qw(catdir catfile rel2abs); | |
use File::Path; | |
use File::Temp qw(tempdir); | |
use File::Copy::Recursive 'dircopy'; | |
use Cwd::Guard qw(cwd_guard); | |
use Capture::Tiny qw(capture); | |
my $perl = $Config{perlpath}; | |
my @perl = ($perl, map { "-I" . $_ } @INC); | |
my $eg_dir = rel2abs(catdir(qw/eg Foo/)); | |
my $tmp_dir = tempdir( CLEANUP => 1 ); | |
dircopy($eg_dir, $tmp_dir); | |
like run_cmd($tmp_dir, @perl, catfile($tmp_dir, 'Build.PL')), qr/Creating new 'Build' script for 'Foo' version '0.01'/; | |
run_cmd($tmp_dir, @perl, catfile($tmp_dir, 'Build')); | |
like run_cmd($tmp_dir, @perl, catfile($tmp_dir, 'Build test')), qr/Result\:\s*PASS/; | |
done_testing; | |
sub run_cmd { | |
my ($work_dir, @cmd) = @_; | |
my $cmd = join ' ', @cmd; | |
my $guard = cwd_guard($work_dir); | |
my ($stdout, $stderr, $result) = capture{ | |
system($cmd); | |
}; | |
return $stdout; | |
} | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment