Skip to main content

Testing

RepX testing is fully integrated into the Nix flake. All tests run in isolated NixOS virtual machines to ensure reproducibility and proper isolation.

Running Tests

Full Test Suite

Run all checks:

nix flake check

Individual Checks

Build and run a specific check:

nix build .#checks.x86_64-linux.<check-name>

Check Categories

Lint Checks

Static analysis and code quality:

CheckDescription
clippyRust linter warnings
formattingCode style validation
macheteUnused Cargo dependencies
deadnixDead Nix code
statixNix anti-patterns
shellcheckShell script analysis
shebangScript interpreter validation

Rust Unit Tests

Rust tests run inside NixOS VMs with the reference Lab available:

CheckScope
rs-unitLibrary and binary unit tests
rs-integrationEnd-to-end, component, regression tests
rs-executorExecutor crate tests
rs-client-testsClient crate tests (wave scheduler, sync)
rs-bwrapBubblewrap runtime tests
rs-gcGarbage collection tests
rs-containersDocker and Podman tests

Example:

nix build .#checks.x86_64-linux.rs-unit
nix build .#checks.x86_64-linux.rs-executor

Python Tests

nix build .#checks.x86_64-linux.repx-py-tests

Nix Library Tests

Validation of the repx-lib Nix functions:

CheckDescription
integrationFull Lab build validation
invalidationCache invalidation behavior
paramsParameter handling
params_listParameter list processing
pipeline_logicPipeline DAG construction
dynamic_params_validationDynamic parameter validation
pass_validDependency check (valid case)
pass_complexComplex dependency scenarios
fail_missingMissing dependency detection

End-to-End Tests

Full execution tests in NixOS VMs:

CheckDescription
e2e-localLocal bwrap execution
e2e-impureImpure mode with host mounts
e2e-impure-dockerDocker container execution
e2e-impure-podmanPodman container execution
e2e-mount-pathsExplicit mount path configuration
e2e-mount-paths-dockerDocker with mount paths
e2e-mount-paths-podmanPodman with mount paths
e2e-remote-localSSH target, local scheduler
e2e-remote-slurmSSH target, SLURM scheduler
incremental-syncIncremental image synchronization
non-nixos-standaloneExecution on non-NixOS host
non-nixos-remoteRemote execution to non-NixOS target
static-analysisStatic binary validation

Example:

nix build .#checks.x86_64-linux.e2e-local
nix build .#checks.x86_64-linux.incremental-sync

Development Testing

For rapid iteration during development, use the dev shell:

nix develop
cargo test --workspace
cargo test -p repx-executor

Note: Some tests require REFERENCE_LAB_PATH to be set. The Nix checks handle this automatically.

Test Infrastructure

repx-test-utils Crate

Shared test harness for Rust integration tests:

use repx_test_utils::harness::TestContext;

#[test]
fn test_execution() {
let ctx = TestContext::new();
// Isolated environment with:
// - Temporary XDG directories
// - Pre-staged reference Lab
// - Configured repx settings
}

Reference Lab

The reference-lab package provides a pre-built Lab for testing:

nix build .#reference-lab

Tests automatically use this Lab via REFERENCE_LAB_PATH.

Writing Tests

Rust Guidelines

  1. Unit tests: mod tests blocks in source files
  2. Integration tests: tests/ directory in crate root
  3. Use TestContext for tests requiring Lab artifacts
  4. Use #[tokio::test] for async tests

Adding a New Check

  1. Create check definition in nix/checks/
  2. Import in nix/checks.nix
  3. The check will be available as checks.<system>.<name>