Skip to content

Commit

Permalink
Fix external dependency (#641)
Browse files Browse the repository at this point in the history
By putting it in here. Closes #640.
  • Loading branch information
JJ committed May 10, 2020
1 parent c2666ff commit 51f90e3
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions S26-documentation/block-leading-user-format.t
@@ -1,7 +1,5 @@
use v6;
use Test;
use lib <t/packages>;
use Test::Helpers;

plan 2;

Expand Down Expand Up @@ -74,3 +72,37 @@ for %h.keys -> $s {


}

sub is-run (
Str() $code, $desc = "$code runs",
Stringy :$in, :@compiler-args, :@args, :$out = '', :$err = '', :$exitcode = 0
) is export {
my @proc-args = flat do if $*DISTRO.is-win {
# $*EXECUTABLE is a batch file on Windows, that goes through cmd.exe
# and chokes on standard quoting. We also need to remove any newlines
<cmd.exe /S /C>, $*EXECUTABLE, @compiler-args, '-e',
($code, @args).subst(:g, "\n", " ")
}
else {
$*EXECUTABLE, @compiler-args, '-e', $code, @args
}

with run :in, :out, :err, @proc-args {
$in ~~ Blob ?? .in.write: $in !! .in.print: $in if $in;
$ = .in.close;
my $proc-out = .out.slurp: :close;
my $proc-err = .err.slurp: :close;
my $proc-exitcode = .exitcode;

my $wanted-exitcode = $exitcode // 0;
my $wanted-out = $out // '';
my $wanted-err = $err // '';

subtest $desc => {
plan 3;
cmp-ok $proc-out, '~~', $wanted-out, 'STDOUT';
cmp-ok $proc-err, '~~', $wanted-err, 'STDERR';
cmp-ok $proc-exitcode, '~~', $wanted-exitcode, 'Exit code';
}
}
}

0 comments on commit 51f90e3

Please sign in to comment.