Skip to content

build: use one generate and check pattern for all examples - #1323

Open
gennaroprota wants to merge 3 commits into
cppalliance:developfrom
gennaroprota:build/use_one_generate_and_check_pattern_for_all_examples
Open

gennaroprota wants to merge 3 commits into
cppalliance:developfrom
gennaroprota:build/use_one_generate_and_check_pattern_for_all_examples

Conversation

@gennaroprota

Copy link
Copy Markdown
Collaborator

Each example directory registered its tests its own way, and most tests only checked that the run succeeded. So an output the docs include could drift unnoticed, as it happened with the jsonl example.

This PR adds mrdocs_add_example, and uses that for every example that runs MrDocs. It runs the example from its own directory and compares the files the example commits with the run's output. It also adds a target that updates those files. An example that commits no output only checks that the run succeeds.

Changes

  • Source: A Lua table converted to a DOM object now inserts its keys in sorted order. Before, the order changed from run to run, and so did the search-index example's output.
  • Tests: Every such example is registered through mrdocs_add_example. The report.py scripts leave the comparison to it, and the run.sh scripts are all removed.
  • Build: Tests are named mrdocs-example-<name> and update targets mrdocs-update-example-<name>, plus mrdocs-update-examples for all of them.
  • Golden tests: The jsonl example's output is regenerated to show the current anchors.

Testing

CI runs the example tests with ctest.

Documentation

The examples README explains how the examples are tested and updated. The Data-Driven Generators page now shows the jsonl output MrDocs actually produces.

Closes #1295.

This fixes a bug for which a Lua script that serialized a table, such as
the search-index generator example writing its entries with
`ctx.stringify`, produced the keys in an order that changed from run to
run, so its output could not be compared with a committed copy.

A Lua table has no order of its own, and `lua_next` walks it in one that
depends on a hash seed Lua picks anew for each state. Both conversions
from a Lua table to a DOM object, the one for a value passed to a DOM
function or assigned to a DOM member and the one for a Handlebars
helper's result, now insert its string keys in sorted order.
@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Warnings

Warning

Source changed but no tests or fixtures were updated.

🧾 Changes by Scope

Scope Lines Δ% Lines Δ Lines + Lines - Files Δ Files + Files ~ Files ↔ Files -
📚 Examples 93% 524 308 216 31 2 11 - 18
🛠️ Source 7% 37 29 8 2 - 2 - -
Total 100% 561 337 224 33 2 13 - 18

Legend: Files + (added), Files ~ (modified), Files ↔ (renamed), Files - (removed)

🔝 Top Files

  • examples/cmake/MrDocsExample.cmake (Examples): 115 lines Δ (+115 / -0)
  • examples/cmake/run-example.cmake (Examples): 83 lines Δ (+83 / -0)
  • examples/extensions/CMakeLists.txt (Examples): 56 lines Δ (+15 / -41)

Generated by 🚫 dangerJS against 1c92ebc

@codecov

codecov Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.12%. Comparing base (adc6242) to head (1c92ebc).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1323   +/-   ##
========================================
  Coverage    83.12%   83.12%           
========================================
  Files           35       35           
  Lines         3662     3662           
  Branches       844      844           
========================================
  Hits          3044     3044           
  Misses         410      410           
  Partials       208      208           
Flag Coverage Δ
bootstrap 83.12% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The committed output of the data-driven jsonl example predates the
reflection-driven Handlebars DOM (d3fc5d5), since which the `anchor`
of a member is the member's own, as in `length` rather than
`Point-length`. The Data-Driven Generators page includes the file, so it
showed output MrDocs no longer produces.
Each example directory registered its tests its own way: mrdocs called
from `add_test`, a run.sh driven through Bash, a Python checker with a
test and a regeneration target of its own. Most tests only checked that
the run succeeded, so an output the docs include could drift without any
of them noticing, as it happened with the jsonl example.

Add `mrdocs_add_example`, which runs an example from its own directory
and compares the output the example commits with the run, with a target
to update it, or, for an example that commits nothing, only checks that
the run succeeds. Every example that runs the tool goes through it, and
the run.sh scripts are all gone.

Fixes cppalliance#1295.
@gennaroprota
gennaroprota force-pushed the build/use_one_generate_and_check_pattern_for_all_examples branch from 10607b0 to 1c92ebc Compare September 25, 2026 10:01
@cppalliance-bot

cppalliance-bot commented Sep 25, 2026 •

Copy link
Copy Markdown

An automated preview of the documentation is available at https://1323.mrdocs.prtest2.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-09-25 10:10:13 UTC

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build: one pattern for example generate and check targets

2 participants