# HG changeset patch # User Maxim Dounin # Date 1353887251 -14400 # Node ID 8f280348d76f1b3e379dadc7f9a7fb0c4a87c17e # Parent a01a53bcbf11cbb841058b3b244a15e294dc56ec Tests: add has_version() method and use it as appropriate. diff --git a/body_chunked.t b/body_chunked.t --- 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'); diff --git a/dav_chunked.t b/dav_chunked.t --- 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; diff --git a/fastcgi_body.t b/fastcgi_body.t --- 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(<{_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) = @_; diff --git a/range_if_range.t b/range_if_range.t --- 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'); diff --git a/scgi_body.t b/scgi_body.t --- 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(<