use v6;
use Test;
plan 1+322;
skip_rest "This file was in t_disabled/. Remove this SKIP if it now works.";
exit;
if $?OS ne 'MSWin32' {
skip_rest "These are Win32-specific tests";
exit;
}
my $cwdb = $*CWD;
my $cwd = $cwdb;
$cwd ~~ s:P5:g!\\!/!;
$cwdb ~~ s:P5:g,/,\\,;
my $testdir = "t/builtins/system/t e s t";
my $exename = "showav";
my $plxname = "showargv.pl";
my $exe = "$testdir/$exename";
my $exex = $exe ~ ".exe";
my $exeb = $exe;
$exeb ~~ s:P5:g,/,\\,;
my $exebx = $exeb ~ ".exe";
my $plx = "$testdir/$plxname";
my $plxb = $plx;
$plxb ~~ s:P5:g,/,\\,;
my $bat = "$testdir/$plxname";
my $batb = $bat;
$batb ~~ s:P5:g,/,\\,;
my $cmdx = $bat ~ ".cmd";
my $cmdb = $batb;
my $cmdbx = $cmdb ~ ".cmd";
my $pugs = 'pugs.exe';
my @command = (
$exe,
$exex,
$exeb,
$exebx,
"./$exe",
"./$exex",
".\\$exeb",
".\\$exebx",
"$cwd/$exe",
"$cwd/$exex",
"$cwdb\\$exeb",
"$cwdb\\$exebx",
[$pugs,$plx],
[$pugs,$plxb],
);
my @av = (
Mu,
"",
" ",
"abc",
"a b\tc",
"\tabc",
"abc\t",
" abc\t",
"\ta b c ",
["\ta b c ", ""],
["\ta b c ", " "],
["", "\ta b c ", "abc"],
[" ", "\ta b c ", "abc"],
['" "', 'a" "b" "c', "abc"],
'Hello "World"!',
'c:\\',
'c:\\test name',
'c:\\test directory\\',
'\\\\localhost\\',
'Hello ^_^',
'Hello ^^',
'^^',
'""',
);
diag "Creating test files";
my $counter;
my @cleanup;
for @command -> $cmd {
my @cmd = $cmd;
for @av -> $arg {
my @args = $arg;
my $prog = "perl6-temprun-test-" ~ ($counter++) ~ ".tmp";
my $fh = open($prog, :w);
$fh.say("run(");
for @cmd, @args -> $l {
my $line = $l.perl();
$line ~~ s:P5/^\\//;
$fh.say($line ~ ",")
};
$fh.say(")");
$fh.close();
undefine $fh;
push @cleanup, $prog;
};
};
ok(1,"Created test files");
$counter = 0;
for @command -> $cmd {
my @cmd = $cmd;
for @av -> $arg {
my @args = $arg;
my $outfile = "perl6-tempout-" ~ ($counter) ~ ".tmp";
push @cleanup, $outfile;
my $prog = "perl6-temprun-test-" ~ ($counter++) ~ ".tmp";
my $cmd = @cmd[*-1];
my $expected = "[" ~ $cmd ~ "][" ~ @args.join("][") ~ "]";
my $name = "|" ~ @cmd.join("*") ~ "| with [" ~ @args.join("][") ~ "]";
if not run($pugs ~ " " ~ $prog ~ "> " ~ $outfile) {
fail($name);
diag slurp $prog;
next;
};
my $output = slurp $outfile;
$output .= chomp;
is($output,$expected,$name)
or diag slurp $prog;
};
};
diag "Cleaning up";
for @cleanup { unlink($_) };