-
Notifications
You must be signed in to change notification settings - Fork 20
Quote Win32 arguments. #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c08bdcb
Quote Win32 arguments.
theory c08f008
Get shell quoting working on Windows.
theory d36bf03
Sync whitespace pattern.
theory 18a3fe2
Make sure single string arg still works.
theory 18e3617
Use the OSPrereqs plugin to require Win32::ShellQuote.
theory 037f569
Fix single-string capture.
theory 6a1956f
Fix Win32 exit exit val tests
theory d0d5f95
Fix last win32 failure.
theory 9b69c63
Use cmd.exe for single-arg run().
theory a99b2f3
Document Windows behavior changes.
theory 5b7394a
Restore and expand tests with command with spaces.
theory 6672f19
Note inability to test large muli-arg exit vals.
theory File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| #!/usr/bin/perl -w | ||
|
|
||
| use strict; | ||
|
|
||
| use Test::More tests => 56; | ||
| use IPC::System::Simple qw(run runx system systemx capture capturex); | ||
| use Config; | ||
| use File::Basename qw(fileparse); | ||
|
|
||
| my $perl = $Config{perlpath}; | ||
| $perl .= $Config{_exe} if $^O ne 'VMS' && $perl !~ m/$Config{_exe}$/i; | ||
| my $tmp = 'test.tmp'; | ||
|
|
||
| my $script = qq{ | ||
| open my \$fh, '>', '$tmp' or die "Cannot write to $tmp: \$!\\n"; | ||
| print {\$fh} "\$_\\n" for \@ARGV; | ||
| }; | ||
|
|
||
| chdir 't'; | ||
|
|
||
| END { | ||
| unlink $tmp; | ||
| } | ||
|
|
||
| my $slurp = sub { | ||
| open my $fh, '<', $tmp or die "Cannot read $tmp: $!\n"; | ||
| return join '', <$fh>; | ||
| }; | ||
|
|
||
| for my $spec ( | ||
| ['single arg', 'foo'], | ||
| ['multiple args', 'x', 'y', 'z'], | ||
| ['arg with spaces', 'foo', 'bar baz'], | ||
| ) { | ||
| my ($desc, @args) = @{ $spec }; | ||
| my $exp = join "\n", @args, ''; | ||
|
|
||
| # Test run. | ||
| my $exit = eval { run $perl, '-e', $script, @args }; | ||
| is $@, "", "Should have no error from runx with $desc"; | ||
| is $exit, 0, "Should have exit 0 from runx with $desc"; | ||
| is $slurp->(), $exp, "Should have passed $desc from run"; | ||
|
|
||
| # Test system. | ||
| $exit = eval { system $perl, '-e', $script, @args }; | ||
| is $@, "", "Should have no error from systemx with $desc"; | ||
| is $exit, 0, "Should have exit 0 from systemx with $desc"; | ||
| is $slurp->(), $exp, "Should have passed $desc from system"; | ||
|
|
||
| # Test runx. | ||
| $exit = eval { runx $perl, '-e', $script, @args }; | ||
| is $@, "", "Should have no error from runx with $desc"; | ||
| is $exit, 0, "Should have exit 0 from runx with $desc"; | ||
| is $slurp->(), $exp, "Should have passed $desc from runx"; | ||
|
|
||
| # Test systemx. | ||
| $exit = eval { systemx $perl, '-e', $script, @args }; | ||
| is $@, "", "Should have no error from systemx with $desc"; | ||
| is $exit, 0, "Should have exit 0 from systemx with $desc"; | ||
| is $slurp->(), $exp, "Should have passed $desc from systemx"; | ||
|
|
||
| # Test capture. | ||
| my $output = eval { capture $perl, '-e', 'print "$_\n" for @ARGV', @args }; | ||
| is $@, "", "Should have no error from capture with $desc"; | ||
| is $output, $exp, "Should have passed $desc from capture"; | ||
|
|
||
| # Test capturex. | ||
| $output = eval { capturex $perl, '-e', 'print "$_\n" for @ARGV', @args }; | ||
| is $@, "", "Should have no error from capturex with $desc"; | ||
| is $output, $exp, "Should have passed $desc from capturex"; | ||
| } | ||
|
|
||
| # Make sure redirection works, too. | ||
| my $exit = eval { run "$perl output.pl > $tmp" }; | ||
| is $@, "", "Should have no error from run with redirection"; | ||
| is $exit, 0, "Should have exit 0 from run with redirection"; | ||
| is $slurp->(), "Hello\nGoodbye\n", "Should have redirected text run"; | ||
|
|
||
| $exit = eval { system "$perl output.pl > $tmp" }; | ||
| is $@, "", "Should have no error from systemx with redirection"; | ||
| is $exit, 0, "Should have exit 0 from systemx with redirection"; | ||
| is $slurp->(), "Hello\nGoodbye\n", "Should have redirected text systemx"; | ||
|
|
||
| # And single-string capture. | ||
| my $output = eval { capture "$perl output.pl" }; | ||
| is $@, "", "Should have no error from single-string capture"; | ||
| is $output, "Hello\nGoodbye\n", "Should have output from capture"; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.