Skip to content

Commit

Permalink
Merge pull request #690 from patrickbkr/fix-spawnprocasync-tests
Browse files Browse the repository at this point in the history
Adapt tests to new `nqp::spawnprocasync` semantics
  • Loading branch information
patrickbkr committed Dec 31, 2020
2 parents d65a8c1 + e53c01c commit 8afa213
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/core/testing.nqp
Expand Up @@ -90,6 +90,10 @@ sub run-command($command, :$stdout, :$stderr) {
my $read-all2 := 0;
my $called-ready := 0;

# Add the program to call to the start of the command.
my @spawn-args := nqp::clone($command);
nqp::unshift(@spawn-args, $command[0]);

my $config := nqp::hash();
$config<done> := -> $status {
++$done;
Expand Down Expand Up @@ -122,7 +126,7 @@ sub run-command($command, :$stdout, :$stderr) {
}

# define the task
my $task := nqp::spawnprocasync($queue, $command, nqp::cwd(),
my $task := nqp::spawnprocasync($queue, @spawn-args, nqp::cwd(),
nqp::getenvhash(), $config);
nqp::permit($task, 1, -1);
nqp::permit($task, 2, -1);
Expand Down
8 changes: 4 additions & 4 deletions t/nqp/111-spawnprocasync.t
Expand Up @@ -57,8 +57,8 @@ my $config := nqp::hash(
# define a task
$string := "expected output from stdout";
$command := "echo $string";
$args := $is-windows ?? nqp::list(nqp::getenvhash()<ComSpec>, '/c', $command)
!! nqp::list('/bin/sh', '-c', $command);
$args := $is-windows ?? nqp::list(nqp::getenvhash()<ComSpec>, nqp::getenvhash()<ComSpec>, '/c', $command)
!! nqp::list('/bin/sh', '/bin/sh', '-c', $command);
my $task := nqp::spawnprocasync($queue, $args, nqp::cwd(), nqp::getenvhash(), $config);
nqp::permit($task, 1, -1);
nqp::permit($task, 2, -1);
Expand Down Expand Up @@ -94,8 +94,8 @@ $called_ready := 0;
# define the task
$string := "expected output from stderr";
$command := "echo $string >&2";
$args := $is-windows ?? nqp::list(nqp::getenvhash()<ComSpec>, '/c', $command)
!! nqp::list('/bin/sh', '-c', $command);
$args := $is-windows ?? nqp::list(nqp::getenvhash()<ComSpec>, nqp::getenvhash()<ComSpec>, '/c', $command)
!! nqp::list('/bin/sh', '/bin/sh', '-c', $command);
$task := nqp::spawnprocasync($queue, $args, nqp::cwd(), nqp::getenvhash(), $config);
nqp::permit($task, 1, -1);
nqp::permit($task, 2, -1);
Expand Down

0 comments on commit 8afa213

Please sign in to comment.