cargo-tes

Crates.iocargo-tes
lib.rscargo-tes
version0.1.3
created_at2026-01-19 21:31:46.774032+00
updated_at2026-01-22 04:16:44.049593+00
descriptionA cargo subcommand to run cargo test and output filtered test failure messages as a JSON array
homepage
repositoryhttps://github.com/permissionlessweb/cargo-chec
max_upload_size
id2055400
size19,486
Hard-Nett (hard-nett)

documentation

README

Cargo Tes

A cargo subcommand that wraps cargo test, filters test failures, and outputs them as a JSON array of strings. Perfect for minimizing character/token count during agentic LLM sessions.

Quick Start

  1. Install globally: cargo install cargo-tes
  2. Run in any Rust project: cargo tes

Outputs a JSON array like ["Test failed: test_name (exec_time: 0.001s) - failure message", "Suite failed: passed 1, failed 2 (exec_time: 0.005s)"]. All tests pass? [].

Installation

cargo install cargo-tes

Requires Rust and Cargo.

Features

  • Full cargo test support: All cargo test flags pass through (--release, --package, --all-targets, etc.)
  • Smart Filtering: Only shows test failures (failed tests and failed suites), ignores passing/ignored tests
  • Structured Output: JSON array of strings for easy parsing
  • Flexible Input: Supports files, stdin, or default cargo test
  • Fast & Lean: Minimal dependencies (clap, serde_json)

Usage

Default: Run cargo test

cd your-rust-project
cargo tes
# Output: ["Test failed: tests::failing_test (exec_time: 0.000s) - thread 'tests::failing_test' panicked at src/lib.rs:10:9: assertion failed"]

With cargo test flags

All cargo test flags are supported:

# Test in release mode
cargo tes --release

# Test a specific package
cargo tes -p my-package

# Test all targets
cargo tes --all-targets

# Combine flags
cargo tes --release --all-targets -p my-package

Custom Input

Parse existing cargo test output instead of running cargo test:

# From file
cargo tes --input test_output.json

# From stdin
cargo test --message-format=json -- -Z unstable-options --format=json | cargo tes --input -

Output Format

JSON array of strings:

[
  "Test failed: tests::test_failing (exec_time: 0.000s) - thread 'tests::test_failing' panicked at src/lib.rs:12:9: assertion `left == right` failed left: 4 right: 5",
  "Suite failed: passed 5, failed 1 (exec_time: 0.003s)"
]

Empty on no failures: [].

Troubleshooting

  • Command not found? Run cargo install cargo-tes.
  • No output? All tests pass or are ignored.
  • Invalid JSON? If using custom input, ensure valid NDJSON from cargo test.

Benchmarks

============================================
Benchmark: cargo test (JSON) vs cargo tes
============================================

Building cargo-tes...
Build complete.

Running cargo test --message-format=json -- -Z unstable-options --format=json...
  Time: 0m0.289s
  Output: 161502 characters, 73 lines

Running cargo tes...
  Time: 0m0.326s
  Output: 10515 characters, 1 lines

============================================
Results Summary
============================================

cargo test --message-format=json -- -Z unstable-options --format=json:
  Time: 0m0.289s
  Characters: 161502
  Lines: 73

cargo tes:
  Time: 0m0.326s
  Characters: 10515
  Lines: 1
  Character savings: 93.4%

Contributing

Open issues/PRs on GitHub. Built for the Rust ecosystem.

Releasing

Use the provided Justfile for release tasks:

# Run all checks
just check

# Dry-run publish
just dry-run

# Full release
just release

Requires just (install via cargo install just).


For AI Agents: Workspace Specifications

This section provides structured details for AI tools to understand and interact with the codebase.

Project Structure

  • Source Code: src/main.rs (single-file binary)
  • Configuration: Cargo.toml (dependencies and metadata)
  • Scripts: ../scripts/ (shared sh scripts for release tasks)
  • Justfile: ../Justfile (shared command runner for release)
  • Build Artifacts: target/ (generated by Cargo)

Dependencies

  • clap: CLI argument parsing with cargo subcommand support
  • serde_json: JSON parsing and serialization

Build Commands

  • Build: cargo build --release -p cargo-testarget/release/cargo-tes
  • Lint: cargo clippy -p cargo-tes
  • Format: cargo fmt -p cargo-tes
  • Test: cargo test -p cargo-tes
  • Publish: cargo publish -p cargo-tes

Runtime Behavior

  • Entry Point: main() in src/main.rs
  • Input: If no --input, runs cargo test --message-format=json [args] -- -Z unstable-options --format=json
  • Filtering: Failed tests (type: "test", event: "failed") and failed suites (type: "suite", event: "failed") only
  • Output: JSON array of formatted failure strings to stdout

Code Style

  • Idiomatic Rust with ? operator and iterator chains
  • Edition 2021, rustfmt-compliant
Commit count: 29

cargo fmt