Skip to content

Testing and Benchmarks

Handbook → Development

Every module ships tests, every public header has a test file, and every test is headless and deterministic. This chapter documents the machinery that makes that cheap: the test support library under tests/support/include/conjure/testing/, the shared main, CMake registration, test naming and content, labels, preconditions and skipping, the header and style checks, how to write and run one test, the editor's and widget kit's tests and goldens, and the benchmarks.

Overview

  • doctest 2.4.11, included only through conjure/testing/doctest.h (DOCTEST_CONFIG_SUPER_FAST_ASSERTS, DOCTEST_CONFIG_USE_STD_HEADERS). tools/check_style.py rejects a direct <doctest/doctest.h> include.
  • One CTest entry per TEST_CASE, named <module>.<case>, run as its own process from build/<preset>/bin with --conjure-isolated. A crash takes down exactly one entry.
  • One static support library conjure_test_support (conjure::test_support, namespace conjure::testing, depends on conjure::core only). tests/support/src/test_main.cpp and tracked_global_new.cpp are compiled into every test executable, not into the library, so every heap allocation of a test process is counted and the shared main owns seed, thread count, log sink and assert handler.
  • Tests run against a real job system (default clamp(hardware_concurrency(), 2, 8) workers, 0 = inline) and the null backends of platform, rhi and audio; nothing may need a GPU, window, audio device or network. The few cases that exercise real hardware guard themselves with a precondition (section 6).

Registering tests with CMake

conjure_add_test_module(<module>
    SOURCES <files...>              # test_<header>.cpp files and helper headers next to them
    [DEPS <targets...>]             # extra link targets (test groups without a library of their own)
    [LABELS <labels...>]            # appended to "unit;<module>"
    [TIMEOUT <seconds>]             # default 120
    [LINK_ENGINE_SHARED]            # link the umbrella conjure::shared instead of the static libraries (below)
    [ENGINE]                        # also link conjure::test_support_engine (the engine fixtures, section 4)
)
conjure_header_check(conjure_<module>)

conjure_add_test_module() (cmake/ConjureTesting.cmake) builds conjure_<module>_tests from the sources plus the two shared translation units, links conjure::<module> when that target exists, conjure::test_support, conjure::platform_defines, conjure::warnings and conjure::sanitizers, adds engine/src as a private include directory (tests may reach private module headers), and defines per executable CONJURE_TEST_EXECUTABLE_NAME, CONJURE_TEST_REPO_ASSET_ROOT (tests/assets), CONJURE_TEST_DOWNLOADED_ASSET_ROOT (tests/.downloaded), CONJURE_TEST_OUTPUT_ROOT (build/<preset>/test_output/<target>) and CONJURE_TEST_TEMP_ROOT (build/<preset>/test_tmp/<target>). Discovery is doctest_discover_tests() with TEST_PREFIX "<module>.", EXTRA_ARGS --conjure-isolated, WORKING_DIRECTORY bin, properties TIMEOUT and SKIP_RETURN_CODE 77; the label list is applied by a generated <target>_labels.cmake because doctest's script flattens nested lists.

ENGINE links conjure::test_support_engine (or conjure::test_support_engine_shared together with LINK_ENGINE_SHARED), the engine-level fixtures of section 4; tests/integration/CMakeLists.txt and the engine, bindings and editor suites use it. The option is a no-op with a notice when conjure::engine is not built.

conjure_add_test_executable(<name> SOURCES ... [DEPS ...] [FOLDER ...]) is the executable half without CTest registration, used for helper programs such as conjure_support_child. tests/CMakeLists.txt adds every tests/<module>/ that has a CMakeLists.txt; tests/core/CMakeLists.txt adds an area directory only when TARGET conjure::core_<area> exists (conjure_add_test_module(core_<area> ...) in tests/core/<area>/CMakeLists.txt). Every module test directory guards itself the same way, so disabling a subsystem disables its tests. Every module directory is in the tree; tests/integration/ adds cross-module scenarios (conjure_integration_tests, plus conjure_integration_plugin_tests with LINK_ENGINE_SHARED for the sample plugin scenario), tests/runtime/ the process tests of the runtime, tests/third_party/ the probes of the third-party pins (section 10), and tests/benchmarks/ the benchmark harness (section 11).

LINK_ENGINE_SHARED (used by tests/modules/) links the umbrella conjure::shared and conjure::test_support_shared (the support library compiled against it) instead of the static libraries, so the executable and the fixture plugins it loads share one engine copy. Such an executable keeps the C runtime's allocation functions: memory_guard and allocation_scope count nothing in it, and the suite asserts "no growth" through the registry instead. The option needs conjure_finalize_engine() to have run, which the root CMakeLists.txt does before tests/ (Building and Configuration).

Warning

Case names become CMake list items and CTest names: they must be unique within the executable and must not contain ; or unbalanced [ / ]. check_style.py (test-case-name) rejects ; and unbalanced brackets; a duplicate name is not caught until doctest_discover_tests() registers the second entry, so grep the file before adding a case.

Conventions

Follow these test conventions:

