Skip to content

Commit

Permalink
Merge branch 'develop' release 0.13.4
Browse files Browse the repository at this point in the history
  • Loading branch information
xd009642 committed Jun 23, 2020
2 parents ff5fcdc + 93f40aa commit 5ad0b99
Show file tree
Hide file tree
Showing 15 changed files with 193 additions and 86 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ file.

### Changed

### Removed

# [0.13.4] - 2020-06-23
### Added
- Add `--cfg=tarpaulin` to `RUSTFLAGS` this allows users to use
`#[cfg(tarpaulin)]` and `#[cfg(not(tarpaulin))]`

### Changed
- Don't run executables when `--no-run` provided
- `#[cfg(not(tarpaulin))]` blocks are ignored in source analysis

### Removed

## [0.13.3] - 2020-06-06
Expand Down
98 changes: 49 additions & 49 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-tarpaulin"
version = "0.13.3"
version = "0.13.4"
authors = ["Daniel McKenna <[email protected]>"]
description = "Cargo-Tarpaulin is a tool to determine code coverage achieved via tests"
repository = "https://github.com/xd009642/tarpaulin"
Expand Down Expand Up @@ -35,7 +35,7 @@ libc = "0.2.71"
log = "0.4.8"
memmap = "0.7.0"
nix = "0.17.0"
object = "0.19"
object = "0.20"
proc-macro2 = { version = "1.0", features = ["span-locations"] }
quick-xml = "0.18"
quote = "1.0"
Expand Down
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Below is the help-text for a thorough explanation of the flags and features
available:

```bash
cargo-tarpaulin version: 0.13.3
cargo-tarpaulin version: 0.13.4
Tool to analyse test coverage of cargo projects

USAGE:
Expand Down Expand Up @@ -215,6 +215,32 @@ fn main() {
}
```
However, the skip attribute only allows you to exclude code from coverage
it doesn't change the code present in the binaries or what tests are ran.
Because of this, `--cfg=tarpaulin` is used when building your project for
Tarpaulin allowing you to also conditionally include/exclude code from
compilation entirely. For example to have a test that isn't included in
the test binaries when built with tarpaulin and cannot be ran just do:
```Rust
#[test]
#[cfg(not(tarpaulin))]
fn big_test_not_for_tarpaulin() {
// Something that would be very slow in tarpaulin or not work
}
```
If you still want the test included in the binary just ignored by default
you can use:
```Rust
#[test]
#[cfg_attr(tarpaulin, ignore)]
fn ignored_by_tarpaulin() {
}
```
### Continuous Integration Services
Tarpaulin aims to be easy to add to your CI workflow. With well tested support
Expand Down
3 changes: 2 additions & 1 deletion src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ fn clean_doctest_folder<P: AsRef<Path>>(doctest_dir: P) {
fn setup_environment(cmd: &mut Command, config: &Config) {
cmd.env("TARPAULIN", "1");
let rustflags = "RUSTFLAGS";
let common_opts = " -C relocation-model=dynamic-no-pic -C link-dead-code -C debuginfo=2 ";
let common_opts =
" -C relocation-model=dynamic-no-pic -C link-dead-code -C debuginfo=2 --cfg=tarpaulin ";
let mut value = common_opts.to_string();
if config.release {
value = format!("{}-C debug-assertions=off ", value);
Expand Down
Loading

0 comments on commit 5ad0b99

Please sign in to comment.