Rust tests.
Guided by analysis.

Give language models the paths and context behind your Rust code. PALM generates test candidates, repairs compilation errors, and measures the results.

Follow a path into a test.

Source

src/lib.rs
pub fn classify(value: i32) -> i32 {
    if support::positive(value) {
        1
    } else {
        0
    }
}
View the source

Extracted paths

support::positive(value) The two branches of classify A true condition returns 1; a false condition returns 0. true return 1 false return 0

One condition chain per path.

Test assertion

Selected condition true

assert_eq!(
    classify(2),
    1
);

Expected return 1

Assertion excerpt from a fixed local model response.

See the context behind this functionpositive → threshold
pub fn positive(value: i32) -> bool {
    threshold(value)
}

fn threshold(value: i32) -> bool {
    // body omitted in the extracted context
}

A function has dependencies.

PALM supplies related code alongside the focal function. This extracted-context excerpt includes positive; the body of threshold is omitted.

In the original source, threshold checks value > 0.

Illustration of the minimal offline fixture, using fixed local responses. This page does not execute Rust or call a model.

Open source · MIT

Analysis and generation,
working together.

Representative paths tell the model what to exercise. Code context tells it what the function depends on. The Rust toolchain checks what comes back.

Rust package

Your source code

Path constraints

Representative paths

Code context

Calls & types

Generate tests

LLM + analysis

Compile

Check each candidate

Repair & retry

LLM + diagnostics

On compiler errors

Run & measure

Test results · Coverage

After compilation passes
Analysis guides generationCompiler feedback guides repair

Inspect outcomes per function, with test code excluded from coverage.

Explore the architecture

A compiler error becomes a concrete repair.

A separate fixture example starts with the wrong argument type. Compiler feedback guides a correction, then PALM checks the candidate again.

Expected i32.
Found &str.

The argument "bad" does not match the function signature.

"bad"2
Source · nested::double
pub fn double(value: i32) -> i32 { value * 2 }

Before repair

Compile error
assert_eq!(double("bad"), 4);

After repair

Compiles
assert_eq!(double(2), 4);
Passes the fixture check

The corrected input produces the expected value.

Fixed-response example from the offline validation script. Excerpts omit test wrappers and helper assertions.

Repair handles compilation errors. Assertion failures and candidate timeouts remain failed outcomes.

Start small.
See the whole pipeline.

Run the minimal fixture through analysis, generation, repair, execution, and coverage. No model credentials needed.

First install the prerequisites: Git, Rust and a C linker, Python 3.9+, the pinned nightly, and cargo-llvm-cov. Downloads may need network access.

Run from your terminal
git clone https://github.com/cppbear/PALM.git
cd PALM
cargo build --workspace --locked
python3 scripts/check_minimal.py
Expected completion

Minimal analysis/generation/repair/coverage checks passed.

Then try your own package.

Install the tools, configure a model, and begin with a few functions and a request budget. Preprocessing changes source and tests; use a fresh working copy.

Follow a bounded example

Know where it fits.

A few boundaries to check
before your first run.

Full scope and limitations
One Cargo package
Ordinary lib/bin targets, including custom names and entry files. The complete workflow does not support multi-package workspaces.
Unit & integration tests
Unit tests use the recorded target. Function-level integration tests require a library and check external access.
The active build configuration
Shared lib/bin definitions prefer lib. Analysis does not explore every binary variant or feature combination.
Pinned tools
nightly-2025-03-19 and cargo-llvm-cov 0.6.16. Exercised on Linux CI and macOS Apple Silicon; Windows has not been validated.

Built on research.
Open for exploration.

PALM: Synergizing Program Analysis and LLMs to Enhance Rust Unit Test Coverage

Bei Chu, Yang Feng, Kui Liu, Hange Shi, Zifan Nan, Zhaoqiang Guo, and Baowen Xu

ASE 2025

This maintained implementation includes changes made after the paper’s experiments. The poster and presentation describe those experiments. Material revision notes