Rule Detail
One file per header tests/<module>/test_<name>.cpp mirrors engine/include/conjure/<module>/<name>.h (core: tests/core/<area>/test_<name>.cpp); check_style.py --tests-mirror-headers enforces it, exceptions with reasons in tools/style_exceptions.json
File opening #include "conjure/testing/doctest.h" first, then TEST_SUITE("<module>/<name>")
Case names TEST_CASE("<type> - <behaviour in plain English>"), e.g. "slot_map - erase invalidates the handle generation"; bug fixes add "regression - <issue id> <summary>"
Variants SUBCASE, never copied cases; loops CAPTURE(index)
Tags in the name [slow] (> 1 s), [parallel] (asserts on multi-worker behaviour), [scripting] (+ * doctest::timeout(60)), [window] (needs a real window; guarded by CONJURE_TEST_REQUIRE(precondition::REAL_WINDOW))
Assertions REQUIRE only when continuing would dereference an invalid result, CHECK otherwise; floats through doctest::Approx or CONJURE_CHECK_APPROX; results through CONJURE_REQUIRE_OK, CONJURE_CHECK_OK, CONJURE_CHECK_ERROR
Fixtures locals in the case body; TEST_CASE_FIXTURE allowed, fixture inheritance not
Coverage per public type construction/destruction, happy path, failure path (every error_code a result function can return), edge cases (empty, max, invalid or stale handle)
Forbidden, checked by check_style.py (forbidden-in-tests) std::thread / std::jthread (use core::jobs), sleep_for, wall-clock reads (steady_clock / system_clock / high_resolution_clock::now), getenv (only test_main reads variables); doctest-include catches a direct <doctest/doctest.h>
Forbidden, checked in review randomness not derived from environment().seed, file I/O outside temp_directory, other third-party headers, absolute paths
Skipping * doctest::skip() needs a comment with the tracking issue; machine preconditions use CONJURE_TEST_REQUIRE (section 6)

The first group is mechanical: check_style.py reports forbidden-in-tests; a test file that the test infrastructure permits exceptions (core areas below jobs testing their thread-safety contract, the process tests' wall-clock timeouts) is listed under forbidden_in_tests in tools/style_exceptions.json with its reason. The second group has no script behind it; the review checklist (section 5 of Contribution Workflow) is where it is caught.

The support library

All headers are under tests/support/include/conjure/testing/, namespace conjure::testing; every one has a self-test in tests/support/tests/ (conjure_support_tests, label support).

Header Provides Use it for
conjure/testing/doctest.h CONJURE_REQUIRE_OK(expr), CONJURE_CHECK_OK(expr), CONJURE_CHECK_ERROR(expr, errorCode), CONJURE_TEST_REQUIRE(precondition), describe_error(result), has_error(result, code), doctest::StringMaker for core::uuid and core::error, toString(core::error_code) every test file; the result macros evaluate their expression exactly once and print category.CODE: message on failure
conjure/testing/test_environment.h enum class precondition : u8 { DOTNET_RUNTIME, DOWNLOADED_ASSETS, SOFTWARE_GPU_ADAPTER, LOOPBACK_TCP, REAL_WINDOW, AUDIO_DEVICE, COUNT }, struct test_environment (seed, jobThreadCount, isolatedProcess, goldenEnabled, updateGoldens, realWindowAllowed, continueOnAssert, the four paths repoAssetRoot, downloadedAssetRoot, outputRoot, temporaryRoot, executableName), environment(), precondition_holds(), require_precondition(), set_precondition_probe(), to_string(precondition), SKIP_EXIT_CODE = 77 reading the seed and thread count instead of environment variables; installing a probe for a module-dependent precondition
conjure/testing/approx.h approx_equal(left, right, epsilon = EPSILON) for f32, vec2/3/4, quat (q and -q equal), mat3/4, aabb, transform; EPSILON = 1.0e-5f; CONJURE_CHECK_APPROX(actual, expected); StringMaker for every math type comparing results of whole computations
conjure/testing/log_capture.h log_capture: contains(level, substring), contains(substring), count(level), count(), entries(), messages(), messages(level), allow_errors(), errors_allowed(), clear(); captured_log_entry { level, category, text } asserting on log output; the destructor fails the case when an ERR or FATAL was logged without allow_errors()
conjure/testing/assert_capture.h expect_assert: count(), failures() (span of asserted_failure, at most CAPACITY = 8), last_message(), reset(); CONJURE_CHECK_ASSERTS(statement) code that must assert; scopes nest, record asserts from helper threads, and never allocate
conjure/testing/memory_guard.h memory_guard: check(), reset_baseline(), live_delta(), baseline() leak detection: the destructor fails the case when live allocations differ from the baseline
conjure/testing/allocation_scope.h allocation_scope: allocation_count(), free_count(), allocated_bytes(), reset(); CONJURE_CHECK_NO_ALLOCATIONS(statement) allocation gates on hot paths (parallel_for dispatch, slot_map lookup)
conjure/testing/temp_directory.h temp_directory (optional name prefix): path(), file(name), write_text(name, text) -> result<void>, write_file(path, contents) the only place tests may do file I/O; unique per instance under environment().temporaryRoot, removed on destruction
conjure/testing/test_assets.h repo_asset(relativePath), downloaded_asset(relativePath) fixtures under tests/assets (always present) and tests/.downloaded (behind precondition::DOWNLOADED_ASSETS)

The engine support library

tests/support/engine/ builds conjure_test_support_engine (conjure::test_support_engine; the _shared twin for LINK_ENGINE_SHARED executables) on top of the core library and conjure::engine, with the optional renderer, physics, audio and scripting libraries when they are compiled. In a tree with ImGui (an editor build) it also takes ImGui's include directories and definitions, never its code, for soft_raster. Headers are under tests/support/engine/include/conjure/testing/, self-tests in tests/support/tests/engine/ (conjure_support_engine_tests), and check_style.py --tests-mirror-headers pairs the two like a module.

Header Provides Use it for
conjure/testing/headless_engine.h headless_engine_options (workerCount, fixedDeltaSeconds, enableRenderer, enablePhysics, enableAudio, enableScripting, useNullScriptHost, allowErrors, checkMemory, project, gameAssembly, registerSystems), headless_engine: load_scene, load_scene_json, step_frames, step_seconds, application(), context(), world(), scenes(), active_scene(), window(), input(), rhi_stats(), audio_stats(), checks(), logs(), frame_index(), fixed_update_count(), world_hash(), find_entity() a whole engine::application on the null window, device and audio backend with log_capture and memory_guard built in; workerCount 0 runs the jobs inline; a one-time warm-up process absorbs the process-wide first-use allocations
conjure/testing/input_script.h input_script: key, tap_key, text, mouse_move, mouse_button, mouse_scroll, gamepad_*, push, events_for(frame), close_frames_before, late_event_count scripted input replayed into the null window frame by frame; frames are absolute (schedule at frame_index() + n after stepping) and an event scheduled for a frame that already ran fails the case at the next step_frames
conjure/testing/world_builder.h spawn_many, spawn_hierarchy(scene, hierarchy_shape), hierarchy_entity_count, spawn_box_body, spawn_script_entity, mark_dirty_fraction populating a world or scene with 10,000 entities in one call
conjure/testing/protocol_client.h protocol_channel, scripted_protocol_channel, protocol_client: send(command, args), send_raw, receive, events(), response_ok, error_code_of driving the editor protocol from a test without sockets
conjure/testing/golden_image.h golden_options, golden_result, golden_image::render_headless, compare, compare_images, make_diff, reference_path, output_directory the golden-image scenarios behind CONJURE_TEST_GOLDEN_IMAGES (render_offscreen waits for off-screen rendering); the default limits let up to 0.5 % of the pixels be wholly wrong (a 33x33 block at 640x360), so review the reference images of a PR, which is the guard against a small missing object
conjure/testing/soft_raster.h soft_raster (add_texture, clear, draw, pixels, pixel, width, height, pixel_hash, to_image, write_png), raster_texture, raster_stats (outOfRangeTriangles among its counters) rasterising ImGui's ImDrawData on the CPU into the same bytes on every compiler and platform (integer pipeline after one rounding to 8 sub-pixel bits, top-left fill rule, the renderer backend's scissor arithmetic), for the widget kit goldens and the painter's pixel-coverage cases; built only in a tree with ImGui, and the header itself includes no ImGui
conjure/testing/log_category.h LOG_TESTING the library's own messages

