home / skills / redisearch / redisearch / run-rust-tests

run-rust-tests skill

/.skills/run-rust-tests

This skill analyzes Rust changes and runs affected crate tests to verify correctness after edits.

npx playbooks add skill redisearch/redisearch --skill run-rust-tests

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.2 KB
---
name: run-rust-tests
description: Run Rust tests after making changes to verify correctness
---

# Rust Test Skill

Run Rust tests after making changes to verify correctness.

## Arguments
- No arguments: Analyze changes and run tests for affected crates only
- `all`: Run all Rust tests
- `<crate>`: Run tests for specific crate (e.g., `/run-rust-tests hyperloglog`)
- `<crate> <test>`: Run specific test in crate (e.g., `/run-rust-tests hyperloglog test_merge`)

Arguments provided: `$ARGUMENTS`

## Usage
Run this skill after modifying Rust code to ensure tests pass.

## Instructions

1. Check the arguments provided above:
   - If arguments are empty, determine affected crates:
     1. Check which files were modified in `src/redisearch_rs/` using `git status` and `git diff --name-only`
     2. Map each modified file to its crate (the directory name directly under `src/redisearch_rs/`, e.g., `src/redisearch_rs/hyperloglog/src/lib.rs` → `hyperloglog`)
     3. Run tests for each affected crate:
        ```bash
        cd src/redisearch_rs && cargo nextest run -p <crate1> -p <crate2> ...
        ```
     4. If no Rust files were modified in `src/redisearch_rs/`, or if you cannot determine affected crates, run all tests
   - If `all` is provided, run all Rust tests:
     ```bash
     cd src/redisearch_rs && cargo nextest run
     ```
   - If a crate name is provided, run tests for that crate:
     ```bash
     cd src/redisearch_rs && cargo nextest run -p <crate_name>
     ```
   - If both crate and test name are provided, run the specific test:
     ```bash
     cd src/redisearch_rs && cargo nextest run -p <crate_name> <test_name>
     ```
2. If tests fail:
   - Read the error output carefully
   - Fix the failing tests or the code causing failures
   - Re-run tests to verify the fix

## Common Test Commands

```bash
# Test specific crate
cd src/redisearch_rs && cargo nextest run -p hyperloglog
cd src/redisearch_rs && cargo nextest run -p inverted_index
cd src/redisearch_rs && cargo nextest run -p trie_rs

# Run a specific test
cd src/redisearch_rs && cargo nextest run -p <crate_name> <test_name>

# Run tests under miri (for undefined behavior detection)
cd src/redisearch_rs && cargo +nightly miri test
```

Overview

This skill runs Rust tests after code changes to verify correctness and prevent regressions. It targets the Rust crates under src/redisearch_rs, choosing either affected crates, a specific crate, or all tests based on provided arguments. Use it to quickly validate changes before merging or releasing.

How this skill works

When invoked with no arguments, the skill inspects git changes in src/redisearch_rs to map modified files to crate directories and runs tests only for those crates using cargo nextest. With the argument all it runs the full test suite; with a crate name it runs that crate; with a crate and test name it runs a single test. Failures are reported from cargo nextest so you can fix code and re-run.

When to use it

  • After modifying Rust files under src/redisearch_rs to validate the affected crates
  • Before opening a pull request to ensure tests pass locally
  • When diagnosing intermittent or new test failures in a specific crate
  • To run the full Rust test suite before a release or major merge
  • When you need to run a single test during debugging

Best practices

  • Run with no arguments during development so only affected crates are tested and feedback is fast
  • Use cargo nextest for reliable, parallel test runs and better diagnostics
  • If the skill cannot determine affected crates or you changed build/config, run with all
  • Inspect nextest output closely; rerun failing tests locally to reproduce and debug
  • Use crate+test invocation to iterate quickly on a failing unit or integration test

Example use cases

  • No arguments: run tests for crates changed by your current git diff to get quick validation
  • all: run the entire Rust test suite before tagging a release
  • <crate>: validate a single crate after focused refactoring, e.g., run-rust-tests hyperloglog
  • <crate> <test>: reproduce and iterate on a failing test, e.g., run-rust-tests hyperloglog test_merge
  • Use nightly + miri for undefined-behavior checks when investigating unsafe code

FAQ

What happens if no Rust files in src/redisearch_rs were modified?

If no modified Rust files are detected or the mapping cannot be determined, the skill defaults to running all tests to ensure coverage.

Which test runner is used?

Tests are executed with cargo nextest by default; you can also use cargo +nightly miri test manually for UB detection.