comparison 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
comparison
equal deleted inserted replaced
1810:7cf848422b28 1811:520fb74cce4c
93 $t->run_daemon(\&stream_daemon, port(8090)); 93 $t->run_daemon(\&stream_daemon, port(8090));
94 $t->waitforsocket('127.0.0.1:' . port(8090)); 94 $t->waitforsocket('127.0.0.1:' . port(8090));
95 95
96 ############################################################################### 96 ###############################################################################
97 97
98 local $TODO = 'not yet' 98 local $TODO = 'not yet' unless has_version('0.7.9');
99 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.7.9';
100 99
101 is(stream('127.0.0.1:' . port(8081))->io('ABC'), 'ABC', 'access fetch ok'); 100 is(stream('127.0.0.1:' . port(8081))->io('ABC'), 'ABC', 'access fetch ok');
101
102 ###############################################################################
103
104 sub has_version {
105 my $need = shift;
106
107 http_get('/njs') =~ /^([.0-9]+)$/m;
108
109 my @v = split(/\./, $1);
110 my ($n, $v);
111
112 for $n (split(/\./, $need)) {
113 $v = shift @v || 0;
114 return 0 if $n > $v;
115 return 1 if $v > $n;
116 }
117
118 return 1;
119 }
102 120
103 ############################################################################### 121 ###############################################################################
104 122
105 sub stream_daemon { 123 sub stream_daemon {
106 my $server = IO::Socket::INET->new( 124 my $server = IO::Socket::INET->new(