diff options
| -rw-r--r-- | njs.spec | 9 | ||||
| -rw-r--r-- | tests.patch | 68 |
2 files changed, 63 insertions, 14 deletions
@@ -33,7 +33,7 @@ Name: %{project} Summary: NGINX JavaScript Version: 0.9.5 -Release: 1%{?dist} +Release: 2%{?dist} License: BSD-2-Clause AND MIT URL: https://github.com/%{gh_owner}/%{project} @@ -91,9 +91,7 @@ mv %{qjs_project}-%{qjs_commit} quickjs %setup -qn %{project}-%{gh_commit} %endif -if pkg-config libpcre2-8 --atleast-version 10.47; then -%patch -P0 -p0 -fi +%patch -P0 -p1 %build @@ -168,6 +166,9 @@ make test %{?_smp_mflags} %changelog +* Thu Jan 15 2026 Remi Collet <remi@remirepo.net> - 0.9.5-2 +- use upstream patch for test suite + * Tue Jan 13 2026 Remi Collet <remi@remirepo.net> - 0.9.5-1 - update to 0.9.5 - update bundled quickjs to 2025.12.22 diff --git a/tests.patch b/tests.patch index 6f679d5..131b8ae 100644 --- a/tests.patch +++ b/tests.patch @@ -1,15 +1,63 @@ -diff -up src/test/njs_unit_test.c.old src/test/njs_unit_test.c ---- src/test/njs_unit_test.c.old 2026-01-13 07:39:11.539231644 +0100 -+++ src/test/njs_unit_test.c 2026-01-13 07:39:28.102421977 +0100 -@@ -11804,11 +11804,6 @@ static njs_unit_test_t njs_test[] = - njs_pcre_var("pcre_compile2(\"(\") failed: missing closing parenthesis at \"\" in 1", - "pcre_compile(\"(\") failed: missing ) in 1")) }, - -- { njs_str("/+/.test('')"), -- njs_str("SyntaxError: " +From ca8d7740d6545234909131a6de8404109a850d85 Mon Sep 17 00:00:00 2001 +From: Dmitry Volyntsev <xeioex@nginx.com> +Date: Wed, 14 Jan 2026 14:43:58 -0800 +Subject: [PATCH] Making unit tests less brittle when libpcre2 changes. + +This fixes #1011 issue on Github. +--- + src/njs_str.h | 6 ++++++ + src/test/njs_unit_test.c | 10 ++++------ + 2 files changed, 10 insertions(+), 6 deletions(-) + +diff --git a/src/njs_str.h b/src/njs_str.h +index 8c7e60b06..e64d88a97 100644 +--- a/src/njs_str.h ++++ b/src/njs_str.h +@@ -139,6 +139,12 @@ njs_strstr_case_eq(s1, s2) \ + && (njs_strncasecmp((s1)->start, (s2)->start, (s1)->length) == 0)) + + ++#define \ ++njs_strstr_starts_with(str, prefix) \ ++ (((str)->length >= (prefix)->length) \ ++ && (memcmp((str)->start, (prefix)->start, (prefix)->length) == 0)) ++ ++ + NJS_EXPORT njs_int_t njs_strncasecmp(u_char *s1, u_char *s2, size_t n); + + +diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c +index c39523ac0..a89d80161 100644 +--- a/src/test/njs_unit_test.c ++++ b/src/test/njs_unit_test.c +@@ -11806,8 +11806,8 @@ static njs_unit_test_t njs_test[] = + + { njs_str("/+/.test('')"), + njs_str("SyntaxError: " - njs_pcre_var("pcre_compile2(\"+\") failed: quantifier does not follow a repeatable item at \"+\" in 1", - "pcre_compile(\"+\") failed: nothing to repeat at \"+\" in 1")) }, -- ++ njs_pcre_var("pcre_compile2(\"+\") failed: quantifier does not follow a repeatable item", ++ "pcre_compile(\"+\") failed: nothing to repeat")) }, + { njs_str("/^$/.test('')"), njs_str("true") }, +@@ -21994,9 +21994,7 @@ njs_process_test(njs_external_state_t *state, njs_opts_t *opts, + return NJS_ERROR; + } + +- success = expected->ret.length <= s.length +- && (memcmp(expected->ret.start, s.start, expected->ret.length) +- == 0); ++ success = njs_strstr_starts_with(&s, &expected->ret); + if (!success) { + njs_stderror("njs(\"%V\")\nexpected: \"%V\"\n got: \"%V\"\n", + &expected->script, &expected->ret, &s); +@@ -22156,7 +22154,7 @@ njs_unit_test(njs_unit_test_t tests[], size_t num, njs_str_t *name, + "Extra characters at the end of the script"); + } +- success = njs_strstr_eq(&tests[i].ret, &s); ++ success = njs_strstr_starts_with(&s, &tests[i].ret); + if (!success) { + njs_stderror("njs(\"%V\")\nexpected: \"%V\"\n" + " got: \"%V\"\n", |
