changeset 242:8f280348d76f

Tests: add has_version() method and use it as appropriate.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 26 Nov 2012 03:47:31 +0400
parents a01a53bcbf11
children de7338227832
files body_chunked.t dav_chunked.t fastcgi_body.t lib/Test/Nginx.pm range_if_range.t scgi_body.t
diffstat 6 files changed, 24 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/body_chunked.t
+++ b/body_chunked.t
@@ -83,7 +83,7 @@ EOF
 ###############################################################################
 
 TODO: {
-local $TODO = 'not yet';
+local $TODO = 'not yet' unless $t->has_version('1.3.9');
 
 like(http_get_body('/', '0123456789'),
 	qr/X-Body: 0123456789\x0d?$/ms, 'body');
--- a/dav_chunked.t
+++ b/dav_chunked.t
@@ -56,7 +56,7 @@ EOF
 ###############################################################################
 
 TODO: {
-local $TODO = 'not yet';
+local $TODO = 'not yet' unless $t->has_version('1.3.9');
 
 my $r;
 
--- a/fastcgi_body.t
+++ b/fastcgi_body.t
@@ -63,7 +63,7 @@ like(http_get_length('/', ''), qr/X-Body
 like(http_get_length('/', 'foobar'), qr/X-Body: foobar/, 'fastcgi body');
 
 TODO: {
-local $TODO = 'not yet';
+local $TODO = 'not yet' unless $t->has_version('1.3.9');
 
 like(http(<<EOF), qr/X-Body: foobar/, 'fastcgi chunked');
 GET / HTTP/1.1
--- a/lib/Test/Nginx.pm
+++ b/lib/Test/Nginx.pm
@@ -117,6 +117,24 @@ sub has_module($) {
 	return ($self->{_configure_args} =~ $re) ? 1 : 0;
 }
 
+sub has_version($) {
+	my ($self, $need) = @_;
+
+	$self->{_configure_args} = `$NGINX -V 2>&1`
+		if !defined $self->{_configure_args};
+
+	$self->{_configure_args} =~ m!nginx version: nginx/([0-9.]+)!;
+
+	my @v = split(/\./, $1);
+	my $n;
+
+	for $n (split(/\./, $need)) {
+		return 0 if $n > (shift @v || 0);
+	}
+
+	return 1;
+}
+
 sub has_daemon($) {
 	my ($self, $daemon) = @_;
 
--- a/range_if_range.t
+++ b/range_if_range.t
@@ -80,7 +80,7 @@ like($t1, qr/206/, 'if-range');
 $t1 = http_get_range('/t2.html', "Range: bytes=0-9\nIf-Range: wrong");
 
 TODO: {
-local $TODO = 'not yet';
+local $TODO = 'not yet' unless $t->has_version('1.3.3');
 
 like($t1, qr/200 OK/, 'if-range notime');
 
@@ -93,7 +93,7 @@ unlike($t1, qr/Last-Modified: /, 'if-ran
 $t1 = http_get_range('/t3.html', "Range: bytes=0-9\nIf-Range: wrong");
 
 TODO: {
-local $TODO = 'not yet';
+local $TODO = 'not yet' unless $t->has_version('1.3.3');
 
 like($t1, qr/200 OK/, 'if-range time wrong');
 
--- a/scgi_body.t
+++ b/scgi_body.t
@@ -63,7 +63,7 @@ like(http_get_length('/', ''), qr/X-Body
 like(http_get_length('/', 'foobar'), qr/X-Body: foobar/, 'scgi body');
 
 TODO: {
-local $TODO = 'not yet';
+local $TODO = 'not yet' unless $t->has_version('1.3.9');
 
 like(http(<<EOF), qr/X-Body: foobar/, 'scgi chunked');
 GET / HTTP/1.1