Lore testing standards¶
This document defines the standard patterns for testing across the Lore codebase.
Overview¶
| Type | Location | Framework | Purpose |
|---|---|---|---|
| Unit tests | tests/unit/ in each crate |
Rust/tokio | Module-level testing |
| Integration tests | lore-revision/tests/ |
Rust/tokio | Cross-module testing |
| Smoke tests | scripts/test/ |
Python/pytest | CLI and server testing |
| Load tests | Internal infrastructure | Internal harness | Performance testing |
1. Target risk at the cheapest tier that can find the fault¶
Test effort follows risk, not line count. Business logic — session state, ordering guarantees, allocation and placement decisions — earns thorough tests. Plumbing and trivial code earn few or none. A test that restates the implementation costs maintenance and finds nothing.
Then split by what you are checking:
- Edge cases, variants, boundaries, and error paths → unit tests. They are cheap, so be exhaustive.
- Happy paths → tests that run against real things. Mocks cannot tell you whether this works wired to a real dependency or assembled into the binary we ship, and it is not worth asking twenty times over.
Assert on outcomes, not on wording. Check Ok or Err and the error variant, never a substring of the message. Message text is presentation: it changes for readability and the test fails for no reason, or it stops matching a real regression and passes for no reason.
What a change tests¶
A change must come with its tests. Write them with the code, not after review.
- A fix must carry a test that fails without it. A defect found in use or in review gets a unit test that reproduces it, or a smoke test when it shows only across the binaries.
- Each behavior a change adds or changes must have a test. In business logic, that includes each new branch, limit, and error path. Trivial code needs none, as above.
- Confirm each new test fails without its change. A test that passes either way gives no assurance.
- Test each variant the change reaches. Where code dispatches over filesystem providers (
StaticDispatchInstanceOperation::OsandSwfs), stores, or platforms, test each variant the change touches. Where a variant can't run in the suite, the change's description says which and why. - Test a bound the code relies on past its limit. A limit on memory, concurrency, or batch size gets a test with more input than the limit, which checks that the limit holds.
- Extend the existing harness. Build on the fixtures the test's binary already has, such as
test_store_create,TestOperation, and the smoke fixturesnew_lore_repoandscratch_dir, rather than a setup of your own. A fixture a second test needs goes beside the others.
The tiers¶
Cheapest first. Cost tracks how much must be standing before the test can run.
| Tier | Answers | Location | Needs |
|---|---|---|---|
| Unit | Is this logic correct across all its cases? | tests/unit/ |
Nothing |
| Smoke | Does a real user flow work across the binaries? | scripts/test/, @pytest.mark.smoke |
lore and loreserver binaries built |
Edge cases belong in unit tests. The smoke test covers the happy path only.
Build profile¶
Build and run tests on the release profile, one test or a full suite alike. It compiles incrementally, and one build serves every test run. While iterating on a change, run only the tests it touches: a unit test by its test binary and name, and a smoke test by its node ID. Run the full unit and smoke suites once the change is done.
# One unit test, or the tests a name matches
cargo test --release -p lore-telemetry --test unit observe::result::can_observe_success_no_callback
# One smoke test
cargo build --release -p lore-client -p lore-server --bin lore --bin loreserver
uv run pytest "scripts/test/<file>.py::<test>" --lore-client-binary=release --lore-server-binary=release
# The full unit and smoke suites
cargo test --release
uv run pytest scripts/test/ --lore-client-binary=release --lore-server-binary=release
The State node operations' scenarios¶
When a change touches the State's implementation, lore-revision/src/state.rs and lore-revision/src/state/ with the node module in state/node/, or the scenarios of its node operations and the stress harness they share, also run those scenarios and lint them. Other changes need neither. The scenarios live in lore-revision/tests/state_scenarios/, and those that run the C API's verbs in lore/tests/state_scenarios/. They drive the node operations through scheduling hooks built into lore-revision, so each builds only with its package's state-stress feature: neither a plain cargo test nor the pre-commit hook's clippy reaches them, and a plain run tests the build that ships.
# The State node operations' deterministic scenarios, and their lint
cargo test --release -p lore-revision --features state-stress --test state_scenarios
cargo test --release -p lore --features state-stress --test state_scenarios
cargo clippy -p lore-revision --features state-stress --all-targets -- -D warnings --no-deps
cargo clippy -p lore --features state-stress --all-targets -- -D warnings --no-deps
Their scenarios explore every interleaving they can, or every one within a preemption bound, so the run takes several minutes. An exploration stops at a wall budget only to guard against a hang: an hour by default, set in seconds by LORE_STATE_TESTS_BUDGET_SECONDS. One that stops there fails, since its coverage is incomplete.
The scenarios cover the interleavings written for them. A change to the node operations, in state/node/, also runs a chaos campaign of the stress suite, which finds others: mixes of the operations run more at once than production runs them, on threads that yield at random scheduling points and on random settings, and every run is checked against the contract. scripts/state-stress/README.md covers its modes and options.
# A chaos campaign of the State node operations, after building the stress harness
python3 scripts/state-stress/stress.py build
python3 scripts/state-stress/stress.py chaos --minutes 30
2. Rust unit tests¶
Unit tests live in the crate's tests/unit/ directory, not in inline #[cfg(test)] modules. Cargo builds the directory as one test binary, which links the library like any other user of it:
lore-telemetry/
├── Cargo.toml # [lib] test = false
├── src/
│ └── observe.rs
└── tests/
└── unit/
├── main.rs # mod observe; mod user_agent_filter;
├── observe.rs
└── user_agent_filter.rs
// tests/unit/observe.rs
use lore_telemetry::observe::ObserveResult;
#[tokio::test]
async fn can_observe_success_no_callback() {
// test code
}
An inline #[cfg(test)] module makes cargo compile the whole crate a second time, with --test. That compile produces an executable, which the build cache cannot store, so CI repeats it on every run. Tests in tests/unit/ use the library build every other crate already shares, and the build cache serves it.
Set [lib] test = false in the crate's Cargo.toml once no inline test is left. Without it cargo still compiles the crate a second time, as an empty test harness. The setting covers the whole crate, so move all of a crate's inline modules together. Crates that still carry inline modules move them when next worked on.
One binary, unless a test needs its own process¶
All tests in tests/unit/ share one process, as the tests of an inline module do. A test that needs a process of its own goes in a separate tests/<name>.rs file, which cargo builds as its own binary: one that changes process-wide state other tests would observe, or that exercises process-level behavior such as the library's shutdown. Keep these few. Every file directly in tests/ is another binary to compile and link, and none of that is cached.
Test helpers¶
Put helpers that only the crate's own tests use in tests/unit/ as well, as modules beside the tests: mocks, factories, fixtures. Their dependencies go in [dev-dependencies]. A mockall::mock! of a public trait works there as it does inside the crate.
Helpers that other crates' tests use are the exception. Another crate cannot import a module from tests/, so these live in the library behind the crate's test-util feature, as lore_base::test_util::TempDir does (see Scratch space on disk).
So is a test double that library code has to name itself, such as the type behind a variant of a closed enum. It lives in the library behind test-util as well, as lore_revision::fs::filesystem_provider::test_util::TestOperation does, and the rest of the fixture stays in tests/unit/.
When a test needs something private¶
Look for the public way first: a trait method, a constructor, a re-export. A test that needs private access often checks an implementation detail.
When a test does need an item that is not public, make it public for tests only, behind the crate's test-util feature, and enable the feature from the crate's own dev-dependencies:
[dependencies]
lore-macro = { workspace = true }
[features]
test-util = []
[dev-dependencies]
lore-foo = { workspace = true, features = ["test-util"] }
Mark the item with #[lore_macro::test_pub]. Built with test-util, the item is pub, and so are a struct's fields. Built without it, the item is exactly as written. It applies to functions and methods, structs, enums, constants, static items, type aliases, and traits. Put it first among the item's attributes, above any #[derive]:
// lore-storage/src/local/immutable_store/info.rs
#[lore_macro::test_pub]
const INFO_MAGIC: u32 = u32::from_le_bytes(*b"IS_I");
#[lore_macro::test_pub]
#[repr(C)]
#[derive(Debug, IntoBytes, FromBytes, Immutable)]
pub struct ImmutableStoreInfo {
magic: u32,
version: u32,
pub next_group_index_to_migrate_oodle: i32,
}
When a test needs read access or a wrapper rather than a wider item, add one gated test_util child module beside the private items instead. A child module sees its parent's private items, and an inherent impl may live anywhere in the crate, so accessors, constructors, and wrappers all fit in it and the production code stays as it is:
// lore-credential/src/token_store.rs
#[cfg(feature = "test-util")]
pub mod test_util {
use super::IdentityToken;
use super::TokenStoreError;
impl IdentityToken {
pub fn user_id(&self) -> &str {
&self.user_id
}
}
pub fn seal_token(key: &[u8], user_token: &str) -> Result<String, TokenStoreError> {
super::seal_token(key, user_token)
}
}
To make a private module public, switch its declaration. The attribute cannot do this, because it does not apply to a module declared in its own file. A module that already has a cfg keeps it in both declarations:
#[cfg(not(feature = "test-util"))]
mod internals;
#[cfg(feature = "test-util")]
pub mod internals;
#[cfg(all(feature = "oodle", not(feature = "test-util")))]
mod oodle_migration;
#[cfg(all(feature = "oodle", feature = "test-util"))]
pub mod oodle_migration;
cfg(test) is set only when cargo compiles the crate itself as a test. The tests in tests/unit/ link the library as built normally, so a #[cfg(test)] item or a #[cfg_attr(test, ...)] in library code is not there for them. When moving inline tests out, change each one to feature = "test-util".
Used this way the feature adds access and nothing else: wider visibility, accessors, constructors, and wrappers over code that already exists. Helper code stays in tests/unit/ and its dependencies in [dev-dependencies]. Release builds never see the feature: cargo applies a dev-dependency's features only to builds that include the dev-dependencies. Don't make an item pub unconditionally for a test. It becomes API other crates can reach, and the compiler stops reporting it once it falls out of use.
A crate may stop or fail its own code at a test point, so that its race tests run in every unit run. Make the point a call under #[cfg(feature = "test-util")] that returns at once unless a test armed it. lore-storage's park_packfile_write and park_store_write, and lore-revision's test_util::BranchStep, are such points. Put the scheduling points that the State's node operations need under state-stress instead, as the scenarios above describe.
3. Rust async tests¶
Frameworks: tokio, mockall, async-trait
In lore-revision and the crates that depend on it, every async test of code that relies on its caller to set LORE_CONTEXT, directly or through the code it calls, runs its body in LORE_CONTEXT.scope(). The code under test then has the execution context it has in production:
#[tokio::test]
async fn test_example() {
LORE_CONTEXT
.scope(setup_test_execution(), async {
// test code
})
.await;
}
Only those crates can build an ExecutionContext, the type of the value LORE_CONTEXT carries in production, since lore-revision defines it.
Test independence¶
Tests MUST be independent and isolated. Avoid:
#[serial]— Forces sequential execution, indicating shared mutable state.- Test dependencies — Tests that rely on other tests running first.
If you find yourself needing #[serial], refactor the test to:
- Create isolated test fixtures and state per test.
- Use unique identifiers (for example, random repository names or unique temp directories).
- Mock shared resources instead of using real shared state.
// Anti-pattern: shared state requiring serial execution
#[tokio::test]
#[serial] // DON'T DO THIS
async fn test_with_shared_state() { ... }
// Preferred: isolated test with unique fixtures
#[tokio::test]
async fn test_with_isolated_state() {
let test_repo = test_store_create(); // Creates unique test repository
// Test uses only this isolated state
}
Key files:
lore-revision/tests/helper.rs—test_store_create(),setup_test_execution().lore-revision/tests/— Cross-module integration tests.lore-integration-tests/— Tests against real infrastructure, without mocking
Scratch space on disk¶
lore_base::test_util::TempDir, and TempFile for a single file, are the only
way a test asks for scratch space on disk. Both are behind lore-base's
test-util feature, which the crates that need it enable from their
dev-dependencies:
let dir = TempDir::new("my-test-"); // <temp>/my-test-A1b2C3d4
std::fs::write(dir.child("data.bin"), b"...").expect("write");
let file = TempFile::with_contents("my-test-", b"payload");
some_api(file.path());
The name carries a random suffix, so two tests — or two runs on one machine —
never share a directory, and removal happens in Drop, so it happens whether
the test passes or fails an assertion.
Do not build a path under std::env::temp_dir() by hand, and do not
remove a directory on the last line of a test body: a failing assertion panics
before reaching that line, so the run that most needs its output is the one that
leaks it.
Return the guard, never a path derived from it. A helper that ends
temp.path().to_path_buf() drops the guard on return and deletes the directory
its caller is about to read. Hand back the TempDir and let the caller hold it:
fn fixture() -> (TempDir, PathBuf) { ... } // correct
fn fixture() -> PathBuf { ... } // deletes the directory on return
Set LORE_KEEP_TEST_DATA=1 to keep the directories rather than remove them —
the Rust equivalent of the smoke tests' --keep-test-data. The prefix is all
there is to identify one afterwards, so give it the test's name wherever several
tests in a module would otherwise share it.
A test that moves the external root needs its global directory and its targets on one volume Lore verifies as local and durable, and outside any Lore working tree. It makes them in the base lore_io::test_util::verified_scratch_base finds, through verified_temp_dir in lore-revision/tests/helper.rs, or with the verified_volume marker in the smoke tests: the system temp directory where it qualifies, else the build's temp directory, else lore-test-scratch beside the outermost working tree that holds the build. The last lies outside pytest's base temp directory, so the session sweep doesn't reach it: the process that chose it removes it once empty as it exits, a Rust test binary only on Unix. Where no candidate qualifies, the test fails, naming each.
tempfile is the implementation and a dependency of lore-base only. Do not add
it to another crate: a second guard type is a second set of rules, and it does not
honour LORE_KEEP_TEST_DATA.
Polling for async state¶
Poll for a condition instead of sleeping. Fixed sleeps are flaky on slow CI, wasteful on fast machines, and opaque — a failure does not say whether the timeout was wrong or the code is broken.
// BAD
sleep(Duration::from_millis(500)).await;
// GOOD
wait_for_condition(|| async { manager.session_count() == 2 }, Duration::from_secs(5))
.await
.expect("sessions should appear within 5 seconds");
Fixed sleeps are acceptable only for time-based behavior such as TTL expiry, or pauses under 20ms to let a spawned task start.
4. Smoke tests (scripts/test/)¶
Framework: pytest
Requirement: All Lore CLI commands must have smoke test coverage. When adding a new command, add corresponding tests to scripts/test/.
Key files¶
| File | Purpose |
|---|---|
conftest.py |
Fixtures and server management |
lore.py |
Lore wrapper class for the CLI |
error_types.py |
Exception mapping from CLI output |
Fixtures¶
new_lore_repo— Creates a new test repository.scratch_dir— Hands out a path beside the repositories for the test to create something at: a shared store, a path to clone into, a moved instance.lore_executable_path— Path to the Lore client binary.auto_lore_local_server— Auto starts the server for the session.
Test data is removed as the run goes¶
A full run writes about ten gigabytes, so nothing is kept once it is no longer needed. Cleanup is in two layers:
- Per test.
new_lore_reporemoves every repository it handed out and every repository those went on to clone;scratch_dirremoves every path it handed out;global_dir_nameremoves the isolated global config and the shared stores under it. All of this runs whether the test passed or failed. A server built inside a test or a class fixture throughgenerate_server_configis removed at that same scope, after the fixture that launched it has stopped it. An autouse fixture removes the per-testtmp_path, which pytest itself only removes under thefailedpolicy and then only for tests that passed. - Per session.
_SessionCleanupinlore_server.pyempties basetemp once every worker has finished, taking the session server's root and anything a per-test cleanup could not.
A test that creates files outside its repository must take scratch_dir and
create them at a path it hands out. Anything written straight to
tmp_path_factory.getbasetemp() survives the test that made it and is only
caught by the session sweep, which is a backstop, not the guard.
Removal is best effort and never fails a test: a locked file is logged and left to the sweep.
Pass --keep-test-data to keep everything on disk — repositories, stores,
server roots and the server log — when investigating a failure.
Usage¶
@pytest.mark.smoke
def test_commit(new_lore_repo):
repo: Lore = new_lore_repo()
repo.stage(offline=True)
repo.commit("Test commit", offline=True)
repo.push()
Running with uv¶
Tests require Python 3.13 or 3.14. Use uv to manage dependencies and run tests:
# Install dependencies
uv sync
# Run all smoke tests with local server
uv run pytest scripts/test/ --lore-client-binary=release --lore-server-binary=release
# Run only tests marked as smoke
uv run pytest scripts/test/ -m smoke
# Run smoke tests on a machine without the EpicVFS driver (skips SWFS tests)
uv run pytest scripts/test/ -m "smoke and not swfs"
# Run tests in parallel (uses pytest-xdist)
uv run pytest scripts/test/ -n auto
# Against external server
uv run pytest scripts/test/ --disable-local-server --lore-remote-url=lore://host:port
Command-line options¶
| Option | Default | Description |
|---|---|---|
--lore-client-binary |
release |
Path or "release"/"debug" |
--lore-server-binary |
release |
Path or "release"/"debug" |
--lore-remote-url |
lore://127.0.0.1:41338 |
Server address |
--disable-local-server |
false |
Use external server |
--disable-auto-server |
false |
Don't auto start the server |
--keep-test-data |
false |
Leave repositories, stores and server roots on disk |
Running the SWFS tests¶
The mounting tests in test_swfs.py carry the swfs marker and run on Windows,
where they need two preconditions, the second of which is arranged outside the
harness and not visible from it:
- The SWFS library, which every x86-64 Windows build links:
swfs_d.libfor adevprofile build andswfs.libfor any other. It is read fromlore-revision/native/swfs/win64unlessSWFS_LIB_DIRnames another directory. - The
epicvfsfilesystem driver running. It installs fromEpicVFS.exeand is demand-start, and the SWFS library does not start it: start it from an elevated session withsc start epicvfs.sc query epicvfsreportingSTOPPEDmeans the next mount will hang, as the next paragraph describes.
Without the driver a mount does not fail, it hangs: the SWFS library parks the
service process, so the client relaying to it blocks until the per-test timeout
kills the worker. A machine without the driver should deselect the tests with
-m "smoke and not swfs".
The Rust tests that mount SWFS, such as lore-revision/tests/swfs_freeze.rs,
compile for Windows x86-64 only and have the same two preconditions. A machine
without the driver sets LORE_TEST_NO_SWFS=1, and they return at once, passing
without testing anything. A new Rust test that mounts SWFS must check
that variable first.
Running the FUSE tests¶
The tests that mount FUSE run on Linux, with /dev/fuse open to the user running
them and fusermount3 on PATH. Without either, the smoke tests in
test_fuse.py skip, and the Rust tests return at once, passing without testing
anything, as they do when LORE_TEST_SKIP_FUSE is set.
A Rust test that mounts FUSE is declared in a module named needs_fuse, in one of
the packages lore_fuse::test_support::FUSE_TEST_PACKAGES names, and starts with
lore_fuse::skip_without_fuse!(), which panics in a test declared anywhere else.
The filter needs_fuse:: then selects every test that mounts, so CI runs them
alone in a container that has /dev/fuse:
The FUSE tests of lore-integration-tests also need its integration_tests
feature and the services its integration tests use.
A test that writes through a shared mapping of a mount its own process serves
writes from a child process. In the test's process, the page fault waits for a
WRITE the process's own session serves while it holds the mapping's lock, and a
fork elsewhere in the process meanwhile keeps the session's threads from taking
a page fault, so the WRITE is never served.
Running the machine server's container tests¶
The tests in test_uds_containers.py run a machine server with a container on
each of its sockets. They run on Linux only, and skip unless both of these hold:
dockeris onPATHand reaches the Docker daemon as the user running the tests.LORE_UDS_CONTAINER_IMAGEnames a Docker image present locally, such asubuntu:26.04. The suite does not pull it. The containers run theloreanduds-benchbinaries built on the host from a read-only mount, so the image must be able to run them.
The tests also need the uds-bench example of lore-server, and fail without
it. The example builds only with the crate's uds-bench feature, so test and
clippy runs leave it out. The tests take it from examples/uds-bench beside the
client binary, where Cargo builds it, or from the path LORE_UDS_BENCH_BINARY
names. LORE_UDS_CONTAINERS
sets how many containers reach the machine server through LORE_UDS_SOCKET, 8
by default and at least 2. One more container mounts a socket without the
variable.
cargo build --release -p lore-client -p lore-server --bin lore --bin loreserver
cargo build --release -p lore-server --features uds-bench --example uds-bench
LORE_UDS_CONTAINER_IMAGE=ubuntu:26.04 uv run pytest scripts/test/test_uds_containers.py \
--lore-client-binary=release --lore-server-binary=release
The tests carry the slow marker and share one rig of servers and containers,
which their xdist_group keeps on one worker.
Running every test through one service¶
LORE_TEST_SHARED_SERVICE=1 starts one service from the build under test before
the run and stops it when the run ends. Every command of every test then runs in
that service, except in the tests that manage a service of their own through
lore_service_runner, which keep theirs, and in the tests marked
runs_in_process(reason), whose commands stay in their own process. The
executable the relayed commands name for starting a service doesn't exist, so a
service that stops partway fails the tests that follow instead of being replaced,
the commands of a virtual instance included. Naming none would not do that: a
virtual instance's commands start a service from the lore that ran them.
The service listens on a socket named for the run, with a global directory of its own, so several runs proceed side by side. A run ended by Ctrl+C, SIGTERM or SIGHUP stops it as a finished run does. On Linux the kernel stops it when the run is killed outright, as it does every service and server a test or an xdist worker starts when that process ends. The server the workers share outlives the worker that launched it, which can finish first: the run's cleanups stop it, and on Linux so does the run's main process ending.
LORE_TEST_SERVICE_SOCKET names the socket of a service started some other way,
which the run then uses in place of starting one:
service_dir=$(mktemp -d)
LORE_SERVICE_SOCKET=lore_service-smoke LORE_GLOBAL_PATH=$service_dir \
LORE_AUTH_PATH=$service_dir LORE_AUTH_STORE=fallback \
target/release/lore service run &
LORE_TEST_SERVICE_SOCKET=lore_service-smoke uv run pytest scripts/test/ -m smoke -n 4
Each call carries the test's LORE_GLOBAL_PATH, LORE_AUTH_PATH and
LORE_AUTH_STORE, which the service reads in place of its own, so the tests
stay isolated from each other. No process in a run uses the machine's token
store or the OS keyring: each test keeps its token store and key in its own
directory, and each worker stands in for the machine's settings and credentials
with a temporary directory of its own, so runs side by side share neither. A
call that leaves LORE_AUTH_STORE unset uses the secure store, never the
service's own, so the harness sets LORE_AUTH_STORE=fallback for every test
process. Outside a call the service reads its own paths, so start it as the
harness starts its shared service: with a directory of its own for both paths
and LORE_AUTH_STORE=fallback.
Running every test over virtual instances¶
LORE_TEST_VFS names a VFS that every repository a test creates or clones
through the harness takes where the test names none, so the suite runs over
virtual instances. The service mounts a virtual instance, so the run needs one:
A test that clones bare, untracked or as a dry run keeps that form, since a virtual instance has no such form. A virtual instance stays mounted past the test that made it, so the harness detaches every Lore mount below a test's directories before removing them.
A virtual instance always uses a shared store. A repository the run makes virtual,
where the test asks for no shared store, gets a store of its own beside it
(--shared-store-path <path>.store). That keeps it apart from the test's other
repositories, as the store in its own .lore did: a branch it commits to
doesn't advance in theirs.
A test that cannot run over a virtual instance keeps the VFS it names, or none,
with @pytest.mark.own_vfs("<why>"). The reason names what the test does that a
virtual instance does not: it links or layers a repository, deletes or moves an
instance's directory, reads the store in a repository's own .lore, or asserts
what a plain status reports of an ordinary working tree, where a status on a
virtual instance always scans.
Per-test timeout¶
Every test is bounded at ten minutes (timeout in pyproject.toml), and the
stack of every thread is dumped a minute before that (faulthandler_timeout).
Nothing else bounds a test: the helper runs the client with subprocess.run and
no timeout, so a client that never returns would otherwise be a run that never
returns.
A test that reaches the limit is reported as a failure and the run continues. On
Linux the test fails in place; on Windows there is no SIGALRM, so the worker is
killed and xdist reports
worker 'gwN' crashed while running <test> and replaces it. Either way the log
names the test and carries the stack it was stuck in.
Override with --timeout=0 to disable, or --timeout=<seconds> for a run that
is legitimately slower.
pytest markers¶
| Marker | Description |
|---|---|
@pytest.mark.smoke |
Smoke tests for basic functionality |
@pytest.mark.swfs |
Tests that need the EpicVFS driver, which is available only on Windows machines where it is installed. Deselect with -m "smoke and not swfs" if you don't have the driver. |
@pytest.mark.slow |
Slow running tests |
@pytest.mark.disable_auto_server |
Tests requiring the --disable-auto-server flag |
@pytest.mark.verified_volume |
Tests that move the external root: their global directory and scratch paths go on a volume Lore verifies, outside any Lore working tree, as Scratch space on disk describes |
5. Load tests¶
Lore has a load-testing suite that exercises concurrent cloning, commit, sync, lock, and compaction workloads. It runs on internal infrastructure and isn't part of the open-source repository, so its harness and scenarios aren't documented here.
6. Instruction counts¶
Wall-clock benchmarks on a shared machine vary by more than the regressions worth catching on a hot path, so gate a change to the State's node operations or the C API's revision-tree verbs on instruction counts instead. scripts/instruction-gate/gate.py <base> <change> builds every workload of state_bench and revision_tree_bench alone in each of two checkouts, counts the user-mode instructions it retires per operation on a hardware counter, and fails a workload that costs more than 0.5% over the base. It runs by hand on a physical Linux machine, since most virtual machines expose no counter. scripts/instruction-gate/README.md covers its requirements, options and output, and how to find what moved.
7. Best practices¶
- Target risk, not line count — spend test effort on business logic; leave plumbing and trivial code with few or no tests.
- Test every fix and every behavior change with a test that fails without it (see What a change tests).
- All Lore commands must have smoke tests in
scripts/test/. - Use
LORE_CONTEXT.scope()for every async Rust test inlore-revisionor a crate that depends on it, of code that relies on its caller to setLORE_CONTEXT. - Keep tests independent — Avoid
#[serial]and test dependencies; use isolated fixtures. - Poll instead of sleeping for async state; reserve fixed sleeps for time-based behavior or sub-20ms task startup.
- Use the
new_lore_repofixture for smoke tests, andscratch_dirfor anything a test creates outside its repository — both remove what they hand out. - Mark tests with
@pytest.mark.smokefor smoke test runs. - Use
offline=Truefor operations that don't need the server. - Feature-gate integration tests that require external dependencies.
- Put Rust unit tests in
tests/unit/, with[lib] test = false. Give a test its owntests/*.rsbinary only when it needs its own process, and reach private items only through thetest-utilfeature, usually with#[lore_macro::test_pub]. - Build and run tests on a release build, one test or a full suite, unit and smoke alike (see Build profile).