#cargo-test #test-output #console #command #pretty #docs

bin+lib cargo-pretty-test

一个用于格式化 cargo 测试输出的控制台命令

7 个版本

0.2.5 2023年10月14日
0.2.4 2023年9月30日
0.1.0 2023年9月21日

#116Cargo 插件

Download history 194/week @ 2024-04-13 112/week @ 2024-04-20 127/week @ 2024-04-27 282/week @ 2024-05-04 172/week @ 2024-05-11 184/week @ 2024-05-18 79/week @ 2024-05-25 59/week @ 2024-06-01 151/week @ 2024-06-08 152/week @ 2024-06-15 151/week @ 2024-06-22 291/week @ 2024-06-29 62/week @ 2024-07-06 119/week @ 2024-07-13 41/week @ 2024-07-20 216/week @ 2024-07-27

每月下载量 465
taskrs-server 中使用

MIT 或 GPL-3.0

40KB
745

Cargo Pretty Test ✨

Testing Crates.io docs.rs

一个 Rust 命令行工具,将难看的 cargo test 输出格式化为美观的输出。

该包也可以用作库,完全解析 cargo test 的输出。

$ cargo pretty-test --workspace --no-fail-fast

Error details from `cargo test` if any ... (Omitted here)

Generated by cargo-pretty-test
├── (OK) cargo_pretty_test ... (4 tests in 0.16s: ✅ 4)
   ├── (OK) tests/golden_master_test.rs ... (1 tests in 0.00s: ✅ 1)
   │   └─ ✅ golden_master_test
   ├── (OK) tests/mocking_project.rs ... (2 tests in 0.16s: ✅ 2)
   │   ├─ ✅ snapshot_testing_for_parsed_output
   │   └─ ✅ snapshot_testing_for_pretty_output
   └── (OK) tests/parsing.rs ... (1 tests in 0.00s: ✅ 1)
       └─ ✅ parse_stderr_stdout
├── (FAIL) integration ... (10 tests in 0.00s: ✅ 6;  2; 🔕 2)
   ├── (FAIL) src/lib.rs ... (8 tests in 0.00s: ✅ 4;  2; 🔕 2)
   │   ├── submod
   │   │   ├─ 🔕 ignore
   │   │   ├─ 🔕 ignore_without_reason
   │   │   ├─ ✅ normal_test
   │   │   └── panic
   │   │       ├─ ❌ panicked
   │   │       ├─ ✅ should_panic - should panic
   │   │       ├─ ❌ should_panic_but_didnt - should panic
   │   │       └─ ✅ should_panic_without_reanson - should panic
   │   └─ ✅ works
   ├── (OK) src/main.rs ... (1 tests in 0.00s: ✅ 1)
   │   └─ ✅ from_main_rs
   └── (OK) tests/parsing.rs ... (1 tests in 0.00s: ✅ 1)
       └─ ✅ from_integration
└── (OK) Doc Tests ... (2 tests in 0.41s: ✅ 2)
    ├── (OK) cargo-pretty-test ... (1 tests in 0.20s: ✅ 1)
       └─ ✅ src/doc.rs - doc (line 3)
    └── (OK) integration ... (1 tests in 0.21s: ✅ 1)
        └─ ✅ tests/integration/src/lib.rs - doc (line 41)

Status: FAIL; total 16 tests in 0.57s: 12 passed; 2 failed; 2 ignored; 0 measured; 0 filtered out

更多截图。

使用方法

安装

cargo install cargo-pretty-test

在项目中运行

cargo pretty-test

注意:所有传递给 cargo pretty-test 的参数都将转发给 cargo test


在 CI 中作为摘要运行: 演示

      - id: pretty-test
        name: Run cargo pretty-test
        run: |
          cargo install cargo-pretty-test
          cargo pretty-test --color=always
          echo '```text' >> $GITHUB_STEP_SUMMARY
          echo "$(cargo pretty-test --color=never)" >> $GITHUB_STEP_SUMMARY
          echo '```' >> $GITHUB_STEP_SUMMARY

注意:使用 --color=always 会在 CI 运行时产生彩色文本,而使用 --color=never 则会在写入摘要之前移除 ANSI 转义序列。

致谢

依赖项

~1–11MB
~66K SLoC