1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
use 5.008004;
use Test2::V0 -no_srand => 1;
use Alien::Build::CommandSequence;
use Test::Alien::Build;
use File::chdir;
use File::Temp qw( tempdir );
use Path::Tiny qw( path );
use Capture::Tiny qw( capture_merged );
my $build = alienfile q{ use alienfile };
subtest 'cd list' => sub {
local $Alien::Build::VERSION = '1.05';
local $CWD;
my $where;
my $dir = path(tempdir( CLEANUP => 1 ))->child('foo')->canonpath;
my $seq = Alien::Build::CommandSequence->new(
[ "%{make_path} $dir" ],
[ "cd", "$dir" ],
sub { path('foo.txt')->spew('here') },
);
note scalar capture_merged { $seq->execute($build) };
my $foo_txt = path($dir)->child('foo.txt');
is( -f $foo_txt, T(), "created file" );
is( $foo_txt->slurp, "here", "content" );
};
subtest 'cd list' => sub {
local $Alien::Build::VERSION = '1.05';
local $CWD;
my $where;
my $dir = path(tempdir( CLEANUP => 1 ))->child('foo')->canonpath;
my $seq = Alien::Build::CommandSequence->new(
[ "%{make_path} $dir" ],
"cd $dir",
sub { path('foo.txt')->spew('here') },
);
note scalar capture_merged { $seq->execute($build) };
my $foo_txt = path($dir)->child('foo.txt');
is( -f $foo_txt, T(), "created file" );
is( $foo_txt->slurp, "here", "content" );
};
subtest 'cd list with code ref' => sub {
local $Alien::Build::VERSION = '1.05';
local $CWD;
my $where;
my $dir = path(tempdir( CLEANUP => 1 ))->child('foo')->canonpath;
my $seq = Alien::Build::CommandSequence->new(
[ "%{make_path} $dir" ],
[ "cd", "$dir", sub { path('foo.txt')->spew('here') } ],
);
note scalar capture_merged { $seq->execute($build) };
my $foo_txt = path($dir)->child('foo.txt');
is( -f $foo_txt, T(), "created file" );
is( $foo_txt->slurp, "here", "content" );
};
done_testing;
|