Skip to content

Feature/renderers unit tests - #31

Open
Lppetrov0 wants to merge 9 commits into
mainfrom
feature/renderers-unit-tests
Open

Feature/renderers unit tests#31
Lppetrov0 wants to merge 9 commits into
mainfrom
feature/renderers-unit-tests

Conversation

@Lppetrov0

Copy link
Copy Markdown
Contributor

Description

Adds direct unit tests for both renderers, plus rendering robustness fixes for bugs the tests uncovered.

Tests

  • New renderer/html_renderer/tests/render_test.c (14 tests) and renderer/md_renderer/tests/render_test.c (13 tests). Each test builds a small DxModel fixture in code and asserts directly on the rendered output — no check.sh or golden-file diff step needed, so those were removed from the component Makefiles.
  • Coverage includes: nested directory trees, full vs. minimal symbols, default title fallback, HTML escaping, malformed/self-referencing parent indices, mermaid diagram and cross-reference toggling, sibling ordering, multiple symbols per file, unnamed-field fallbacks, and write-failure behavior.
  • Minimal self-contained harness: CHECK* macros use setjmp/longjmp instead of assert(), so a failed check aborts only the current test with a file:line message. All tests still run, every failure is reported, and the binary exits non-zero at the end.
  • Removed tests/ from both renderers' .gitignore so the test sources are tracked.

Renderer fixes (found while writing the tests)

  • HTML renderer: renders into index.html.tmp and renames it over index.html only on success, so a failed render never leaves a partial page behind or clobbers a previous good one. Write/close errors are now detected and reported to stderr with errno details.
  • Markdown renderer: on any write failure, cleans up everything written so far (partial module files, index.md, and now-empty directories) so the caller gets a clean error instead of a partial render. ferror/fclose results are now checked, with stderr diagnostics for unopenable files and over-long output paths.

Build

  • Top-level make test now keeps going when one component's tests fail, so every component gets tested, then exits non-zero if any failed (previously it stopped at the first failing component).
  • Ignore .vscode/ and remove the tracked c_cpp_properties.json.

Related issues

Closes #

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Documentation
  • Refactor / chore (no functional change)

Checklist

  • My branch is up to date with main
  • I followed the branch naming convention (feature/*, fix/*, docs/*, chore/*)
  • Self-reviewed my own code
  • Added/updated tests where it makes sense
  • Updated documentation where needed
  • No secrets, credentials, or proprietary source are committed

…erer. tests/render_test.c for both features builds small DxModel fixtures and asserts on the rendered output directly. Each test can be done using the Makefile without check.sh.

Also removed tests/ from ignore rules to track new tests.
…at first failure. Replace assert() with a setjmp/longjmp. A failed CHECK aborts only the current test and it moves on to the next one and exits non zero at the end. Now the tests show where the error comes from
… failed test and the test returns a reason why it failed
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.

2 participants