File: test-env-var.patch

package info (click to toggle)
libapache-session-memcached-perl 0.03-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 136 kB
  • ctags: 19
  • sloc: perl: 82; makefile: 17; sh: 9
file content (25 lines) | stat: -rw-r--r-- 827 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Description: Allow override of test config by environment variables
 The get_config sub in t/testlib.pl has been modified so that an environment
 variable named MEMCACHED_param will override the parameter param in the config
 file t/CONFIG. This is useful, for example, when the port number is determined
 on the fly during automated testing. 
Author: Christopher Hoskin <christopher.hoskin@gmail.com>
Forwarded: https://rt.cpan.org/Public/Bug/Display.html?id=102008
Last-Update: 2015-02-08

--- a/t/testlib.pl
+++ b/t/testlib.pl
@@ -12,8 +12,11 @@
 
 sub get_config {
  	my ($config, $param) = @_;
-	if ($config =~ /^$param\s*?=\s*(.*?)$/m) {
-   	return $1;
+	if (exists $ENV{"MEMCACHED_$param"}) {
+		return $ENV{"MEMCACHED_$param"};
+	} 
+	elsif ($config =~ /^$param\s*?=\s*(.*?)$/m) {
+   		return $1;
 	}
 	return '';
 }