这是indexloc提供的服务,不要输入任何密码
Skip to content

chore: add unit test coverage reporter #10641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jul 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ rustflags = [
"-Clink-arg=-fuse-ld=lld",
]

[alias]
coverage = "run --bin coverage"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ tests_output/
vendor/
/out/
coverage/
!crates/coverage/

*.tsbuildinfo
.eslintcache
Expand Down
26 changes: 23 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
Thank you for your interest in contributing to Turborepo!

- [General dependencies](#general-dependencies)
- [Optional dependencies](#optional-dependencies)
- [Optional dependencies](#optional-dependencies)
- [Structure of the repository](#structure-of-the-repository)
- [Building Turborepo](#building-turborepo)
- [TLS implementation](#tls-implementation)
- [TLS Implementation](#tls-implementation)
- [Running tests](#running-tests)
- [Manually testing `turbo`](#manually-testing-turbo)
- [Repositories to test with](#repositories-to-test-with)
- [Debugging tips](#debugging-tips)
- [Links in error messages](#links-in-error-messages)
- [Verbose logging](#verbose-logging)
- [Crash logs](#crash-logs)
- [Terminal UI debugging](#terminal-ui-debugging)
Expand All @@ -17,7 +18,7 @@ Thank you for your interest in contributing to Turborepo!
- [Contributing to an existing example](#contributing-to-an-existing-example)
- [Philosophy for new examples](#philosophy-for-new-examples)
- [Designing a new example](#designing-a-new-example)
- [Testing examples](#testing-examples)
- [Testing examples](#testing-examples)

## General dependencies

Expand All @@ -36,6 +37,11 @@ You will need to have these dependencies installed on your machine to work on th
- Linux: `sudo apt update && sudo apt install jq zstd`
- Windows: `choco install jq zstandard`
- On Linux, ensure LLD (LLVM Linker) is installed, as it's not installed by default on many Linux distributions (e.g. `apt install lld`).
- For coverage reporting, install the `llvm-tools-preview` component:

```bash
rustup component add llvm-tools-preview
```

## Structure of the repository

Expand Down Expand Up @@ -78,6 +84,20 @@ Now, from the root directory, you can run:
cargo test
```

- Unit tests with coverage

```bash
cargo coverage
```

After running coverage tests, you can manually open the HTML report by navigating to the `coverage/html/index.html` file in your browser, or use the `--open` flag to automatically open it:

You can also add `--open` to your script to automatically open the file when coverage is completed.

```bash
cargo coverage -- --open
```

- A module's unit tests

```bash
Expand Down
58 changes: 52 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"crates/tower-uds",
"crates/turbo-trace",
"crates/turborepo*",
"crates/coverage",
"packages/turbo-repository/rust",
]

Expand Down
18 changes: 18 additions & 0 deletions crates/coverage/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "coverage"
version = "0.1.0"
edition = "2021"
license = "MIT"

[[bin]]
name = "coverage"
path = "src/main.rs"

[dependencies]
anyhow = "1.0"
clap = { version = "4.0", features = ["derive"] }
glob = "0.3"
serde_json = "1.0"
tracing = "0.1"
tracing-subscriber = "0.3"
which = "6.0"
Loading
Loading