Skip to content

Commit

Permalink
Release 0.18.0-alpha3
Browse files Browse the repository at this point in the history
  • Loading branch information
xd009642 committed May 2, 2021
2 parents 5579fc4 + f627a20 commit 702197e
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 29 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
target-branch: develop
ignore:
- dependency-name: libc
versions:
- 0.2.83
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
From 2019 onwards, all notable changes to tarpaulin will be documented in this
file.

## Unreleased
### Added

### Changed
- Updated logging so for the build mode it says "launching binary" instead of
"launching test"
- Don't apply `--color` argument to test executables if "auto" to prevent issues
with tests that can't have color controlled
- Fix directory that `cargo clean` is run from
- Reduce number of cleans fixing issue where only last run-type was ran
- Clean without `cargo clean` removing directory to preserve coverage run delta reporting

### Removed

## [0.18.0-alpha2] 2021-04-16
### Added
- Check if user sets -Cdebuginfo and remove it #601
Expand Down
22 changes: 11 additions & 11 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.18.0-alpha2"
version = "0.18.0-alpha3"
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 @@ -47,7 +47,7 @@ walkdir = "2.3.2"
cfg-if = "1.0.0"

[target.'cfg(target_os = "linux")'.dependencies]
libc = "0.2.93"
libc = "0.2.94"
nix = "0.20.0"
procfs = "0.9"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Below is the help-text for a thorough explanation of the flags and features
available:

```
cargo-tarpaulin version: 0.18.0-alpha2
cargo-tarpaulin version: 0.18.0-alpha3
Tool to analyse test coverage of cargo projects
USAGE:
Expand Down
25 changes: 14 additions & 11 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use std::io;
use std::io::{BufRead, BufReader};
use std::path::{Component, Path, PathBuf};
use std::process::{Command, Stdio};

use toml::Value;
use tracing::{error, info, trace, warn};
use walkdir::{DirEntry, WalkDir};
Expand Down Expand Up @@ -40,7 +39,7 @@ impl CargoVersionInfo {
}
}

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)]
pub struct TestBinary {
path: PathBuf,
ty: Option<RunType>,
Expand Down Expand Up @@ -164,6 +163,19 @@ lazy_static! {

pub fn get_tests(config: &Config) -> Result<Vec<TestBinary>, RunError> {
let mut result = vec![];
if config.force_clean {
let cleanup_dir = if config.release {
config.target_dir().join("debug")
} else {
config.target_dir().join("release")
};
info!("Cleaning project");
if cleanup_dir.exists() {
if let Err(e) = remove_dir_all(cleanup_dir) {
error!("Cargo clean failed: {}", e);
}
}
}
let manifest = match config.manifest.as_path().to_str() {
Some(s) => s,
None => "Cargo.toml",
Expand Down Expand Up @@ -197,15 +209,6 @@ fn run_cargo(
ty: Option<RunType>,
result: &mut Vec<TestBinary>,
) -> Result<(), RunError> {
if config.force_clean {
if let Ok(clean) = Command::new("cargo").arg("clean").output() {
info!("Cleaning project");
if !clean.status.success() {
error!("Cargo clean failed:");
println!("{}", std::str::from_utf8(&clean.stderr).unwrap_or_default());
}
}
}
let mut cmd = create_command(manifest, config, ty);
if ty != Some(RunType::Doctests) {
cmd.stdout(Stdio::piped());
Expand Down
8 changes: 7 additions & 1 deletion src/process_handling/linux.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::collect_coverage;
use crate::config::types::Mode;
use crate::errors::*;
use crate::event_log::*;
use crate::process_handling::execute_test;
Expand Down Expand Up @@ -40,6 +41,7 @@ pub fn get_test_coverage(
logger: &Option<EventLog>,
) -> Result<Option<(TraceMap, i32)>, RunError> {
if !test.path().exists() {
warn!("Test at {} doesn't exist", test.path().display());
return Ok(None);
}
if let Err(e) = limit_affinity() {
Expand All @@ -57,7 +59,11 @@ pub fn get_test_coverage(
}
}
Ok(ForkResult::Child) => {
info!("Launching test");
let bin_type = match config.command {
Mode::Test => "test",
Mode::Build => "binary",
};
info!("Launching {}", bin_type);
execute_test(test, ignored, config)?;
Ok(None)
}
Expand Down
7 changes: 5 additions & 2 deletions src/process_handling/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::config::Color;
use crate::generate_tracemap;
use crate::statemachine::{create_state_machine, TestState};
use crate::traces::*;
Expand Down Expand Up @@ -96,8 +97,10 @@ fn execute_test(test: &TestBinary, ignored: bool, config: &Config) -> Result<(),
for s in &config.varargs {
argv.push(CString::new(s.as_bytes()).unwrap_or_default());
}
argv.push(CString::new("--color").unwrap_or_default());
argv.push(CString::new(config.color.to_string().to_ascii_lowercase()).unwrap_or_default());
if config.color != Color::Auto {
argv.push(CString::new("--color").unwrap_or_default());
argv.push(CString::new(config.color.to_string().to_ascii_lowercase()).unwrap_or_default());
}

if let Some(s) = test.pkg_name() {
envars.push(CString::new(format!("CARGO_PKG_NAME={}", s)).unwrap_or_default());
Expand Down
28 changes: 28 additions & 0 deletions tests/test_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@ use cargo_tarpaulin::launch_tarpaulin;
use std::env;
use std::time::Duration;

#[test]
fn mix_test_types() {
// Issue 747 the clean would delete old tests leaving to only one run type effectively being
// ran. This test covers against that mistake
let mut config = Config::default();
config.force_clean = true;
config.test_timeout = Duration::from_secs(60);
config.run_types = vec![RunType::Tests, RunType::Examples];
let restore_dir = env::current_dir().unwrap();
let test_dir = get_test_path("all_test_types");
env::set_current_dir(&test_dir).unwrap();
config.manifest = test_dir;
config.manifest.push("Cargo.toml");

let (res, ret) = launch_tarpaulin(&config, &None).unwrap();
assert_eq!(ret, 0);
env::set_current_dir(restore_dir).unwrap();

for f in res.files() {
let f_name = f.file_name().unwrap().to_str().unwrap();
if f_name.contains("example") || (f_name.contains("test") && !f_name.contains("doc")) {
assert!(res.covered_in_path(f) > 0);
} else {
assert_eq!(res.covered_in_path(f), 0);
}
}
}

#[test]
fn only_test_coverage() {
let mut config = Config::default();
Expand Down
2 changes: 1 addition & 1 deletion travis-install.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
curl -sL https://github.com/xd009642/tarpaulin/releases/download/0.18.0-alpha2/cargo-tarpaulin-0.18.0-alpha2-travis.tar.gz | tar xvz -C $HOME/.cargo/bin
curl -sL https://github.com/xd009642/tarpaulin/releases/download/0.18.0-alpha3/cargo-tarpaulin-0.18.0-alpha3-travis.tar.gz | tar xvz -C $HOME/.cargo/bin

0 comments on commit 702197e

Please sign in to comment.