diff stream_js_fetch_init.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 01fcc82a435a
children f98884ad7700
line wrap: on
line diff
--- a/stream_js_fetch_init.t
+++ b/stream_js_fetch_init.t
@@ -95,13 +95,31 @@ EOF
 
 ###############################################################################
 
-local $TODO = 'not yet'
-	unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.7.9';
+local $TODO = 'not yet' unless has_version('0.7.9');
 
 is(stream('127.0.0.1:' . port(8081))->io('ABC'), 'ABC', 'access fetch ok');
 
 ###############################################################################
 
+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 stream_daemon {
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',