run-rust-tests

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Rust Test Skill

Rust 测试技能

Run Rust tests after making changes to verify correctness.
修改代码后运行Rust测试以验证正确性。

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
  • 无参数:分析变更并仅对受影响的crate运行测试
  • all
    :运行所有Rust测试
  • <crate>
    :对指定crate运行测试(例如:
    /run-rust-tests hyperloglog
  • <crate> <test>
    :运行crate中的指定测试(例如:
    /run-rust-tests hyperloglog test_merge
提供的参数:
$ARGUMENTS

Usage

使用方法

Run this skill after modifying Rust code to ensure tests pass.
修改Rust代码后运行此技能,确保测试通过。

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
  1. 检查上述提供的参数:
    • 如果参数为空,确定受影响的crate:
      1. 使用
        git status
        git diff --name-only
        检查
        src/redisearch_rs/
        中哪些文件被修改
      2. 将每个修改的文件映射到对应的crate(即
        src/redisearch_rs/
        下的直接目录名,例如
        src/redisearch_rs/hyperloglog/src/lib.rs
        hyperloglog
      3. 对每个受影响的crate运行测试:
        bash
        cd src/redisearch_rs && cargo nextest run -p <crate1> -p <crate2> ...
      4. 如果
        src/redisearch_rs/
        中没有Rust文件被修改,或者无法确定受影响的crate,则运行所有测试
    • 如果提供了
      all
      ,运行所有Rust测试:
      bash
      cd src/redisearch_rs && cargo nextest run
    • 如果提供了crate名称,对该crate运行测试:
      bash
      cd src/redisearch_rs && cargo nextest run -p <crate_name>
    • 如果同时提供了crate和测试名称,运行指定测试:
      bash
      cd src/redisearch_rs && cargo nextest run -p <crate_name> <test_name>
  2. 如果测试失败:
    • 仔细阅读错误输出
    • 修复失败的测试或导致失败的代码
    • 重新运行测试以验证修复结果

Common Test Commands

常用测试命令

bash
undefined
bash
undefined

Test specific crate

测试指定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
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>
cd src/redisearch_rs && cargo nextest run -p <crate_name> <test_name>

Run tests under miri (for undefined behavior detection)

在miri下运行测试(用于检测未定义行为)

cd src/redisearch_rs && cargo +nightly miri test
undefined
cd src/redisearch_rs && cargo +nightly miri test
undefined