Warning

memory_guard sees doctest's own bookkeeping. Create the guard after the SUBCASE selection (or call reset_baseline() once the variant is chosen) and never enclose a SUBCASE boundary or a message macro on a worker thread; test_main pre-grows doctest's INFO stack so the CONJURE_* macros are safe inside a guard on the test thread only.

Caution

Outside an expect_assert scope a failed CONJURE_ASSERT fails the current case, prints the captured log and aborts the process, in a direct run as much as under CTest. Code under test must early-out after its assert so that a scope which records and continues cannot corrupt state.

Test executable start-up

tests/support/src/test_main.cpp (DOCTEST_CONFIG_IMPLEMENT) does, in order: parse the --conjure-* arguments (environment variables are the fallback) into test_environment and hand everything else to doctest; replace the console sink by a 4,096-entry ring buffer that a doctest listener dumps to stderr when a case fails; install detail::testing_assert_handler; seed core::random and designate the main thread (core::jobs::set_main_thread()); print seed=<n> threads=<n> to stderr; run. An unknown --conjure-* option exits with code 3.

Argument Variable Default Effect
--conjure-seed=N (decimal or 0x hex) CONJURE_TEST_SEED 0x5EED seeds core::random::default_engine(); read back through environment().seed
--conjure-threads=N (<= 1024) CONJURE_TEST_THREADS clamp(hardware_concurrency(), 2, 8) environment().jobThreadCount; 0 runs every job inline
--conjure-isolated CONJURE_TEST_ISOLATED off (CTest passes it) unmet preconditions exit 77 instead of returning
--conjure-update-golden CONJURE_TEST_UPDATE_GOLDEN off tests that keep a reference overwrite it: the GPU golden images, the widget kit goldens, the protocol dump docs/generated/editor_protocol.json and the scene round-trip fixture
--conjure-continue-on-assert CONJURE_TEST_CONTINUE_ON_ASSERT off an unexpected assert on the test thread fails the case and continues instead of aborting
- CONJURE_TEST_WINDOW=1 off precondition::REAL_WINDOW holds; never in CI
- CONJURE_TEST_DOWNLOADED_ASSET_ROOT compile definition the one variable that overrides a compiled-in path, for testing the precondition itself

Preconditions and skipping

