From f9afc7642ad4f74076ba59bb0bb6e9cfc3bd2991 Mon Sep 17 00:00:00 2001
From: Fabian Keil <fk@fabiankeil.de>
Date: Thu, 9 Oct 2014 15:48:19 +0200
Subject: [PATCH 2/2] runtests.pl: Add an -o option to change internal
 variables

runtests.pl has lots of internal variables one might want to
change in certain situations, but adding a dedicated option
for every single one of them isn't practical.

Usage:
./runtests.pl -o TESTDIR=$privoxy_curl_test_dir -o HOSTIP=10.0.0.1 ...
---
 tests/runtests.pl | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tests/runtests.pl b/tests/runtests.pl
index 5db2724..3daed84 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -4694,6 +4694,15 @@ while(@ARGV) {
         # run the tests cases event based if possible
         $run_event_based=1;
     }
+    elsif($ARGV[0] eq "-o") {
+        shift @ARGV;
+        if ($ARGV[0] =~ /^(\w+)=([\w.:\/\[\]-]+)$/) {
+            my ($variable, $value) = ($1, $2);
+            eval "\$$variable='$value'" or die "Failed to set \$$variable to $value: $@";
+        } else {
+            die "Failed to parse '-o $ARGV[0]'. May contain unexpected characters.\n";
+        }
+    }
     elsif($ARGV[0] eq "-p") {
         $postmortem=1;
     }
@@ -4774,6 +4783,7 @@ Usage: runtests.pl [options] [test selection(s)]
   -l       list all test case names/descriptions
   -m file  load the specifed test manifest to decide which tests get executed
   -n       no valgrind
+  -o variable=value set internal variable to the specified value
   -p       print log file contents when a test fails
   -P proxy use the specified proxy
   -r       run time statistics
-- 
1.9.0


