Skip to content

Commit

Permalink
Releasing 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xd009642 committed May 9, 2019
2 parents f95f717 + 9d7f9bc commit c928356
Show file tree
Hide file tree
Showing 33 changed files with 2,192 additions and 1,096 deletions.
712 changes: 368 additions & 344 deletions Cargo.lock

Large diffs are not rendered by default.

23 changes: 15 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[package]
name = "cargo-tarpaulin"
version = "0.7.0"
version = "0.8.0"
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 All @@ -12,22 +12,31 @@ categories = ["development-tools"]
keywords = ["cargo", "cargo-subcommand", "testing"]
#publish-lockfile = true
edition = "2018"
autotests = false

[[bin]]
name = "cargo-tarpaulin"

[[test]]
name = "integration"
path = "tests/mod.rs"

[dependencies]
cargo = "0.32"
cargo = "0.34"
chrono = "0.4"
clap = "2.31.2"
coveralls-api = "0.3.3"
coveralls-api = "0.4.0"
env_logger = "0.6.0"
failure = "0.1.3"
fallible-iterator = "0.1.6"
gimli = "0.16.1"
lazy_static = "1.0"
libc = "0.2.45"
log = "0.4.6"
memmap = "0.7.0"
nix = "0.12.0"
nix = "0.13.0"
object = "0.11"
proc-macro2 = "0.4.24"
proc-macro2 = "0.4.27"
quick-xml = "0.13.0"
regex = "1.1"
rustc-demangle = "0.1.11"
Expand All @@ -36,6 +45,4 @@ serde_json = "1.0"
syn = { version = "0.15.23", features = ["full"]}
void = "1.0"
walkdir = "2.2.5"
failure = "0.1.3"
env_logger = "0.6.0"
log = "0.4.6"
git2 = "0.7"
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ stage and therefore may contain some bugs. A lot of work has been done to get it
working on some example projects and smaller crates so please report anything
you find that's wrong. Also, check out our roadmap for planned features.

Tarpaulin only supports x86_64 processors running Linux. This is because
**Tarpaulin only supports x86_64 processors running Linux.** This is because
instrumenting breakpoints into executables and tracing their execution requires
processor and OS specific code. It is a goal when greater stability is reached
to add wider system support, however this is sufficient to run Tarpaulin on
Expand Down Expand Up @@ -261,8 +261,10 @@ accuracy. If you see missing lines or files, check your compiler version.
- [x] Annotated coverage reports
- [x] Coverage reports in the style of existing tools (i.e. kcov)
- [x] Integration with 3rd party tools like coveralls or codecov
- [ ] Optional coverage statistics for doctests
- [x] Optional coverage statistics for doctests
- [ ] MCDC coverage reports
- [ ] OSX support
- [ ] Windows support

## License

Expand Down
17 changes: 10 additions & 7 deletions src/breakpoint.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::ptrace_control::*;
use crate::statemachine::*;
use nix::unistd::Pid;
use nix::{Error, Result};
use std::collections::HashMap;
Expand Down Expand Up @@ -43,6 +44,10 @@ impl Breakpoint {
}
}

pub fn jump_to(&mut self, pid: Pid) -> Result<()> {
set_instruction_pointer(pid, self.pc).map(|_| ())
}

