Mercurial > hg > nginx-tests
diff js_fetch_https.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 | f7a8997c46c7 |
children |
line wrap: on
line diff
--- a/js_fetch_https.t Fri Dec 02 17:46:16 2022 -0800 +++ b/js_fetch_https.t Fri Dec 02 17:46:22 2022 -0800 @@ -190,8 +190,7 @@ ############################################################################### -local $TODO = 'not yet' - unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.7.0'; +local $TODO = 'not yet' unless has_version('0.7.0'); like(http_get('/https?domain=default.example.com&verify=false'), qr/You are at default.example.com.$/s, 'fetch https'); @@ -210,6 +209,25 @@ ############################################################################### +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; +} + +############################################################################### + sub reply_handler { my ($recv_data, $port, %extra) = @_;