Repository navigation
Coverage tool
Seth Kitchen edited this page Sep 15, 2026
·
12 revisions
coverage/. A source-to-source instrumenter and a report that measure line, branch, condition and MC/DC coverage. Mojo 1.0 ships no coverage tool, and the toolchain has no llvm-cov to build one on.
This is original work with no three.js lineage.
-
build_cli.mojorewrites every covered module intocoverage/build/, with a probe before each statement and around each decision. It writes a manifest of everything the probes can report. - The test suites run with
-I coverage/build -I ., so imports resolve to the instrumented copies. Each probe writes one record tostderr.stdoutis unchanged. -
report_cli.mojogroups the records, matches them to the manifest, and prints the table. It exits with an error when anything is uncovered.
make coverage runs all three. See How to measure coverage.
| Module | Job |
|---|---|
scanner.mojo |
Find statements, decisions and loop headers in a source file. |
instrument.mojo |
Emit the probes. Split and and or conditions. |
runtime.mojo |
The probe functions the instrumented code calls. |
mcdc.mojo |
Reconstruct decision vectors from the ordered record stream. |
report.mojo |
Build the report and decide whether it is complete. |
build_cli.mojo, report_cli.mojo
|
The two commands the Makefile runs. |
| Metric | Question |
|---|---|
| Line | Did this statement run? |
| Branch | Did this decision go both ways? A for loop counts, including running zero times. |
| Condition | Did each and or or operand take both values? |
| MC/DC | Did each operand change the outcome on its own? |
MC/DC is the masking variant. Short-circuit evaluation makes unique-cause MC/DC unreachable for most compound decisions.
- The Makefile's
COVEREDlist is every CPU module.COVERAGE_EXCLUDEnamesrender/gpu.mojo, because a kernel has nostderr. -
# pragma: no branchopts one decision out. Use it only when the other outcome is provably unreachable. - Probes cannot reach compile-time code, and the instrumenter recognizes
defandasync defonly. - The tool does not measure itself.
Two threads reporting one decision at once would interleave their records. The renderer therefore defaults to one worker, and the coverage run uses it.
A Bool loop flag read after nested loops hangs the Mojo compiler. The instrumenter emits an Int counter instead. See The Mojo compiler hang.
Tutorials
How-to
Reference
- Scene graph
- Rotations
- Cameras
- Geometry
- Geometry addons
- Lofts and clipping groups
- Sculptor
- Procedural generators
- Meshes and assets
- Lines
- Points and sprites
- Helpers
- Scene objects
- Animated objects
- Raycasting
- Curves and paths
- Animation
- Skinning
- Materials
- Node materials
- TSL functions
- Lights
- Lighting addons
- Fog
- Textures
- Renderer
- Renderer hooks and material flags
- Rasterization
- GPU backend
- Render target
- Post-processing
- GPU computation
- Compute nodes
- Progressive light map
- Gaussian splats
- Voxel global illumination
- SVG renderer
- Image files
- Image decode queue
- Model files
- More model files
- Exporters
- Scene JSON
- Windowing and controls
- Math
- Norm consumers
- Math addons
- Units
- Coverage tool
- Commands
- Examples
- Benchmarks
- Extensions
- Shared physics
- Physics query snapshots
- Continuous collision
- Tick force restoration
- Water
- Streamline
- Animals
- Buildings
- CARLA
- Femur
- Tibia
- Fibula
- Patella
- Knee
- Muscles
- Vessels
- Lymph
- Nerves
- Integument
- Leg
- Foot
- Pelvis
- Torso
- Arm
- Hand
- Head
- Genome
- Game humanoid
- Humanoid fidelity
- Audio-aligned game faces
- Converted assets
- Mesh quality
- Segment inertia
Explanation
- Software rasterizer
- Scene graph as an array
- Linear color
- Normals are not colors
- Perspective correction
- Fixed-point coverage
- Per-fragment shading
- Mipmaps
- Sorted transparency
- Types and checks
- Render hooks as a trait
- Shared CPU and GPU code
- Bands and threads
- PNG structure
- Extensions beside the port
- CUDA teardown hang
- Mojo compiler hang