[omd-commits] OMD Git: omd: tests: fixed reading files with comments

git version control git at mathias-kettner.de
Tue Feb 28 21:50:34 CET 2012


Module:   omd
Branch:   master
Commit:   f85e2f8214090b8eadbae0160cba898cb26aac05
URL:      http://omdistro.org/projects/omd/repository/revisions/f85e2f8214090b8eadbae0160cba898cb26aac05

Author:   Sven Nierlein <sven at nierlein.de>
Date:     Tue Feb 28 13:18:46 2012 +0100
Commiter: Sven Nierlein <sven at nierlein.de>
Date:     Tue Feb 28 17:22:10 2012 +0100

tests: fixed reading files with comments

---

 t/TestUtils.pm |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/t/TestUtils.pm b/t/TestUtils.pm
index e57a044..cc33768 100644
--- a/t/TestUtils.pm
+++ b/t/TestUtils.pm
@@ -414,15 +414,18 @@ sub read_config {
     open(my $fh, '<', $conf_file) or carp("cannot open $conf_file: $!");
     while(<$fh>) {
         my $line = $_;
+        chomp($line);
+        next if $line =~ m/^\s*#/;
+        $line =~ s/\s*#.*$//;
         my $append = 0;
-        my($key,$value) = split/\s+\+=\s+/,$line,2;
+        my($key,$value) = split/\s+\+=\s*/,$line,2;
         if(defined $value) {
             $append = 1;
         } else {
-            ($key,$value) = split/\s+=\s+/,$line,2;
+            ($key,$value) = split/\s+=\s*/,$line,2;
         }
         $key   =~ s/^\s+//;
-        $value =~ s/\s+$//;
+        $value =~ s/\s+$// if defined $value;
         if($append) {
             $config->{$key} .= " ".$value;
         } else {



More information about the omd-commits mailing list