diff options
| author | Remi Collet <remi@remirepo.net> | 2026-01-15 07:02:09 +0100 |
|---|---|---|
| committer | Remi Collet <remi@php.net> | 2026-01-15 07:02:09 +0100 |
| commit | efe90cb8918a11b1b0f304b666aa29080cded9ae (patch) | |
| tree | 420d0f5bc91b95d573d893fa4b579a280cd2fcd1 /tests.patch | |
| parent | 9eed8aa7b3748c5f806e3d350ce0e5af6cf7fb32 (diff) | |
Diffstat (limited to 'tests.patch')
| -rw-r--r-- | tests.patch | 68 |
1 files changed, 58 insertions, 10 deletions
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", |
