Skip to content

basic test for spaces and args #147

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions eg/dir space/ipctest.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
echo %1
2 changes: 2 additions & 0 deletions eg/dir space/ipctest2 space.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
echo %1
2 changes: 2 additions & 0 deletions eg/dirnospace/ipctest.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
echo %1
2 changes: 2 additions & 0 deletions eg/dirnospace/ipctest2 space.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
echo %1
2 changes: 2 additions & 0 deletions eg/ipctest.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
echo %1
2 changes: 2 additions & 0 deletions eg/ipctest2 space.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
echo %1
63 changes: 63 additions & 0 deletions t/win32_args_n_spaces.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/perl

use strict;
use warnings;
use Test::More;
use IPC::Run 'run';
use File::Spec;
use Cwd 'getcwd';

plan skip_all => 'Skipping on Win32' if $ENV{GITHUB_WINDOWS_TESTING};
plan skip_all => 'Skipping when not on Win32' unless $^O eq 'MSWin32';
run_tests();
done_testing;

sub run_tests {
chdir "eg"; # so we don't have to have files in project root
## The 2 on the space bat prevents accidentally running the normal one.
my @summary;
my %seen;
test_set(
\@summary,
reverse sort map +( $seen{$_}++ ? () : ($_) ),
map {
my $slash = $_;
my $abs_slash = my $abs = File::Spec->rel2abs($_);
$slash =~ s@/@\\@g;
$abs_slash =~ s@\\@/@g;
( $_, /\// ? ($slash) : (), $abs, $abs_slash )
} (
"ipctest.bat",
"ipctest2 space.bat",
"./ipctest.bat",
"./ipctest2 space.bat",
"dirnospace/ipctest.bat",
"dirnospace/ipctest2 space.bat",
"dir space/ipctest.bat",
"dir space/ipctest2 space.bat"
)
);
note join "\n", "\nSUMMARY:", @summary, " ";
return;
}

sub test_set {
my ( $summary, @tests ) = @_;
push @{$summary}, "\n\ntests:\n", @tests, " ", "successes:\n";
check( $summary, $_ ) for @tests;
return;
}

sub check {
my ( $summary, $executable ) = @_;
note "\ntest '$executable'";
my $t;
my $r = eval {
run [ $executable, "meep marp" ], ">", \my $out;
$t = is $out, qq[\"meep marp\"\n], "output was correct";
1;
};
push @{$summary}, $executable if $t;
fail "died with '$@'" if !$r;
return;
}