comparison js_fetch.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 e1fd234baac0
children f98884ad7700
comparison
equal deleted inserted replaced
1810:7cf848422b28 1811:520fb74cce4c
451 '"very large fetch chunked response"]', 'fetch chunked'); 451 '"very large fetch chunked response"]', 'fetch chunked');
452 like(http_get('/chain'), qr/200 OK.*SUCCESS$/s, 'fetch chain'); 452 like(http_get('/chain'), qr/200 OK.*SUCCESS$/s, 'fetch chain');
453 453
454 TODO: { 454 TODO: {
455 todo_skip 'leaves coredump', 1 unless $ENV{TEST_NGINX_UNSAFE} 455 todo_skip 'leaves coredump', 1 unless $ENV{TEST_NGINX_UNSAFE}
456 or http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.7.4'; 456 or has_version('0.7.4');
457 457
458 like(http_get('/header_iter?loc=duplicate_header_large'), 458 like(http_get('/header_iter?loc=duplicate_header_large'),
459 qr/\['A:a','B:a','C:a','D:a','E:a','F:a','G:a','H:a','Foo:a,b']$/s, 459 qr/\['A:a','B:a','C:a','D:a','E:a','F:a','G:a','H:a','Foo:a,b']$/s,
460 'fetch header duplicate large'); 460 'fetch header duplicate large');
461 461
462 } 462 }
463 463
464 TODO: { 464 TODO: {
465 local $TODO = 'not yet' 465 local $TODO = 'not yet' unless has_version('0.7.7');
466 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.7.7';
467 466
468 like(http_get('/body_special?loc=no_content_length'), 467 like(http_get('/body_special?loc=no_content_length'),
469 qr/200 OK.*CONTENT-BODY$/s, 'fetch body without content-length'); 468 qr/200 OK.*CONTENT-BODY$/s, 'fetch body without content-length');
470 like(http_get('/body_special?loc=no_content_length/parted'), 469 like(http_get('/body_special?loc=no_content_length/parted'),
471 qr/200 OK.*X{32000}$/s, 'fetch body without content-length parted'); 470 qr/200 OK.*X{32000}$/s, 'fetch body without content-length parted');
472 471
473 } 472 }
474 473
475 TODO: { 474 TODO: {
476 local $TODO = 'not yet' 475 local $TODO = 'not yet' unless has_version('0.7.8');
477 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.7.8';
478 476
479 like(http_get('/body_special?loc=head&method=HEAD'), 477 like(http_get('/body_special?loc=head&method=HEAD'),
480 qr/200 OK.*<empty>$/s, 'fetch head method'); 478 qr/200 OK.*<empty>$/s, 'fetch head method');
481 like(http_get('/body_special?loc=length&method=head'), 479 like(http_get('/body_special?loc=length&method=head'),
482 qr/200 OK.*<empty>$/s, 'fetch head method lower case'); 480 qr/200 OK.*<empty>$/s, 'fetch head method lower case');
483 481
482 }
483
484 ###############################################################################
485
486 sub has_version {
487 my $need = shift;
488
489 http_get('/njs') =~ /^([.0-9]+)$/m;
490
491 my @v = split(/\./, $1);
492 my ($n, $v);
493
494 for $n (split(/\./, $need)) {
495 $v = shift @v || 0;
496 return 0 if $n > $v;
497 return 1 if $v > $n;
498 }
499
500 return 1;
484 } 501 }
485 502
486 ############################################################################### 503 ###############################################################################
487 504
488 sub recode { 505 sub recode {