You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-commits@perl.apache.org by co...@apache.org on 2017/01/05 21:51:05 UTC

svn commit: r1777513 - /perl/Apache-Test/trunk/lib/Apache/Test.pm

Author: covener
Date: Thu Jan  5 21:51:05 2017
New Revision: 1777513

URL: http://svn.apache.org/viewvc?rev=1777513&view=rev
Log:
add need_min_apache_fix()

similar to need_min_apache_version() but takes a list
of versions and only compares to the relevant major.minor.

This helps avoid the pitfall of need_min_apache_version("2.2.31")
succeeding against an actual version of e.g. "2.4.0".  Lots of times
a fix or behavior change goes in for a few contemporary releases.



Modified:
    perl/Apache-Test/trunk/lib/Apache/Test.pm

Modified: perl/Apache-Test/trunk/lib/Apache/Test.pm
URL: http://svn.apache.org/viewvc/perl/Apache-Test/trunk/lib/Apache/Test.pm?rev=1777513&r1=1777512&r2=1777513&view=diff
==============================================================================
--- perl/Apache-Test/trunk/lib/Apache/Test.pm (original)
+++ perl/Apache-Test/trunk/lib/Apache/Test.pm Thu Jan  5 21:51:05 2017
@@ -40,7 +40,7 @@ use vars qw(@ISA @EXPORT %EXPORT_TAGS $V
 $VERSION = '1.41';
 
 my @need = qw(need_lwp need_http11 need_cgi need_access need_auth
-              need_module need_apache need_min_apache_version
+              need_module need_apache need_min_apache_version need_min_apache_fix
               need_apache_version need_perl need_min_perl_version
               need_min_module_version need_threads need_fork need_apache_mpm
               need_php need_php4 need_ssl need_imagemap need_cache_disk);
@@ -499,6 +499,38 @@ sub need_min_apache_version {
     }
 }
 
+sub need_min_apache_fix {
+    my @wantlevels = @_;
+    my $cfg = Apache::Test::config();
+    (my $current) = $cfg->{server}->{version} =~ m:^Apache/(\d)\.(\d+)\.(\d+):;
+    my $current_major = $1;
+    my $current_minor = $2;
+    my $current_micro = $3;
+
+    foreach(@wantlevels) { 
+        if ($_ =~ m/(\d)\.(\d+)\.(\d+)/) { 
+             print "matched";
+        }
+        my $wanted_major = $1;
+        my $wanted_minor = $2;
+        my $wanted_micro = $3;
+        if ($wanted_major eq $current_major && $wanted_minor eq $current_minor) { 
+            if (normalize_vstring($wanted_micro) < normalize_vstring($current_micro)) {
+                push @SkipReasons,
+                     "apache version $_ or higher is required," .
+                         " this is version $current";
+                return 0;
+            }
+            else { 
+                return 1;
+            }
+        }
+    }
+
+    # We didn't match major+minor, run the test and let the author sort it out
+    return 1;
+}
+
 sub need_apache_version {
     my $wanted = shift;
     my $cfg = Apache::Test::config();
@@ -882,6 +914,16 @@ For example:
 
 requires Apache 2.0.40.
 
+=item need_min_apache_fix
+
+Used to require a particular micro version from corresponding minor release
+
+For example:
+
+  plan tests => 5, need_min_apache_fix("2.0.40", "2.2.30", "2.4.18");
+
+requires Apache 2.0.40 or higher.
+
 =item need_apache_mpm
 
 Used to require a specific Apache Multi-Processing Module.