Skip to main content

Module test_support

Module test_support 

Source
Expand description

Shared test-only utilities.

Multiple modules’ tests mutate process-global environment variables (HOME, SHINE_CONFIG_DIR, SHINE_PRESETS) to control config/preset resolution. A single crate-wide lock serialises these mutations so tests in different modules don’t race on the shared process environment when cargo test runs unit tests in parallel.

Structs§

AdminCategoryTestLockGuard
Some embedded app categories (e.g. docker-engine) install to a real, absolute system path (/etc/docker/daemon.json) rather than one scoped under the test’s temporary HOME. cargo nextest runs each test in its own OS process, so env_lock() — a single-process Mutex — cannot prevent two such test processes from racing on that one real, shared file. Tests that install/uninstall the full embedded category set must hold this cross-process lock for their entire body.

Functions§

admin_category_test_lock
env_lock
make_temp_dir
Creates and returns a uniquely-named temp directory under the OS temp dir.
restore_current_dir
Restores the process’s current directory, for tests that temporarily set_current_dir to exercise relative-path resolution.
test_config
A Config rooted at dir, for tests that don’t need a separate home subdirectory. config::test_util::config_in is a distinct homed variant (it additionally roots home_dir under dir.join("home")) and stays separate from this one.