Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created July 7, 2016 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/672e8bb4de280e012765a3875786ca02 to your computer and use it in GitHub Desktop.
Save zoffixznet/672e8bb4de280e012765a3875786ca02 to your computer and use it in GitHub Desktop.
diff --git a/S19-command-line/repl.t b/S19-command-line/repl.t
index 14a2507..5a95236 100644
--- a/S19-command-line/repl.t
+++ b/S19-command-line/repl.t
@@ -1,5 +1,9 @@
use v6;
+use lib <t/spec/packages>;
+
use Test;
+use Test::Util;
+
plan 4;
# Sanity check that the repl is working at all.
@@ -10,14 +14,11 @@ is shell($cmd).exitcode, 42, 'exit(42) in executed REPL got run';
{
# RT #119339
- subtest { plan 2;
- my $proc = run $*EXECUTABLE, :in, :out, :err;
- $proc.in.print: "say 069\nexit\n";
- like $proc.out.slurp-rest, /'69'/, 'stdout contains the number';
- like $proc.err.slurp-rest, /'Potential difficulties:'
+ is_run_repl "say 069\nexit\n", {
+ out => /'69'/,
+ err => /'Potential difficulties:'
.* "Leading 0 is not allowed. For octals, use '0o' prefix,"
- .* 'but note that 69 is not a valid octal number'
- /, 'stderr contains correct warning';
+ .* 'but note that 69 is not a valid octal number'/
}, 'prefix 0 on invalid octal warns in REPL';
subtest { plan 2;
diff --git a/packages/Test/Util.pm b/packages/Test/Util.pm
index 493161c..432aa2a 100644
--- a/packages/Test/Util.pm
+++ b/packages/Test/Util.pm
@@ -127,6 +127,16 @@ sub get_out( Str $code, Str $input?, :@args, :@compiler-args) is export {
return %out;
}
+sub is_run_repl ($code, %wanted, $desc) is export {
+ my $proc = run $*EXECUTABLE, :in, :out, :err;
+ $proc.in.print: $code;
+ subtest {
+ plan +(%wanted<out err>:v);
+ like $proc.out.slurp-rest, $_, 'stdout is correct' with %wanted<out>;
+ like $proc.err.slurp-rest, $_, 'stderr is correct' with %wanted<err>;
+ }, $desc;
+}
+
=begin pod
=head1 NAME
@zoffixznet
Copy link
Author

$ prove -e './perl6-m -I../roast/packages/' -vlr  ../roast/S19-command-line/repl.t
../roast/S19-command-line/repl.t .. ===SORRY!=== Error while compiling /home/zoffix/CPANPRC/rakudo/../roast/S19-command-line/repl.t
Undeclared routine:
    is_run_repl used at line 17

Dubious, test returned 1 (wstat 256, 0x100)
No subtests run 

Test Summary Report
-------------------
../roast/S19-command-line/repl.t (Wstat: 256 Tests: 0 Failed: 0)
  Non-zero exit status: 1
  Parse errors: No plan found in TAP output
Files=1, Tests=0,  2 wallclock secs ( 0.02 usr  0.01 sys +  1.26 cusr  0.07 csys =  1.36 CPU)
Result: FAIL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment