Skip to content

Commit 6dd8011

Browse files
committed
made test for stderr more robust\n+defining the output allows testing on a multilingual system
1 parent 483d840 commit 6dd8011

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

t/nqp/111-spawnprocasync.t

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ my sub create_buf($type) {
1616

1717
# reusable vars
1818
my str $s; # for testing output
19-
my $regex;
19+
my $string;
20+
my $command;
21+
my $args;
2022
# reusable vars needing reset
2123
my $done := 0;
2224
my $read_all := 0;
@@ -52,8 +54,10 @@ my $config := nqp::hash(
5254
);
5355

5456
# define a task
55-
my $args := $is-windows ?? nqp::list(nqp::getenvhash()<ComSpec>, '/c', 'echo aardvarks')
56-
!! nqp::list('/bin/sh', '-c', 'echo aardvarks');
57+
$string := "expected output";
58+
$command := "echo $string";
59+
$args := $is-windows ?? nqp::list(nqp::getenvhash()<ComSpec>, '/c', $command)
60+
!! nqp::list('/bin/sh', '-c', $command);
5761
my $task := nqp::spawnprocasync($queue, $args, nqp::cwd(), nqp::getenvhash(), $config);
5862
nqp::permit($task, 1, -1);
5963

@@ -76,7 +80,7 @@ for @stdout_bytes -> $bytes {
7680
nqp::decoderaddbytes($dec, $bytes);
7781
}
7882
$s := nqp::decodertakeallchars($dec);
79-
ok($s ~~ /^aardvarks\s*$/, 'got the correct output on stdout');
83+
ok($s ~~ / $string /, 'got the correct output on stdout');
8084

8185
#== test for stderr ============
8286
# reset some reusable vars
@@ -85,8 +89,10 @@ $read_all := 0;
8589
$called_ready := 0;
8690

8791
# define the task
88-
$args := $is-windows ?? nqp::list(nqp::getenvhash()<ComSpec>, '/c', 'foo')
89-
!! nqp::list('/bin/sh', '-c', 'foo');
92+
$string := "expected output";
93+
$command := "echo $string >&2";
94+
$args := $is-windows ?? nqp::list(nqp::getenvhash()<ComSpec>, '/c', $command)
95+
!! nqp::list('/bin/sh', '-c', $command);
9096
$task := nqp::spawnprocasync($queue, $args, nqp::cwd(), nqp::getenvhash(), $config);
9197
nqp::permit($task, 2, -1);
9298

@@ -114,6 +120,5 @@ if nqp::getcomp('nqp').backend.name eq 'jvm' {
114120
skip("no output from spawnprocasync stderr on the jvm", 1);
115121
}
116122
else {
117-
ok($s ~~ / '/bin/sh:' \s+ \d+ ':' \s+ foo \s* ':' \s* not \s* found/,
118-
'got the correct output on stderr');
123+
ok($s ~~ / $string /, 'got the correct output on stderr');
119124
}

0 commit comments

Comments
 (0)