From 73c881bddf97d81d875e24081b51836e2585abc3 Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Mon, 4 Feb 2019 16:12:54 -0800 Subject: [PATCH] tests: added support for `--- out_like` blocks. --- t/Config.pm | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/t/Config.pm b/t/Config.pm index b1d744c..307de26 100644 --- a/t/Config.pm +++ b/t/Config.pm @@ -58,11 +58,19 @@ sub run_test ($) { $expected_err =~ s/\$OPENRESTY_DIR\b/$DistRoot/gs; } - my $expected_out = $block->out; - if (!defined $expected_out) { - $expected_out = ''; + my ($expected_out, $expected_out_regex); + + if (defined $block->out_like) { + $expected_out_regex = $block->out_like; + if (!ref $expected_out_regex) { + $expected_out_regex = qr~$expected_out_regex~s; + } + + } elsif (defined $block->out) { + $expected_out = $block->out; + } else { - #$expected_out =~ s/\$OPENRESTY_BUILD_DIR\b/$BuildRoot/gs; + $expected_out = ''; } #die $BuildRoot; @@ -70,7 +78,13 @@ sub run_test ($) { $stdout =~ s/\Q$BuildRoot\E/\$OPENRESTY_BUILD_DIR/g; $stdout =~ s/\Q$DistRoot\E/\$OPENRESTY_DIR/g; - is($stdout, $expected_out, "$name - stdout ok"); + if (ref $expected_out_regex) { + like $stdout, $expected_out_regex, "$name - stdout like ok"; + + } else { + is $stdout, $expected_out, "$name - stdout ok"; + } + is($stderr, $expected_err, "$name - stderr ok"); is($retval >> 8, $expected_exit, "$name - exit code ok");