Skip to main content

run_cargo_test

Function run_cargo_test 

Source
pub fn run_cargo_test(
    cwd: &Path,
    package: Option<&str>,
    feature: &str,
    profile_dir: &Path,
    test_filter: Option<&str>,
) -> Result<()>
Expand description

Run cargo build-sbf -p <pkg> from the workspace root. This produces the post-linked .so + sibling keypair under target/deploy/ that solana-sbpf can parse — the raw cargo build --target sbpf-solana-solana artifact in target/sbpf-solana-solana/release/ is missing relocation metadata our debugger needs.

Skipping this step is the most common cause of “the debugger sees the program but the disasm pane is empty”. We surface that explicitly via the target/deploy/ check so users know what to fix. Run cargo test --features <feature> -p <pkg> from cwd, with the profile-mode env vars set the same way the Anchor.toml flow sets them.

Inherits stdio so the user sees test output exactly as they would with a direct cargo test. Returns an error on non-zero exit so we don’t drop into the TUI on a build/test failure (would otherwise confuse users about why nothing’s there).