CONJURE_TEST_REQUIRE(precondition::X); is the first statement of a case that needs something from the machine. When the precondition holds it is a no-op. Otherwise, under CTest (isolatedProcess) it prints skipped: precondition X not met (file:line) and exits with SKIP_EXIT_CODE (77), which SKIP_RETURN_CODE 77 turns into Not Run; in a direct run it emits a doctest MESSAGE and returns from the case.

Precondition Holds when
DOWNLOADED_ASSETS tests/.downloaded/ exists and the stamp file .assets_ready exists in its parent directory, i.e. tests/.assets_ready (precondition_holds() in tests/support/src/test_environment.cpp, as implemented)
REAL_WINDOW CONJURE_TEST_WINDOW=1; used by tests/platform/test_backend_conformance.cpp to run the GLFW backend through the same cases as the null backend
SOFTWARE_GPU_ADAPTER the probe tests/rhi/rhi_test_support.cpp installs with set_precondition_probe() can create a device with preferSoftwareAdapter (WARP on Windows); guards the D3D12 and Vulkan cases of test_device, test_swapchain and test_shader_library (RHI module)
AUDIO_DEVICE the probe tests/audio/audio_test_support.cpp installs finds a miniaudio playback device; guards test_miniaudio_backend (Audio module)
DOTNET_RUNTIME the probe the scripting, bindings and engine support libraries install finds the managed SDK this tree built (Conjure.Managed.dll under the CONJURE_TEST_MANAGED_DIR definition) and a .NET 8 runtime; guards every [dotnet] and [scripting] case. The runtime tests install their own probe (tests/runtime/runtime_test_support.cpp): the managed SDK in managed/ next to conjure_runtime, Conjure.TestScripts v1 and a .NET runtime; their [dotnet] case is compiled only where CONJURE_RUNTIME_TEST_HAS_DOTNET is 1
LOOPBACK_TCP the probe tests/editor/editor_test_support.cpp installs can open and connect a loopback socket; guards the TCP transport cases

The default test presets exclude the labels benchmark|golden|kit_visual|downloaded|slow|process, so a fresh clone without network is green. tools/ctest_check_skips.py reads the JUnit reports of a job's ctest runs (--junit, repeatable) and the labels from ctest --show-only=json-v1 and fails on any Not Run whose labels are not in CONJURE_TEST_ALLOWED_SKIPS (or --allow-label) and whose name carries no --allow-tag tag; CI runs it over both reports of a leg with --allow-tag window --allow-tag downloaded --allow-tag audio_device, plus --allow-tag gpu on Linux and macOS where no D3D12 WARP adapter exists (Continuous Integration).

Writing a test

A minimal file for a header conjure/core/<area>/<name>.h, following tests/core/foundation/test_result.cpp:

#include "conjure/testing/doctest.h"

#include "conjure/core/result.h"

using namespace conjure;
using namespace conjure::core;

namespace {
    result<int> divide(int numerator, int denominator) {
        if (denominator == 0) {
            return make_error(error_code::INVALID_ARGUMENT, "division by zero ({} / {})", numerator, denominator);
        }
        return numerator / denominator;
    }
}

TEST_SUITE("core/result") {

    TEST_CASE("result - divide returns the quotient") {
        const result<int> value = divide(10, 2);
        CONJURE_REQUIRE_OK(value);
        CHECK(value.value() == 5);
    }

    TEST_CASE("result - divide by zero is INVALID_ARGUMENT") {
        CONJURE_CHECK_ERROR(divide(1, 0), error_code::INVALID_ARGUMENT);
    }
}

A case with the two fixtures every module test should own (log_capture, memory_guard), plus an allocation gate and an expected assert:

#include "conjure/testing/doctest.h"

#include "conjure/testing/allocation_scope.h"
#include "conjure/testing/assert_capture.h"
#include "conjure/testing/log_capture.h"
#include "conjure/testing/memory_guard.h"

#include "conjure/core/containers/slot_map.h"

using namespace conjure;
using namespace conjure::core;
using namespace conjure::testing;

TEST_SUITE("core/slot_map") {

    TEST_CASE("slot_map - lookup is allocation-free and erasing end asserts") {
        log_capture logs = {};      // its destructor fails the case if an ERROR or FATAL was logged
        memory_guard guard = {};    // its destructor fails the case if an allocation leaks

        slot_map<int> map = {};
        const slot_key key = map.insert(7);
        const int *found = nullptr;
        CONJURE_CHECK_NO_ALLOCATIONS(found = map.find(key));   // lookup is O(1) and allocation-free
        CHECK(found != nullptr);

        CHECK(map.erase(key));
        CHECK_FALSE(map.erase(key));                  // a stale key is rejected, not asserted
        CONJURE_CHECK_ASSERTS(map.erase(map.cend()));  // erasing end() asserts once and leaves the map unchanged
    }
}

File I/O goes through temp_directory (section 4); its write_text returns result<void>, so CONJURE_REQUIRE_OK(scratch.write_text("scene.json", "{}")) wraps it.

Register the file in tests/<module>/CMakeLists.txt (SOURCES), build, and run tools/check_style.py --tests-mirror-headers: a new public header without its test_<name>.cpp is a style finding.

Tip

