sifr test discovers and runs test functions in your Sifr source files. You do not need a separate test framework or configuration file — annotate a function with @test and the test runner finds it automatically.
Running tests
Pointsifr test at a directory and it discovers every test file and test function inside it:
dir argument defaults to . (the current directory), so sifr test with no arguments runs everything from where you are.
Writing test functions
Mark any top-level function with@test to include it in the test suite. A test passes when the function returns normally and fails when it raises an error.
raise to signal a deliberate failure:
Test discovery
sifr test discovers tests by walking the target directory for .sifr files, then scanning each file for functions decorated with @test. Discovery rules:
- All
.sifrfiles in the directory and its subdirectories are scanned. - Only top-level functions decorated with
@testare collected. - Import resolution uses the standard library and local modules in the target directory.
Test discovery imports are resolved against the standard library and local modules in the target directory — the same resolution rules used by the compiler for that directory. Tests that import from sibling
.sifr files in the same directory are supported.Reading test output
sifr test reports each test result as it runs and prints a summary at the end.
Diagnostic output format
sifr test respects the global --diagnostic-format flag for compiler diagnostics that occur during test discovery or compilation:
Organising tests
You can place tests directly in your source files alongside the code they test, or keep them in a dedicated directory. Both layouts work withsifr test.
- Inline tests
- Dedicated test directory
Tests live in the same file as the code they cover.