@@ -16,7 +16,9 @@ my sub create_buf($type) {
16
16
17
17
# reusable vars
18
18
my str $ s ; # for testing output
19
- my $ regex ;
19
+ my $ string ;
20
+ my $ command ;
21
+ my $ args ;
20
22
# reusable vars needing reset
21
23
my $ done := 0 ;
22
24
my $ read_all := 0 ;
@@ -52,8 +54,10 @@ my $config := nqp::hash(
52
54
);
53
55
54
56
# 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 );
57
61
my $ task := nqp ::spawnprocasync($ queue , $ args , nqp ::cwd(), nqp ::getenvhash(), $ config );
58
62
nqp ::permit($ task , 1 , -1 );
59
63
@@ -76,7 +80,7 @@ for @stdout_bytes -> $bytes {
76
80
nqp ::decoderaddbytes($ dec , $ bytes );
77
81
}
78
82
$ 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' );
80
84
81
85
# == test for stderr ============
82
86
# reset some reusable vars
@@ -85,8 +89,10 @@ $read_all := 0;
85
89
$ called_ready := 0 ;
86
90
87
91
# 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 );
90
96
$ task := nqp ::spawnprocasync($ queue , $ args , nqp ::cwd(), nqp ::getenvhash(), $ config );
91
97
nqp ::permit($ task , 2 , -1 );
92
98
@@ -114,6 +120,5 @@ if nqp::getcomp('nqp').backend.name eq 'jvm' {
114
120
skip (" no output from spawnprocasync stderr on the jvm" , 1 );
115
121
}
116
122
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' );
119
124
}
0 commit comments