Copy patterns from the existing suites: tests/core/foundation/test_result.cpp (result macros), tests/core/jobs/ (CONJURE_JOBS_WORKER_SUBCASES runs every behavioural case with 0 and 8 workers), tests/core/containers/test_slot_map.cpp (property tests against the standard container seeded with 0x5EED), tests/support/tests/ (self-tests of every helper, including a spawned child for exit code 77).

Running tests

python tools/build.py --test                                                     # everything, default preset
python tools/build.py --target conjure_core_foundation_tests --test -R core_foundation
ctest --preset windows-msvc-debug -R "core_foundation.result - value result"     # one case through CTest
ctest --preset windows-msvc-debug -L support                                     # by label
build/windows-msvc-debug/bin/conjure_core_foundation_tests -tc="result - *"      # doctest filter, full report
build/windows-msvc-debug/bin/conjure_core_jobs_tests -ts="core/job_system" -s    # one suite, successful asserts too
build/windows-msvc-debug/bin/conjure_core_jobs_tests --conjure-threads=0 --conjure-seed=0x1234

Reading failures: ***Failed in ctest output names the exact case; rerun the executable with -tc for doctest's report and the ring-buffer log of that case. log_capture: unexpected ERROR logged by [...] means the case needs allow_errors() or has a real bug; memory_guard: N allocation(s) still live is a leak; an unexpected CONJURE_ASSERT prints its source location and aborts the process.

Header, style, export and documentation checks

  • Header check. conjure_header_check(<target>) compiles every header listed in the target's CONJURE_PUBLIC_HEADERS in its own translation unit with the project warning set; the aggregate target conjure_header_check is part of ALL, so a header that does not include what it uses breaks the default build. tests/core/CMakeLists.txt calls it for every core area.
  • Style check. python tools/check_style.py --tests-mirror-headers (CTest style.check, label style) scans engine/, editor/, runtime/, tests/, samples/ and reports path:line: rule: message for: tabs, line-length (120), crlf, trailing-whitespace, pragma-once, using-namespace (headers), windows-macro (enumerators or constants named ERROR, DELETE, IN, min,...), enum-class (plain enums only for *_flags), include-order (own module, other Conjure, third-party, standard library, blank line between groups, quotes for Conjure headers), third-party-include (public headers), doctest-include, third-party-include-in-test, test-case-name, forbidden-in-tests, thread-outside-jobs (non-test code: no std::thread / std::jthread outside the two core/jobs folders, std::async and the raw OS thread calls nowhere), lifecycle-spelling (initialise, finalise and their forms in identifiers), file-name (snake_case), kit-only (no editor source under engine/include/conjure/editor/, engine/src/editor/ or editor/ reaches ImGui, by an include, an include chain or an ImGui name, unless kit_only_exceptions in tools/style_exceptions.json lists it with its reason) and tests-mirror-headers. The include rules and kit-only take no directive from comments, string literals or the text of a raw string literal. Exit code 0 clean, 1 findings, 2 usage error. style.check and style.check_tool also carry the label kit_conformance.
  • Export check. python tools/check_exports.py [module ...] (every module by default or with --all; name modules to check only those) reports public classes with out-of-line members, namespace-scope prototypes and extern variables that lack CONJURE_API; output path:line: kind: message, exit code 0 clean, 1 findings, 2 usage error. CTest runs it as exports.check_annotations, its --self-test as exports.check_tool and --count-exports over the built conjure_shared as exports.count_shared_library (labels exports;style); see Modules module 7.2.
  • Documentation checks. python -I tools/check_docs.py (CTest docs.check, label docs) checks local links, anchors, wiki boundaries, alerts, markers, every public header's code span, and scoped handbook module pages; tools/tests/test_check_docs.py (CTest docs.check_tool) is the checker's self-test over a fake docs tree it generates in a temporary directory. tools/tests/test_docs.py (CTest docs.driver_tool) checks commands and all four draft templates. tools/tests/test_docs_site.py runs rendering/build tests with the documentation environment. tools/tests/test_regenerate_docs.py (CTest docs.regeneration_tool) tests content-preserving regeneration; docs.generated_up_to_date checks that templates and source-derived documentation agree. The Writing Documentation chapter explains these checks.
  • Generated outputs. python -I tools/generate_brand_icons.py --check (CTest brand.icons_up_to_date, label generated) fails while the editor's committed icon differs from what the logo drawings produce; tools/tests/test_generate_brand_icons.py (CTest brand.icons_tool) is the generator's self-test. The Logo and application icon chapter explains both; the notices entries are in the generated row of section 10.

Labels

