Skip to content

Commit

Permalink
Merge pull request #234 from FabijanC/patch-1
Browse files Browse the repository at this point in the history
Update 2021-02-27-delete-cargo-integration-tests.dj
  • Loading branch information
matklad authored Dec 12, 2024
2 parents 2695ba8 + adf08af commit 9fbe13d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions content/posts/2021-02-27-delete-cargo-integration-tests.dj
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ To build unit tests, Cargo runs
rustc --test src/lib.rs
```

Rustc then compiles the library with `--cfg test`.
Then `rustc` compiles the library with `--cfg test`.
It also injects a generated `fn main()`, which invokes all functions annotated with `#[test]`.
The result is an executable file which, when run subsequently by Cargo, executes the tests.

Integration tests are build differently.
Integration tests are built differently.
First, Cargo uses `rustc` to compile the library as usual, _without_ `--cfg test`:

```
Expand Down Expand Up @@ -170,7 +170,7 @@ mod tests {
}
```

This way, when you modify just the tests, the cargo is smart to not recompile the library crate.
This way, when you modify just the tests, Cargo is smart to not recompile the library crate.
It knows that the contents of `tests.rs` only affects compilation when `--test` is passed to rustc.
Learned this one from [@petrochenkov](https://github.com/petrochenkov), thanks!

Expand Down

0 comments on commit 9fbe13d

Please sign in to comment.