/// Attaches the current breakpoint.
pub fn enable(&mut self, pid: Pid) -> Result<()> {
let data = read_address(pid, self.aligned_address())?;
Expand All @@ -65,7 +70,7 @@ impl Breakpoint {
}

/// Processes the breakpoint. This steps over the breakpoint
pub fn process(&mut self, pid: Pid, reenable: bool) -> Result<bool> {
pub fn process(&mut self, pid: Pid, reenable: bool) -> Result<(bool, TracerAction<ProcessInfo>)> {
let is_running = match self.is_running.get(&pid) {
Some(r) => *r,
None => true,
Expand All @@ -74,15 +79,14 @@ impl Breakpoint {
let _ = self.enable(pid);
self.step(pid)?;
self.is_running.insert(pid, false);
Ok(true)
Ok((true, TracerAction::Step(pid.into())))
} else {
self.disable(pid)?;
if reenable {
self.enable(pid)?;
}
continue_exec(pid, None)?;
self.is_running.insert(pid, true);
Ok(false)
Ok((false, TracerAction::Continue(pid.into())))
}
}

Expand All @@ -98,9 +102,8 @@ impl Breakpoint {
// Remove the breakpoint, reset the program counter to step before it
// hit the breakpoint then step to execute the original instruction.
self.disable(pid)?;
// Need to set the program counter back one.
set_instruction_pointer(pid, self.pc)?;
single_step(pid)
self.jump_to(pid)?;
Ok(())
}

fn aligned_address(&self) -> u64 {
Expand Down
45 changes: 43 additions & 2 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ mod parse;
mod types;

/// Specifies the current configuration tarpaulin is using.
#[derive(Debug, Default)]
#[derive(Debug)]
pub struct Config {
/// Path to the projects cargo manifest
pub manifest: PathBuf,
/// Types of tests for tarpaulin to collect coverage on
pub run_types: Vec<RunType>,
/// Flag to also run tests with the ignored attribute
pub run_ignored: bool,
/// Flag to ignore test functions in coverage statistics
Expand All @@ -27,6 +29,8 @@ pub struct Config {
pub force_clean: bool,
/// Verbose flag for printing information to the user
pub verbose: bool,
/// Debug flag for printing internal debugging information to the user
pub debug: bool,
/// Flag to count hits in coverage
pub count: bool,
/// Flag specifying to run line coverage (default)
Expand Down Expand Up @@ -68,15 +72,52 @@ pub struct Config {
pub release: bool,
}

impl Default for Config {
fn default() -> Config {
Config {
run_types: vec![RunType::Tests],
manifest: Default::default(),
run_ignored: false,
ignore_tests: false,
ignore_panics: false,
force_clean: false,
verbose: false,
debug: false,
count: false,
line_coverage: true,
branch_coverage: false,
generate: vec![],
coveralls: None,
ci_tool: None,
report_uri: None,
forward_signals: false,
no_default_features: false,
features: vec![],
all: false,
packages: vec![],
exclude: vec![],
excluded_files: vec![],
varargs: vec![],
test_timeout: Duration::from_secs(60),
release: false,
all_features: false,
}
}
}

impl<'a> From<&'a ArgMatches<'a>> for Config {
fn from(args: &'a ArgMatches<'a>) -> Self {
let debug = args.is_present("debug");
let verbose = args.is_present("verbose") || debug;
Config {
manifest: get_manifest(args),
run_types: get_run_types(args),
run_ignored: args.is_present("ignored"),
ignore_tests: args.is_present("ignore-tests"),
ignore_panics: args.is_present("ignore-panics"),
force_clean: args.is_present("force-clean"),
verbose: args.is_present("verbose"),
verbose,
debug,
count: args.is_present("count"),
line_coverage: get_line_cov(args),
branch_coverage: get_branch_cov(args),
Expand Down
4 changes: 4 additions & 0 deletions src/config/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ pub(super) fn get_outputs(args: &ArgMatches) -> Vec<OutputFile> {
values_t!(args.values_of("out"), OutputFile).unwrap_or(vec![])
}

pub(super) fn get_run_types(args: &ArgMatches) -> Vec<RunType> {
values_t!(args.values_of("run-types"), RunType).unwrap_or(vec![RunType::Tests])
}

pub(super) fn get_excluded(args: &ArgMatches) -> Vec<Regex> {
let mut files = vec![];

Expand Down
18 changes: 18 additions & 0 deletions src/config/types.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
use cargo::core::compiler::CompileMode;
use clap::{_clap_count_exprs, arg_enum};
use coveralls_api::CiService;
use std::str::FromStr;
use void::Void;

arg_enum! {
#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
pub enum RunType {
Tests,
Doctests,
}
}

arg_enum! {
#[derive(Debug)]
pub enum OutputFile {
Expand All @@ -23,6 +32,15 @@ impl Default for OutputFile {

pub struct Ci(pub CiService);

impl From<RunType> for CompileMode {
fn from(run: RunType) -> Self {
match run {
RunType::Tests => CompileMode::Test,
RunType::Doctests => CompileMode::Doctest,
}
}
}

impl FromStr for Ci {
/// This can never fail, so the error type is uninhabited.
type Err = Void;
Expand Down
14 changes: 9 additions & 5 deletions src/errors/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::report::cobertura;
use failure::Fail;

/// Error states that could be returned from tarpaulin
#[derive(Fail, Debug)]
pub enum RunError {
Expand All @@ -16,8 +16,10 @@ pub enum RunError {
#[fail(display = "Failed to compile tests! Error: {}", _0)]
TestCompile(String),
/// Test failed during run
#[fail(display = "Failed to run tests! Error: {}", _0)]
#[fail(display = "Failed to run tests: {}", _0)]
TestRuntime(String),
#[fail(display = "Test failed during run")]
TestFailed,
/// Failed to parse
#[fail(display = "Error while parsing: {}", _0)]
Parse(std::io::Error),
Expand All @@ -40,7 +42,9 @@ pub enum RunError {
#[fail(display = "Failed to generate HTML report! Error: {}", _0)]
Html(String),
#[fail(display = "Failed to generate XML report! Error: {}", _0)]
XML(quick_xml::Error),
XML(cobertura::Error),
#[fail(display = "Tarpaulin experienced an internal error")]
Internal,
}

impl From<std::io::Error> for RunError {
Expand All @@ -55,8 +59,8 @@ impl From<nix::Error> for RunError {
}
}

impl From<quick_xml::Error> for RunError {
fn from(e: quick_xml::Error) -> Self {
impl From<cobertura::Error> for RunError {
fn from(e: cobertura::Error) -> Self {
RunError::XML(e)
}
}
Loading

0 comments on commit c928356

Please sign in to comment.