Label Applied to Default presets
unit, <module> every entry from conjure_add_test_module() (core_math, support,...) run
extra LABELS e.g. support on the self-tests run
style style.check, style.check_tool; also the exports.* entries (labels exports;style, section 9) run
kit_conformance the widget kit's conformance suite: the editor cases tagged [kit_conformance] or [kit_visual], plus style.check and style.check_tool (Editor and widget kit tests) run, except the kit_visual cases among them
kit_visual the widget kit's goldens, the editor cases tagged [kit_visual] (timeout 600 s; Widget kit goldens) excluded by every test preset; pull-request CI runs them on its Windows legs
build editor.kit_labels (the kit's labels checked against their tags in the build tree), build.abi_identity_non_ascii_path (the ABI identity script over a non-ASCII path), build.managed_project_references (the managed <ProjectReference> parser through the source-tree check), the configure probes build.missing_engine_module_fails_configure, build.missing_core_area_fails_configure, build.missing_test_module_fails_configure, build.missing_core_test_area_fails_configure, build.missing_benchmarks_fail_configure, build.missing_integration_fails_configure (a listed directory without its CMakeLists.txt stops the configure) and build.development_links_without_incremental (Development links with /INCREMENTAL:NO); the fourteen notices probes of cmake/ConjureNotices.cmake (notices.configure_*, notices.*_fails_configure, notices.host_files_without_flag_fail_configure, notices.ship_places_and_restores_the_file); runtime.msvc_runtime_folder_rules (labels runtime;build: which Visual C++ redistributable folder a Distribution build ships, probed over fake folders on every platform) run
tools build.driver_tool, build.prune_tool, test_assets.downloader_tool, native_api.generator_tool, kit.triptych_tool, runtime.check_distribution_symbols_tool (labels runtime;tools): the tool self-tests; build.driver_tool and build.prune_tool are not under build run
third_party the libjxl pin probes third_party.jxl_* (also labelled build), listed in JPEG XL run
managed conjure_managed_sources_match.<name> and conjure_managed_source_tree_clean.<name>, registered per managed project by cmake/ConjureManaged.cmake run
docs docs.check, docs.check_tool, docs.driver_tool, docs.regeneration_tool, docs.generated_up_to_date run
generated conjure_scripting_api_generated_up_to_date, brand.icons_up_to_date, brand.icons_tool, notices.up_to_date (python -I tools/third_party_notices.py --check --manifest <build>/notices/third_party_notices.json: fails while THIRD_PARTY_NOTICES.md differs from the licence files the tree fetched), notices.tool (the tool's self-test); both need a Python interpreter run
integration, engine, bindings, editor, runtime, benchmarks the suites (benchmarks is the harness self-test, not the scenarios) run
dotnet cases that start the real CLR (tests/scripting, tests/bindings, the [scripting] integration scenarios, the scripting benchmarks) run; Not Run without the SDK
benchmark one entry per scenario of conjure_benchmarks (benchmark.<module>.<scenario>, plus the module label) excluded; nightly benchmarks-ci-class
golden, downloaded, slow, process GPU golden images, downloaded fixtures, > 1 s cases, tests that spawn an executable (tests/runtime, test_editor_process, the export round trip) excluded; nightly-test excludes only benchmark and kit_visual; CI runs downloaded|process in a second step

Filter with ctest -L <label> or python tools/build.py --test -L <label>; -R filters by entry name.

Note

The cases that need hardware carry no extra label: they are ordinary unit;<module> entries that exit 77 when their precondition (section 6) does not hold, so a default run reports them as Not Run rather than skipping them silently.

Editor and widget kit tests

tests/editor/CMakeLists.txt builds one executable, conjure_editor_tests (labels unit;editor, timeout 300 s). Its folders follow the editor's include tree, so check_style.py --tests-mirror-headers finds each header's file in the header's own sub-directory:

Folder Holds Built when
tests/editor/ one test_<header>.cpp per public header of conjure/editor/, the topic files (command catalogue fixtures, editor.batch, the per-area command files, protocol robustness, the loopback session, the headless runner, the Grid Sweeper command file) and editor_test_support.{h,cpp} conjure::editor_core exists
tests/editor/protocol/ the headers of conjure/editor/protocol/ always, with the folder above
tests/editor/ui/, tests/editor/ui/panels/ the headers of conjure/editor/ui/ and its panels, and the UI test support (draw_test_support, font_test_support, module_test_support, panel_test_support, picture_test_support) conjure::editor_ui exists
tests/editor/kit/ one test_<header>.cpp per public header of conjure/editor/kit/, plus test_shaded_line.cpp and test_typography.cpp for two of the kit's private headers conjure::editor_kit exists
tests/editor/kit/support/ kit_test_support.{h,cpp}: a headless kit frame, the probe of the kit's stock-item counter, draw probes as above
tests/editor/kit/text/ the typography's private text/ headers: the font loader, the OpenType reader, the GSUB reader, the code ligatures over a hand-built font and over the bundled Fira Code, the ligature atlas and the shaped-run cache as above
tests/editor/kit/golden/ the kit goldens and their Grid Sweeper fixture (Widget kit goldens) the kit and the UI exist
tests/editor/data/ commands/ (command files), protocol_corpus/, kit_mockup/ (the structural layout references, layout_<theme>.json) and kit_golden/ (the golden references) data, never built

The UI and kit cases run headless over the null backends. They draw into an ImGui frame without a renderer backend (conjure/editor/ui/imgui_frame_scope.h), click widgets by id (ImGui::ActivateItemByID, through panel_test_support's activate or the kit's frame record), press keys and type through ImGuiIO, and move the pointer with imgui_frame_scope::set_mouse. The painter's coverage cases rasterise its draw lists with soft_raster, so the executable links conjure::test_support_engine when the kit is built. The text cases read the fonts the build installed next to the executable (bin/fonts/), as the editor finds them, so a file the font loader or the code ligatures would refuse fails a test.

Conformance

The widget kit's conformance suite carries the label kit_conformance, so ctest -L kit_conformance runs it alone. It holds:

  • the cases whose name carries [kit_conformance]: per widget family and per panel, no canary ink and no stock ImGui item, idle and while editing; the stock colour table; the reverse pass, in which every PRIMITIVE colour of that table shows somewhere the editor draws; and the structural comparison of the Grid Sweeper default layout with tests/editor/data/kit_mockup/layout_<theme>.json in six themes;
  • the [kit_visual] goldens (below);
  • style.check and style.check_tool, which hold the editor's sources to the kit-only include rule.

Doctest's discovery registers every case of an executable with the same labels, so tests/editor/CMakeLists.txt writes a file of label rules that CTest reads after discovery (conjure_editor_tests_tag_labels.cmake, a TEST_INCLUDE_FILES entry). It gives every case whose name carries [kit_conformance], [kit_visual], [process], [slow] or [dotnet][slow] its labels.

editor.kit_labels (label build, registered when the kit, the UI and the renderer are built) holds those labels to their tags. It runs tests/editor/check_kit_labels.cmake, which lists what each selection finds in the build tree: -L golden must find no editor case, -L kit_visual exactly the [kit_visual] cases, -L kit_conformance exactly the tagged cases and the two style entries, and the filters of the base-test and nightly-test presets must leave every [kit_visual] case out.

Widget kit goldens

The widget kit's goldens are CPU renders of editor frames compared with committed reference images. They need no GPU: soft_raster rasterises ImGui's draw data in an integer pipeline, so the same draw data gives the same bytes on every compiler, optimisation level and platform. They are not the GPU golden images of CONJURE_TEST_GOLDEN_IMAGES, and their labels, kit_visual and kit_conformance, hold no golden, so the nightly GPU jobs' ctest -L golden (a regular expression) never selects them.

tests/editor/kit/golden/test_kit_golden.cpp draws, headless, with the bundled fonts, in the six built-in themes at 100 % and 150 % UI scale:

  • every section of the Widget gallery, each cropped to its content;
  • the gallery's "Enum, a name disabled" field with its list open (8x greyed), the field and the list cropped together with an 8 px margin at 100 % (OPEN_LIST_MARGIN, times the scale), since a section golden never shows a popup open;
  • the default layout over the Grid Sweeper fixture of the structural comparison (grid_sweeper_layout.{h,cpp}), at the editor's client area times the scale.

References

A reference is tests/editor/data/kit_golden/<name>/<variant>.jxl. <name> is layout, gallery/<section>, or gallery_open/choices (the open list), and <variant> is <theme>_<percent>, for example gallery/buttons/autumn_150.jxl or layout/deep_ocean_150.jxl. The files are lossless JPEG XL tagged sRGB, the repository's image format, in an ordinary folder outside Git LFS. The renderer's codec (conjure/renderer/jpeg_xl.h) reads and writes them. The cases that compare references therefore compile with the renderer module only; the harness and the Grid Sweeper fixture, which ui/test_default_layout.cpp shares, build without it.

The comparison uses the kit's own limits, kit_test::KIT_LIMITS (kit/golden/kit_golden.h):

Limit Value
A pixel mismatches when a channel differs by more than 3
Mismatched pixels allowed 64
Largest 8-connected cluster of mismatched pixels 8
Mean absolute error over the colour channels, at most 0.25

A CPU rasteriser has no rasteriser noise to absorb, so these limits are far stricter than the GPU goldens' (whose defaults let four missing 16 px icons pass). Only scattered pixels may differ: ImGui's approximate reciprocal square root in its anti-aliased edges and libm differ between processors. A missing icon or border fails, and so does a change of a whole fill within the channel tolerance.

What differs between runs or builds by design is masked before the comparison with a fixed two-grey hatch (kit_test::mask_area), which the reference holds as well: each console line's local time, the status bar right of its leading segments (the build's configuration and the frame rate), and the CPU time of the Scene view's stats chip.

Running and reading failures

ctest --test-dir build/<preset> -L kit_visual --output-on-failure
build/<preset>/bin/conjure_editor_tests -tc="*[kit_visual]*"

Every test preset leaves kit_visual out by name; pull-request CI runs it in a step of its own on the Windows legs (Continuous Integration). The cases have a 600 s timeout.

A failing comparison writes two PNG files under build/<preset>/test_output/conjure_editor_tests/kit_golden/<name>/<variant>/: actual.png, the render, and diff.png, the difference magnified eight times. They stay PNG so that any image viewer opens them. A missing or unreadable reference fails and writes actual.png alone. Every comparison first removes the failure images an earlier run left in its folder, and a passing comparison writes none.

Regenerating the references

build/<preset>/bin/conjure_editor_tests -tc="*[kit_visual]*" --conjure-update-golden

In update mode a reference is rewritten whenever its pixels differ at all from the render, even where the limits would pass, so an intended change shows in the pull request's images; a reference equal to the render is left untouched, and the check passes once the write succeeds. References are encoded at kit_test::REFERENCE_EFFORT, 7, libjxl's default effort, on the test's job system; the bytes are the same with or without worker threads, and a lossless file holds the same pixels at every effort. There is no other step.

Important

Review every rewritten reference before committing it. Update mode accepts any change, so the images in the pull request are the only guard against an unintended one.

Review triptychs

A layout run also leaves, under build/<preset>/test_output/conjure_editor_tests/kit_golden/, what tools/kit_triptych.py reads:

File Content
layout/<variant>/render.png the layout's render, masked, as it was compared with its reference
layout/<variant>/text_mask.png where the same frame drew text, white on black, with the masked areas added
mockup/<theme>.png the approved editor mockup's render in that theme (docs/assets/editor_mockup/<theme>.jxl), decoded

The tool uses Python's standard library alone, which cannot decode JPEG XL, so it reads these PNG files and refuses a .jxl file with that advice:

python tools/kit_triptych.py --build-dir build/<preset> --out-dir <folder>
python tools/kit_triptych.py --render <render.png> --mockup <mockup.png> --text-mask <text_mask.png> --out <file.png>

--build-dir makes one triptych_<variant>.png per layout reference and triptych_stats.txt, and fails, naming the run to make, when the render or the mockup render is missing. Each triptych puts side by side the mockup render (cropped below its title row and resampled by area to the render's size), the kit's render, and their CIEDE2000 difference with the text hatched in blue. The statistics give the share of pixels past each difference threshold outside the hatching, per region of the layout. The triptych is for review and is not a gate; the goldens are. kit.triptych_tool (label tools) is the tool's self-test.

Benchmarks

tests/benchmarks/ (CONJURE_BUILD_BENCHMARKS, ON) holds the benchmark harness: the library conjure::bench_harness (conjure/bench/benchmark.h: CONJURE_BENCHMARK(name), bench_context::measure, fixed warm-up and measured iterations, min / p50 / p95 / p99 and the exact allocation count of the worst iteration; conjure/bench/bench_runner.h: the command line, thresholds, JSON output and exit codes), the executable conjure_benchmarks with one scenario file per module (bench_core, bench_ecs, bench_scene, bench_assets, bench_physics, bench_render_null_frame, bench_render_extract, bench_scripts_update_phase, bench_bindings_spawn, bench_full_frame_10k, and bench_editor in a tree with the editor), thresholds.json with the desktop and ci machine classes (ci is 3x looser), and the self-tests conjure_benchmarks_tests (label benchmarks). Every scenario is one CTest entry benchmark.<module>.<scenario> under the label benchmark (plus the module name; the scripting scenarios add scripting and dotnet), excluded from the default presets. Thresholds are enforced in Development and Distribution and only reported in Debug; --enforce / --no-enforce override. A scenario that returns without measure() or skip(), or that calls bench_context::fail, is FAILED with a reason rather than passing over zero samples. --threads means what jobs_settings.workerCount means: 0 is inline jobs (the determinism tests' mode), auto (default) is hardware_concurrency - 1 clamped to 1..16.

python tools/build.py --preset windows-msvc-dev --build-dir build/bench --target conjure_benchmarks --test -L benchmark
build/bench/bin/conjure_benchmarks --list
build/bench/bin/conjure_benchmarks --filter "scene.*" --threads 8
build/bench/bin/conjure_benchmarks --filter "ecs.*" --threads 0

tests/benchmarks/README.md documents the layout, the command line and how to add a scenario. The nightly benchmarks-ci-class job runs the executable with --class ci --enforce and publishes the table. Allocation-free steady state is still asserted in unit tests as well (CONJURE_CHECK_NO_ALLOCATIONS, job_system::stats().poolGrowths).

Editor frame budgets

bench_editor.cpp holds the widget kit's frame budgets. It is compiled and its scenarios registered only when the build has the editor's UI (conjure::editor_ui), so never in Distribution. Each scenario measures a headless editor (null platform, RHI and audio; scripting on the null host) over a scratch project, drawn by the editor's own UI code in an ImGui frame without a renderer backend, with the bundled fonts the build installs, in Midnight at 100 %.

Scenario What one iteration is Desktop / ci p50 Allocations Fails when a measured frame
editor.default_layout_frame one UI frame of the editor layer (its update, the ImGui frame with the workspace, Render, the frame end): the default layout in the 1600 x 867 client area at the Grid Sweeper fixture's paused moment 1.00 / 3.00 ms not gated drew no vertices, or more than DEFAULT_LAYOUT_VERTEX_LIMIT: 1.3 times the 14,930 the kit's frame drew when the gate was set (19,409)
editor.hierarchy_frame_10k, editor.hierarchy_frame_100k one steady frame of the Hierarchy alone in its 262 x 538 column over 10,000 or 100,000 root entities 0.15 / 0.45 ms 0 drew no row, or more rows than its view holds
editor.hierarchy_rebuild_100k the same tree with one structural change a frame, so every frame rebuilds the rows none: thresholds.json has no entry, so the row is UNTHRESHOLDED, which an enforced run (Development, Distribution, --enforce) counts as a failure not gated did not rebuild, or drew no row
editor.console_frame one steady frame of the Console in its 653 x 236 dock over 10,000 lines of code text, whose shaped runs are cached 0.15 / 0.45 ms 0 drew no line or more than the dock holds, or Fira Code's ligatures are off
editor.console_scroll_ligatures the same console scrolled by one view a frame, so every line it shows runs the ligature pass 0.50 / 1.50 ms not gated as the console above, or shaped no run

The items of editor.default_layout_frame are the most vertices a measured frame drew. The checks of what a frame drew apply to the measured frames, not the warm-up's. tests/benchmarks/README.md records the measured figures and the reasons for each budget.