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
|
use strict;
use warnings;
use Test::More;
use Git::Wrapper;
my @data = (
# input , #output
[
[ 'status' ] ,
'git status'
] ,
[
[ 'status' , { init => 1 } ] ,
'git status --init'
] ,
[
[ 'status' , { init => 1 , -STDIN => 'foo bar baz' } ] ,
'git status --init' ,
'foo bar baz'
] ,
[ [ 'status' , { init => 1 , -pre => 'bar' } ] ,
'git --pre=bar status --init'
] ,
[
[ 'status' , { init => 1 } , 'file' , { -pre => 'bar' } ] ,
'git --pre=bar status --init file'
] ,
[
[ 'status' , { init => 1 } , 'file' , { -pre => 'bar' , -STDIN => 'foo bar baz' } ] ,
'git --pre=bar status --init file' ,
'foo bar baz'
] ,
[
[ 'status' , { init => 1 } , 'file' , { -pre => 'bar' , post => 1 } ] ,
'git --pre=bar status --init file --post'
] ,
[
[ 'status' , { arg => 'barg' , -pre => 'bar' } , 'file' , { post => 1 } ] ,
'git --pre=bar status --arg=barg file --post'
] ,
[
[ 'status' , { init => 1 , -pre => 'bar' } , qw/ file1 file2 file3 / , { post => 1 } ] ,
'git --pre=bar status --init file1 file2 file3 --post'
] ,
[
[ 'rev-list' , qw/ --all --not master / , { remotes => '*trunk*' } , qw/ -- filename / ] ,
'git rev-list --all --not master --remotes=*trunk* -- filename'
],
[
[ 'submodule' , 'update' , { init => 1 } ] ,
'git submodule update --init'
],
[
[ 'submodule' , { -STDIN => 'foo bar baz' } , 'update' , { init => 1 } ] ,
'git submodule update --init',
'foo bar baz'
],
);
my $test_case = 1;
foreach ( @data ) {
my( $input , $expected_cli , $expected_stdin ) = @$_;
my( $parts , $stdin ) = Git::Wrapper::_parse_args( @$input );
my $output = join ' ' , ( 'git' , @$parts );
is( $output , $expected_cli , "Expected for '$expected_cli' (CASE:$test_case)" );
is( $stdin , $expected_stdin , "Expected STDIN (CASE:$test_case)" );
$test_case++;
}
done_testing();
|