linera-io/linera-protocol · error · anyhow::Error
tests failed
Error message
tests failed
What it means
Project::test runs `cargo test --target <CURRENT_PLATFORM>` inside the project directory and surfaces any non-zero exit as 'tests failed'. This is the application's own Rust test suite failing, not Linera's; the wrapper itself carries no diagnostics, so cargo's output must be read separately.
Source
Thrown at linera-service/src/project.rs:111
})?;
ensure!(
root.join("Cargo.toml").exists(),
"No Cargo.toml found at {}. \
The path must point to a Rust project directory.",
root.display()
);
Ok(Self { root })
}
/// Runs the unit and integration tests of an application.
pub fn test(&self) -> Result<()> {
let tests = Command::new("cargo")
.arg("test")
.args(["--target", CURRENT_PLATFORM])
.current_dir(&self.root)
.spawn()?
.wait()?;
ensure!(tests.success(), "tests failed");
Ok(())
}
/// Finds the workspace for a given crate. If the workspace
/// does not exist, returns the path of the crate.
fn workspace_root(&self) -> Result<&Path> {
let mut current_path = self.root.as_path();
loop {
let toml_path = current_path.join("Cargo.toml");
if toml_path.exists() {
let toml = Manifest::from_path(toml_path)?;
if toml.workspace.is_some() {
return Ok(current_path);
}
}
match current_path.parent() {
None => {
break;View on GitHub (pinned to 6c226ddcb3)
Solutions
- Run `cargo test` in the project directory yourself to see the full failing output
- Fix the failing assertions or test code
- If cargo complains about the target, install it: `rustup target add <CURRENT_PLATFORM>`
Example fix
# before $ linera project test . error: tests failed # after $ cd my-dapp && cargo test # see full failure output, fix the tests $ cd .. && linera project test .
Defensive patterns
Strategy: try-catch
Try / catch
Wrap Project::test and, on the 'tests failed' anyhow error, re-run `cargo test` in the project directory to surface the failing test names — the wrapper propagates no cargo output, so the diagnostics must come from your own re-run.
Prevention
- Run cargo test locally before linera project test or publish
- Keep application tests hermetic (no network, no chain state)
- Install the host rustup target in CI images
When it happens
Trigger: `linera project test <path>` where cargo test exits non-zero: failing assertions, compile errors in test code, or the CURRENT_PLATFORM rustup target not being installed.
Common situations: Broken application logic after edits; tests depending on external network or chain state; CI images missing the host platform target.
Related errors
- No Cargo.toml found at {}. The path must point to a Rust pro
- build failed
- No wallet found at {}. Please initialize a wallet first, e.g
- Project name {name} should not contain path-separators
- Directory {} already exists
AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22).
Data as JSON: /api/errors/7e906ab007d6e441.
Report an issue: GitHub.