Mercurial > hg > nginx-tests
diff js_headers.t @ 1811:520fb74cce4c
Tests: improved njs version check to account multi digit versions.
author | Dmitry Volyntsev <xeioex@nginx.com> |
---|---|
date | Fri, 02 Dec 2022 17:46:22 -0800 |
parents | 386748f328b1 |
children |
line wrap: on
line diff
--- a/js_headers.t Fri Dec 02 17:46:16 2022 -0800 +++ b/js_headers.t Fri Dec 02 17:46:22 2022 -0800 @@ -531,8 +531,7 @@ ), qr/a,b,c/, 'r.headersOut sorted keys'); TODO: { -local $TODO = 'not yet' - unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.7.6'; +local $TODO = 'not yet' unless has_version('0.7.6'); like(http_get('/hdr_out_special_set'), qr/CE: abc/, 'r.headerOut special set'); @@ -548,3 +547,22 @@ } ############################################################################### + +sub has_version { + my $need = shift; + + http_get('/njs') =~ /^([.0-9]+)$/m; + + my @v = split(/\./, $1); + my ($n, $v); + + for $n (split(/\./, $need)) { + $v = shift @v || 0; + return 0 if $n > $v; + return 1 if $v > $n; + } + + return 1; +} + +###############################################################################