Skip to content

Commit

Permalink
Merge branch 'issue-13' into develop
Browse files Browse the repository at this point in the history
Fixes #13
  • Loading branch information
xd009642 committed Mar 10, 2019
2 parents 2620220 + f32c4aa commit 1087cb7
Show file tree
Hide file tree
Showing 12 changed files with 280 additions and 54 deletions.
50 changes: 38 additions & 12 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
Expand Up @@ -17,7 +17,7 @@ edition = "2018"
name = "cargo-tarpaulin"

[dependencies]
cargo = "0.33"
cargo = "0.34"
chrono = "0.4"
clap = "2.31.2"
coveralls-api = "0.4.0"
Expand All @@ -31,7 +31,7 @@ log = "0.4.6"
memmap = "0.7.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 Down
39 changes: 38 additions & 1 deletion 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 Down Expand Up @@ -70,10 +72,45 @@ 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 {
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"),
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 clap::{_clap_count_exprs, arg_enum};
use cargo::core::compiler::CompileMode;
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
2 changes: 2 additions & 0 deletions src/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ pub enum RunError {
Html(String),
#[fail(display = "Failed to generate XML report! Error: {}", _0)]
XML(cobertura::Error),
#[fail(display = "Tarpaulin experienced an internal error")]
Internal,
}

impl From<std::io::Error> for RunError {
Expand Down
Loading

0 comments on commit 1087cb7

Please sign in to comment.