summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-04-01 15:05:52 +0200
committerRichard Levitte <levitte@openssl.org>2016-04-02 23:13:42 +0200
commitcb2ceb18f242bbc573c0e332f34b9ca42fc5f561 (patch)
treeef413d5761460f16b46860d3f5c164182bd0463c /test
parentd3e6d6bcdfb725a57f94330367e7b752036c7a2c (diff)
Enhance OpenSSL::Test::cmdstr to give cmd string variants
Within OpenSSL::Test, all commands end up existing in two variants, one that has redirections that are needed internally to work well together with the test harness, and one without those redirections. Depending on what the result is going to be used for, the caller may want one for or the other, so we give them the possibility. Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'test')
-rw-r--r--test/testlib/OpenSSL/Test.pm27
1 files changed, 25 insertions, 2 deletions
diff --git a/test/testlib/OpenSSL/Test.pm b/test/testlib/OpenSSL/Test.pm
index b0a609fd4d..ca2e369a20 100644
--- a/test/testlib/OpenSSL/Test.pm
+++ b/test/testlib/OpenSSL/Test.pm
@@ -548,19 +548,42 @@ sub with {
=over 4
-=item B<cmdstr CODEREF>
+=item B<cmdstr CODEREF, OPTS>
C<cmdstr> takes a CODEREF from C<app> or C<test> and simply returns the
command as a string.
+C<cmdstr> takes some additiona options OPTS that affect the string returned:
+
+=over 4
+
+=item B<display =E<gt> 0|1>
+
+When set to 0, the returned string will be with all decorations, such as a
+possible redirect of stderr to the null device. This is suitable if the
+string is to be used directly in a recipe.
+
+When set to 1, the returned string will be without extra decorations. This
+is suitable for display if that is desired (doesn't confuse people with all
+internal stuff), or if it's used to pass a command down to a subprocess.
+
+Default: 0
+
+=back
+
=back
=cut
sub cmdstr {
my ($cmd, $display_cmd) = shift->(0);
+ my %opts = @_;
- return $cmd;
+ if ($opts{display}) {
+ return $display_cmd;
+ } else {
+ return $cmd;
+ }
}
=over 4