Mercurial > hg > nginx-tests
diff js.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 | 7cf848422b28 |
children |
line wrap: on
line diff
--- a/js.t +++ b/js.t @@ -301,8 +301,7 @@ like(http_get('/global'), qr/global=njs/ like(http_get('/log'), qr/200 OK/, 'r.log'); TODO: { -local $TODO = 'not yet' - unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.7.7'; +local $TODO = 'not yet' unless has_version('0.7.7'); like(http_get('/internal'), qr/parent: false sub: true/, 'r.internal'); @@ -324,6 +323,25 @@ ok(index($t->read_file('error.log'), 'at ############################################################################### +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 http_get_hdr { my ($url, %extra) = @_; return http(<<EOF, %extra);