Skip to content

Tests: ngx_http_json_module tests. - #101

Merged
roman-f5 merged 1 commit into
nginx:masterfrom
roman-f5:dev/json-parser
Sep 10, 2026
Merged

roman-f5 merged 1 commit into
nginx:masterfrom
roman-f5:dev/json-parser

Conversation

@roman-f5

@roman-f5 roman-f5 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Proposed changes

Added json_parser.t covering json_set value extraction (scalars, nested
objects and arrays, compound containers, literals, number types, escapes,
the '$' root selector, source caching, last-match-wins on duplicate keys,
quoted key segments, and binary-safe / Unicode / surrogate-pair keys), and
json_parser_invalid.t covering rejection of malformed json_set paths at
configuration load.

Checklist

Before creating a PR, run through this checklist and mark each as complete:

@roman-f5
roman-f5 requested a review from pluknet August 12, 2026 20:13
@roman-f5
roman-f5 force-pushed the dev/json-parser branch 3 times, most recently from 347aa85 to 02a6707 Compare August 12, 2026 22:54
@sindhushiv sindhushiv moved this from New to In Review in NGINX OSS Unified Workspace Aug 13, 2026
@roman-f5
roman-f5 force-pushed the dev/json-parser branch 5 times, most recently from 6284bcb to f6ba9ea Compare August 18, 2026 18:39
Comment thread json_parser.t Outdated
Comment thread json_set.t
Comment thread json_set.t
Comment thread json_set.t
Comment thread json_parser.t Outdated
Comment thread json_parser.t Outdated
Comment thread json_parser.t Outdated
Comment thread json_set.t
Comment thread json_parser.t Outdated
Comment thread json_set.t
Comment thread json_set.t
Comment thread json_parser.t Outdated
Comment thread json_set.t
Comment thread json_parser.t Outdated
@dekobon

dekobon commented Aug 20, 2026

Copy link
Copy Markdown

The PR description no longer matches the diff: it says there is a separate json_parser_invalid.t file, but this PR only adds json_parser.t, and it lists $ root selector extraction even though the test correctly asserts that $ is rejected.

Could the description be updated to match the current coverage?

@route443 route443 removed their assignment Aug 28, 2026
@route443
route443 self-requested a review August 28, 2026 02:37
@roman-f5
roman-f5 force-pushed the dev/json-parser branch 2 times, most recently from e533a26 to 5077b2b Compare August 28, 2026 20:33

@pluknet pluknet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename json_parset.t to json_set.t - to follow the naming convention of using the (main) directive name as exported by the tested module

I didn't look deeply into the essence of the tests, especially into the syntax-related.
If you believe they are truly needed and they pass on all tested platforms, I'm ok to keep them.

Comment thread json_parser.t Outdated
Comment thread json_set.t
Comment thread json_parser.t Outdated
Comment thread json_parser.t Outdated
Comment thread json_parser.t Outdated
@route443 route443 self-assigned this Sep 4, 2026
@route443

route443 commented Sep 4, 2026

Copy link
Copy Markdown
Member

It's time to take care of these tests a bit! Roman -> Ivan

Co-authored-by: Ivan Ovchinnikov <i.ovchinnikov@f5.com>

@route443 route443 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of pluknet's comments are addressed.
Plus the coverage gaps and two defects in the config-check helper:

  • tests added to cover whitespace characters (ngx_json_ws() branch)
  • certain num vals ​​and exponent sign processing
  • top-level scalars
  • expanded malformed docs tests
  • escape decoding
  • empty string val
  • some config time tests

Plus some issues with config checks:

  • run_check_conf() writes the config using standard open/print calls, bypassing write_file_expand() => listen 127.0.0.1:8080 directive within it is not replaced with the allocated port => prove -j = fail
  • server {} block is unnecessary and removed

Now we have 102 tests. Coverage:

file strings branches
ngx_http_json_module.c 92.33% (391) 82.05% (234)
ngx_json_parse.c 89.46% (408) 79.72% (355)
ngx_json_unescape.c 96.77% (124) 85.94% (64)

Delta relative to the previous coverage: +1.8 / +11.8 / +15.3 by line, +1.7 / +17.8 / +17.2 by branch.

I made a few adjustments to the sandbox CI so that the json module builds by default and there are no checks in has(). All tests are passing successfully.

@roman-f5
roman-f5 merged commit c45d610 into nginx:master Sep 10, 2026
@github-project-automation github-project-automation Bot moved this from In Review to Done in NGINX OSS Unified Workspace Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants