Navigation Menu

Skip to content

Commit

Permalink
update tests for nqp::spawn and nqp::shell
Browse files Browse the repository at this point in the history
  • Loading branch information
FROGGS committed Jun 26, 2015
1 parent 67c3c31 commit 9d4c5d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion t/nqp/19-file-ops.t
Expand Up @@ -170,7 +170,9 @@ nqp::unlink($test-file ~ '-linked');
my $tmp-file := "tmp";
my $env := nqp::getenvhash();
$env<NQP_SHELL_TEST_ENV_VAR> := "123foo";
nqp::shell("echo %NQP_SHELL_TEST_ENV_VAR% > $tmp-file",nqp::cwd(),$env);
nqp::shell("echo %NQP_SHELL_TEST_ENV_VAR% > $tmp-file",nqp::cwd(),$env, nqp::null(), nqp::null(), nqp::null(),
nqp::const::PIPE_INHERIT_IN + nqp::const::PIPE_INHERIT_OUT + nqp::const::PIPE_INHERIT_ERR
);
my $output := slurp($tmp-file);
nqp::unlink($tmp-file);
my $is-windows := $output ne "%NQP_SHELL_TEST_ENV_VAR%\n";
Expand Down
9 changes: 6 additions & 3 deletions t/nqp/78-shell.t
Expand Up @@ -10,17 +10,20 @@ ok($a<foo> == 123,'nqp::getenvhash() is a fresh hash');
ok($b<foo> == 456,'nqp::getenvhash() is a fresh hash');

my $tmp-file := "tmp";
nqp::shell("echo Hello > $tmp-file",nqp::cwd(),nqp::getenvhash());
nqp::shell("echo Hello > $tmp-file",nqp::cwd(),nqp::getenvhash(), nqp::null(), nqp::null(), nqp::null(),
nqp::const::PIPE_INHERIT_IN + nqp::const::PIPE_INHERIT_OUT + nqp::const::PIPE_INHERIT_ERR);
my $output := slurp($tmp-file);
ok($output ~~ /^Hello/,'nqp::shell works with the echo shell command');

my $env := nqp::getenvhash();
$env<NQP_SHELL_TEST_ENV_VAR> := "123foo";

nqp::shell("echo %NQP_SHELL_TEST_ENV_VAR% > $tmp-file",nqp::cwd(),$env);
nqp::shell("echo %NQP_SHELL_TEST_ENV_VAR% > $tmp-file",nqp::cwd(),$env, nqp::null(), nqp::null(), nqp::null(),
nqp::const::PIPE_INHERIT_IN + nqp::const::PIPE_INHERIT_OUT + nqp::const::PIPE_INHERIT_ERR);
$output := slurp($tmp-file);
if $output eq "%NQP_SHELL_TEST_ENV_VAR%\n" {
nqp::shell("echo \$NQP_SHELL_TEST_ENV_VAR > $tmp-file",nqp::cwd(),$env);
nqp::shell("echo \$NQP_SHELL_TEST_ENV_VAR > $tmp-file",nqp::cwd(),$env, nqp::null(), nqp::null(), nqp::null(),
nqp::const::PIPE_INHERIT_IN + nqp::const::PIPE_INHERIT_OUT + nqp::const::PIPE_INHERIT_ERR);
my $output := slurp($tmp-file);
ok($output eq "123foo\n","passing env variables to child processes works linux");
} else {
Expand Down

0 comments on commit 9d4c5d8

Please sign in to comment.