Skip to main content

Module testing

Module testing 

Source
Expand description

htl test: discovery, one isolated Lua state per test file, compile, report.

The runner owns nothing about assertions. A test file requires a library; the bundled default is htl.test (describe / it / expect, typed via test.d.tl). Any library exposing run(filter) -> { passed, failed, failures } under the module name the runner is told about plugs in the same way. A file that uses no such library is judged at file level: it passes if it runs to completion.

Structs§

FileReport
Outcome of one test file.
RunOptions
Runner options passed through to the library’s run(filter, opts).
TestResult
One test’s outcome, as reported by the assertion library.
TestSession
One checker for a whole run: every test file gets its own fresh program state (globals, package.loaded, module state), but modules are type-checked and generated once and served to every file from the checker’s store.

Constants§

DEFAULT_LIB
Module name of the bundled assertion library.

Functions§

discover_tests
*_test.tl anywhere, plus every .tl under a directory named tests. Explicit file paths are always included. Does not enter crate::SKIP_DIRS, dot-directories or the project’s mlua-pkg dir (dependencies’ tests are theirs).
discover_tests_skipping
discover_tests, not entering skip either — directories named by path rather than by name (crate::patched_dirs: a patched dependency’s *_test.tl are its own suite, not the project’s).
file_seed
The seed one file gets, from the run’s seed and its path.
lib_dir
crate::lib_dir with this library’s declaration in it: htl/test.d.tl, written on demand, only when its content changes.
run_test_file
Run one test file in a fresh state. lib is the assertion library module to consult for run(filter) after the file executed (default: htl.test).
snapshot_dir
Where a test file’s snapshots live: <dir>/__snapshots__/<file stem>/.