]> git.ipfire.org Git - thirdparty/nftables.git/commit
tests/shell: have .json-nft dumps prettified to wrap lines
authorThomas Haller <thaller@redhat.com>
Thu, 7 Dec 2023 09:08:50 +0000 (10:08 +0100)
committerPhil Sutter <phil@nwl.cc>
Thu, 8 Feb 2024 17:25:45 +0000 (18:25 +0100)
commitd8f2124ffe1965629d0d47ad22a27e36de279c43
treee3d1dfccfd3928dd29eeec5262e889b53eef4689
parent46eeb2339d2923daaf736fb0bb41383fc03e4ec0
tests/shell: have .json-nft dumps prettified to wrap lines

Previously, the .json-nft file in git contains the output of `nft -j
list ruleset`. This is one long line and makes diffs harder to review.

Instead, have the prettified .json-nft file committed to git.

- the diff now operates on the prettified version. That means, it
  compares essentially

     - `nft -j list ruleset | json-sanitize-ruleset.sh | json-pretty.sh`
     - `cat "$TEST.json-nft" | json-pretty.sh`

  The script "json-diff-pretty.sh" is no longer used. It is kept
  however, because it might be a useful for manual comparing files.

  Note that "json-sanitize-ruleset.sh" and "json-pretty.sh" are still
  two separate scripts and called at different times. They also do
  something different. The former mangles the JSON to account for changes
  that are not stable (in the JSON data itself), while the latter only
  pretty prints it.

- when generating a new .json-nft dump file, the file will be updated to
  use the new, prettified format, unless the file is in the old format
  and needs no update. This means, with DUMPGEN=y, old style is preserved
  unless an update becomes necessary.

This requires "json-pretty.sh" having stable output, as those files are
committed to git. This is probably fine.

Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
tests/shell/helpers/json-pretty.sh
tests/shell/helpers/test-wrapper.sh