Skip to content

Commit 3c5b51b

Browse files
committed
rewrite dash-p.t to use Test::Util
hangs on MoarVM due to RT #121720
1 parent 3a83c5f commit 3c5b51b

File tree

1 file changed

+22
-39
lines changed

1 file changed

+22
-39
lines changed

S19-command-line-options/03-dash-p.t

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ use v6;
22

33
use Test;
44

5+
use lib 't/spec/packages';
6+
use Test::Util;
7+
8+
plan 2;
9+
510
=begin pod
611
712
Test C<-p> implementation
@@ -18,44 +23,22 @@ switch, and wraps the whole script in
1823

1924
# L<S19/Reference/"Act like sed.">
2025

21-
my @examples = (
22-
'-p',
23-
'-p "-e1;"',
24-
'-pe ";"',
25-
'-pe ""',
26-
'-p "-e1;" "-e1;"',
27-
'"-e1;" -p "-e1;"',
26+
is_run(
27+
'1', # program
28+
"foo\n", # input
29+
{
30+
out => "foo\n", # expected
31+
},
32+
'-p -e 1 works like cat',
33+
:compiler-args['-p'],
2834
);
2935

30-
plan +@examples;
31-
32-
diag "Running under $*OS";
33-
34-
my ($redir_in,$redir_out) = ("<", ">");
35-
36-
my $str = "
37-
foo
38-
bar
39-
";
40-
41-
sub nonce () { return (".{$*PID}." ~ (1..1000).pick) }
42-
my ($in_fn, $out_fn) = <temp-ex-input temp-ext-output> >>~>> nonce;
43-
my $h = open("$in_fn", :w);
44-
$h.print($str);
45-
$h.close();
46-
47-
for @examples -> $ex {
48-
my $command = "$*EXECUTABLE_NAME $ex $redir_in $in_fn $redir_out $out_fn";
49-
diag $command;
50-
run $command;
51-
52-
my $expected = $str;
53-
my $got = slurp $out_fn;
54-
unlink $out_fn;
55-
56-
is $got, $expected, "$ex works like cat";
57-
}
58-
59-
unlink $in_fn;
60-
61-
# vim: ft=perl6
36+
is_run(
37+
's:g/o/a/', # program
38+
"foo\nbar\n", # input
39+
{
40+
out => "faa\nbar\n",
41+
},
42+
'-p works in combination with s:g///',
43+
:compiler-args['-p'],
44+
);

0 commit comments

Comments
 (0)