Skip to content

Replace tut with doctest#5563

Open
daatsuka wants to merge 2 commits intosecondlife:developfrom
daatsuka:fix/issue-4445
Open

Replace tut with doctest#5563
daatsuka wants to merge 2 commits intosecondlife:developfrom
daatsuka:fix/issue-4445

Conversation

@daatsuka
Copy link

Summary

Replaces the legacy tut testing framework with doctest — a lightweight, single-header C++ testing framework.

Wallet: 2s37zauxhzbVM5SeLhLiryoGGaqcuv248ekRKU49rbWw

Changes

CMake infrastructure

  • indra/cmake/Doctest.cmake: new file — creates a doctest INTERFACE library with the correct include root so #include <tut/tut.hpp> and #include "doctest/doctest.h" both resolve from any test target
  • indra/cmake/LLAddBuildTest.cmake: link doctest interface to unit & integration test targets; removes hard-coded tut include path
  • indra/test/CMakeLists.txt: add CMAKE_CURRENT_SOURCE_DIR to lltest include dirs; link doctest interface target

Test framework files

  • indra/test/doctest/doctest.h: vendored doctest single-header (v2.4.11)
  • indra/test/tut/tut.hpp: compatibility shim — #include <tut/tut.hpp> now silently redirects to lltut.h so all existing _tut.cpp files compile without modification
  • indra/test/lltut.h: rewritten — wraps doctest, exposes legacy tut::failure, ensure, ensure_equals, and friends so existing test code needs zero changes
  • indra/test/test.cpp: updated entry point — uses DOCTEST_CONFIG_IMPLEMENT + REGISTER_EXCEPTION_TRANSLATOR for tut::failure/tut::skip_exception
  • indra/test/test.h: retains tut::sSourceDir declaration for compatibility

How it works

  • Old tests using tut::test_group / tut::factory continue to work through the shim
  • New tests can use TEST_CASE / SUBCASE / CHECK / REQUIRE directly
  • tut::failure is registered as a doctest exception translator so throw-based assertions map to proper doctest failures

Closes #4445

- Doctest.cmake: create INTERFACE library with correct include root
  so both '#include <tut/tut.hpp>' and '#include "doctest/doctest.h"'
  resolve correctly from any test target
- test/CMakeLists.txt: add CMAKE_CURRENT_SOURCE_DIR to lltest includes
  and link the doctest interface target
- LLAddBuildTest.cmake: link doctest to unit and integration test targets

Without these changes the compiler cannot find doctest/doctest.h or
tut/tut.hpp, causing undefined-symbol errors at compile time.

Fixes secondlife#4445
@github-actions
Copy link

github-actions bot commented Mar 22, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@daatsuka
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

- lltut.h: rewritten to wrap doctest instead of tut
- test.cpp: updated entry point using DOCTEST_CONFIG_IMPLEMENT
- test.h: retain tut::sSourceDir declaration for compat
- doctest/doctest.h: vendored single-header doctest library
- tut/tut.hpp: compatibility shim that includes lltut.h
@daatsuka daatsuka force-pushed the fix/issue-4445 branch 2 times, most recently from 1ca516e to 5612f12 Compare March 22, 2026 19:03
@daatsuka
Copy link
Author

recheck

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace tut with doctest

1 participant