Skip to content

Commit

Permalink
Cargo update.
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytm committed Nov 15, 2017
1 parent ce0c999 commit f5a96ae
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 103 deletions.
24 changes: 13 additions & 11 deletions cargo-cov/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-cov"
version = "0.0.1"
version = "0.0.2"
authors = ["kennytm <[email protected]>"]
description = "Collect source coverage via LLVM-GCOV (⚠ not fully tested, may eat your laundry)"
build = "build.rs"
Expand All @@ -10,34 +10,36 @@ license = "MIT"
keywords = ["cargo", "subcommand", "coverage", "gcov", "lcov"]
categories = ["command-line-utilities", "development-tools", "development-tools::cargo-plugins", "development-tools::testing"]

[badge]
maintenance = { status = "experimental" }

# Note: `pest` (via `tera`) is licensed in MPL-2.0, and `unidecode` (via `slug` via `tera`) in BSD-3.
# According to https://softwareengineering.stackexchange.com/q/317944, this should not cause any
# legal problem for keeping `cargo-cov` itself as MIT, as MPL-2.0 is non-viral.

[dependencies]
cov = { version = "0.0", path = "../cov", features = ["serde_json"] }

bitflags = { version = "0.9", default-features = false }
clap = "2.24"
bitflags = { version = "1", default-features = false }
clap = "2"
copy_dir = "0.1"
either = "1.1" # <- added just because .flat_map(|a| a) is not clone
env_logger = "0.4"
error-chain = "0.10"
error-chain = "0.10" # <- waits for tera to update.
fs2 = "0.4"
glob = "0.2"
lazy_static = "0.2"
log = { version = "0.3", features = ["release_max_level_warn"] }
md5 = "0.3" # <- md5 needed for coveralls
natord = "1.0"
open = "1.2"
natord = "1"
open = "1"
rand = "0.3"
rustc-demangle = "0.1"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
serde = "1"
serde_derive = "1"
serde_json = "1"
shell-escape = "0.1"
tempdir = "0.3"
tera = "0.10"
termcolor = "0.3"
toml = "0.4"
walkdir = "1.0"
walkdir = "2"
4 changes: 2 additions & 2 deletions cargo-cov/src/argparse.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Extra functions for command line argument parsing.
use error::Result;
use sourcepath::{SOURCE_TYPE_DEFAULT, SourceType};
use sourcepath::SourceType;
use utils::{join_3, parent_3};

use clap::ArgMatches;
Expand Down Expand Up @@ -200,7 +200,7 @@ impl<'a> ReportConfig<'a> {
let output_path = match_or_else(matches, "output", || join_3(&workspace_path, "target", "cov", "report"));

let template_name = matches.value_of_os("template").unwrap_or_else(|| OsStr::new("html"));
let allowed_source_types = matches.values_of("include").map_or(SOURCE_TYPE_DEFAULT, |it| SourceType::from_multi_str(it).expect("SourceType"));
let allowed_source_types = matches.values_of("include").map_or(SourceType::DEFAULT, |it| SourceType::from_multi_str(it).expect("SourceType"));

Ok(ReportConfig {
workspace_path,
Expand Down
16 changes: 8 additions & 8 deletions cargo-cov/src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ bitflags! {
/// [`Cargo::clean()`]: ./struct.Cargo.html#method.clean
pub struct CleanTargets: u8 {
/// Delete the `target/cov/build/gcda/` folder.
const CLEAN_BUILD_GCDA = 1;
const BUILD_GCDA = 1;
/// Delete the `target/cov/build/gcno/` folder and built artifacts of all crates in the current workspace.
const CLEAN_BUILD_GCNO = 2;
const BUILD_GCNO = 2;
/// Delete the whole `target/cov/build/` folder.
const CLEAN_BUILD_EXTERNAL = 4;
const BUILD_EXTERNAL = 4;
/// Delete the `target/cov/report` folder.
const CLEAN_REPORT = 8;
const REPORT = 8;
}
}

Expand Down Expand Up @@ -238,13 +238,13 @@ impl<'a> Cargo<'a> {
Ok(())
}

if clean_targets.contains(CLEAN_BUILD_EXTERNAL) {
if clean_targets.contains(CleanTargets::BUILD_EXTERNAL) {
do_clean(&self.cov_build_path)?;
} else {
if clean_targets.contains(CLEAN_BUILD_GCDA) {
if clean_targets.contains(CleanTargets::BUILD_GCDA) {
do_clean(&self.cov_build_path.join("gcda"))?
}
if clean_targets.contains(CLEAN_BUILD_GCNO) {
if clean_targets.contains(CleanTargets::BUILD_GCNO) {
let mut cmd = Command::new(&self.cargo_path);
cmd.current_dir(&self.cov_build_path)
.env("RUSTC", &self.rustc_path) // No need to run our shim.
Expand All @@ -262,7 +262,7 @@ impl<'a> Cargo<'a> {
}
}

if clean_targets.contains(CLEAN_REPORT) {
if clean_targets.contains(CleanTargets::REPORT) {
do_clean(&self.cov_build_path.with_file_name("report"))?;
}
Ok(())
Expand Down
11 changes: 5 additions & 6 deletions cargo-cov/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ Subcommands:
(@setting DeriveDisplayOrder)
(@setting ArgRequiredElseHelp)
(@setting GlobalVersion)
(@setting PropagateGlobalValuesDown)
(@setting AllowExternalSubcommands)
(@arg profiler: --profiler [LIB] +global "Path to `libclang_rt.profile_*.a`")
(@arg target: --target [TRIPLE] +global "Target triple which the covered program will run in")
Expand Down Expand Up @@ -219,18 +218,18 @@ fn clean(cargo: &Cargo, matches: &ArgMatches) -> Result<()> {
let mut clean_target = CleanTargets::empty();

if matches.is_present("gcda") {
clean_target |= CLEAN_BUILD_GCDA;
clean_target |= CleanTargets::BUILD_GCDA;
} else if matches.is_present("local") {
clean_target |= CLEAN_BUILD_GCDA | CLEAN_BUILD_GCNO;
clean_target |= CleanTargets::BUILD_GCDA | CleanTargets::BUILD_GCNO;
} else if matches.is_present("all_crates") {
clean_target |= CLEAN_BUILD_EXTERNAL | CLEAN_BUILD_GCDA | CLEAN_BUILD_GCNO;
clean_target |= CleanTargets::BUILD_EXTERNAL | CleanTargets::BUILD_GCDA | CleanTargets::BUILD_GCNO;
}
if matches.is_present("report") {
clean_target |= CLEAN_REPORT;
clean_target |= CleanTargets::REPORT;
}

if clean_target.is_empty() {
clean_target = CLEAN_BUILD_GCDA | CLEAN_BUILD_GCNO;
clean_target = CleanTargets::BUILD_GCDA | CleanTargets::BUILD_GCNO;
}
cargo.clean(clean_target)
}
2 changes: 1 addition & 1 deletion cargo-cov/src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use utils::{CommandExt, join_2, parent_3};

use fs2::FileExt;
use rand::{Rng, thread_rng};
use walkdir::{WalkDir, WalkDirIterator};
use walkdir::WalkDir;

use std::env;
use std::ffi::{OsStr, OsString};
Expand Down
48 changes: 24 additions & 24 deletions cargo-cov/src/sourcepath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ bitflags! {
/// The type of source path.
pub struct SourceType: u8 {
/// The path is in the local workspace.
const SOURCE_TYPE_LOCAL = 1;
const LOCAL = 1;
/// The "path" is part of macro declaration.
const SOURCE_TYPE_MACROS = 2;
const MACROS = 2;
/// Unknown kind of path.
const SOURCE_TYPE_UNKNOWN = 4;
const UNKNOWN = 4;
/// The path is of external crates.
const SOURCE_TYPE_CRATES = 8;
const CRATES = 8;
/// The path is in the Rust standard libraries.
const SOURCE_TYPE_RUSTSRC = 16;
const RUSTSRC = 16;

/// The default set of interesting source paths.
const SOURCE_TYPE_DEFAULT = SOURCE_TYPE_LOCAL.bits | SOURCE_TYPE_MACROS.bits | SOURCE_TYPE_UNKNOWN.bits;
const DEFAULT = SourceType::LOCAL.bits | SourceType::MACROS.bits | SourceType::UNKNOWN.bits;
}
}

Expand Down Expand Up @@ -87,9 +87,9 @@ impl SourceType {
/// Obtains the path prefix so that
pub fn prefix(self) -> &'static str {
match self {
SOURCE_TYPE_LOCAL => ".",
SOURCE_TYPE_RUSTSRC => "«rust»",
SOURCE_TYPE_CRATES => "«crates»",
SourceType::LOCAL => ".",
SourceType::RUSTSRC => "«rust»",
SourceType::CRATES => "«crates»",
_ => "",
}
}
Expand All @@ -100,11 +100,11 @@ impl FromStr for SourceType {
type Err = UnsupportedSourceTypeName;
fn from_str(s: &str) -> Result<SourceType, UnsupportedSourceTypeName> {
Ok(match s {
"local" => SOURCE_TYPE_LOCAL,
"macros" => SOURCE_TYPE_MACROS,
"rustsrc" => SOURCE_TYPE_RUSTSRC,
"crates" => SOURCE_TYPE_CRATES,
"unknown" => SOURCE_TYPE_UNKNOWN,
"local" => SourceType::LOCAL,
"macros" => SourceType::MACROS,
"rustsrc" => SourceType::RUSTSRC,
"crates" => SourceType::CRATES,
"unknown" => SourceType::UNKNOWN,
"all" => SourceType::all(),
_ => return Err(UnsupportedSourceTypeName),
})
Expand All @@ -114,7 +114,7 @@ impl FromStr for SourceType {
/// Analyzes the the source path and obtain its corresponding [`SourceType`].
///
/// `crates_path` should be the string representation of the workspace path. If the `path` starts with `crates_path`, it
/// will be considered to be [`SOURCE_TYPE_LOCAL`].
/// will be considered to be [`SourceType::LOCAL`].
///
/// The return type is a 2-tuple. The second type (`usize`) is the number of bytes should be removed from the prefix of
/// `path` for human display. This is used in [`simplify_source_path` filter of the default Tera
Expand All @@ -127,31 +127,31 @@ impl FromStr for SourceType {
///
/// let source_path = "/Users/travis/build/rust-lang/rust/src/libstd/lib.rs";
/// let (source_type, prefix_len) = identify_source_path(source_path, "/workspace/path");
/// assert_eq!(source_type, SOURCE_TYPE_RUSTSRC);
/// assert_eq!(source_type, SourceType::RUSTSRC);
///
/// // This is how `simplify_source_path` is created.
/// let simplified_path = format!("{}/{}", source_type.prefix(), &source_path[prefix_len..]);
/// assert_eq!(simplified_path, "«rust»/src/libstd/lib.rs");
/// ```
///
/// [`SourceType`]: ./struct.SourceType.html
/// [`SOURCE_TYPE_LOCAL`]: ./constant.SOURCE_TYPE_LOCAL.html
/// [`SourceType::LOCAL`]: ./constant.SourceType::LOCAL.html
pub fn identify_source_path(path: &str, crates_path: &str) -> (SourceType, usize) {
if path.starts_with(crates_path) {
(SOURCE_TYPE_LOCAL, crates_path.len())
(SourceType::LOCAL, crates_path.len())
} else if path.starts_with(&*REGISTRY_PATH) {
let subpath = &path[REGISTRY_PATH.len()..];
let first_slash = subpath.find(MAIN_SEPARATOR).map_or(0, |s| s + MAIN_SEPARATOR.len_utf8());
(SOURCE_TYPE_CRATES, REGISTRY_PATH.len() + first_slash)
(SourceType::CRATES, REGISTRY_PATH.len() + first_slash)
} else if path.starts_with('<') && path.ends_with(" macros>") {
(SOURCE_TYPE_MACROS, 0)
(SourceType::MACROS, 0)
} else if path.starts_with(MACOS_RUSTSRC_DIR) {
(SOURCE_TYPE_RUSTSRC, MACOS_RUSTSRC_DIR.len())
(SourceType::RUSTSRC, MACOS_RUSTSRC_DIR.len())
} else if path.starts_with(DOCKER_RUSTSRC_DIR) {
(SOURCE_TYPE_RUSTSRC, DOCKER_RUSTSRC_DIR.len())
(SourceType::RUSTSRC, DOCKER_RUSTSRC_DIR.len())
} else if path.starts_with(WINDOWS_RUSTSRC_DIR) {
(SOURCE_TYPE_RUSTSRC, WINDOWS_RUSTSRC_DIR.len())
(SourceType::RUSTSRC, WINDOWS_RUSTSRC_DIR.len())
} else {
(SOURCE_TYPE_UNKNOWN, 0)
(SourceType::UNKNOWN, 0)
}
}
4 changes: 2 additions & 2 deletions cargo-cov/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#![cfg_attr(feature="cargo-clippy", allow(needless_pass_by_value))]
// The pass-by-value is mandated by Tera.

use sourcepath::{SOURCE_TYPE_MACROS, identify_source_path};
use sourcepath::{SourceType, identify_source_path};
use utils::ValueExt;

use md5;
Expand Down Expand Up @@ -84,7 +84,7 @@ fn simplify_source_path(value: Value, mut options: HashMap<String, Value>) -> Re
crate_path.push(MAIN_SEPARATOR);

let (source_type, stripped_len) = identify_source_path(&path, &crate_path);
let simplified = if source_type == SOURCE_TYPE_MACROS {
let simplified = if source_type == SourceType::MACROS {
path
} else {
format!("{}{}{}", source_type.prefix(), MAIN_SEPARATOR, &path[stripped_len..])
Expand Down
17 changes: 10 additions & 7 deletions cov/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cov"
version = "0.0.1"
version = "0.0.2"
authors = ["kennytm <[email protected]>"]
description = "gcov format (*.gcda/*.gcno) parser and analyzer in pure Rust"
documentation = "https://docs.rs/cov"
Expand All @@ -9,20 +9,23 @@ license = "MIT"
keywords = ["coverage", "gcov", "lcov"]
categories = ["parsing"]

[badge]
maintenance = { status = "experimental" }

[dependencies]
bitflags = { version = "0.9", default-features = false } # <- avoid building example_generated by default
byteorder = "1.0"
error-chain = { version = "0.10", default-features = false }
bitflags = { version = "1", default-features = false } # <- avoid building example_generated by default
byteorder = "1"
error-chain = { version = "0.10", default-features = false } # <- waits for tera to update.
fixedbitset = "0.1"
log = { version = "0.3", features = ["release_max_level_warn"] }
num-traits = "0.1"
petgraph = { version = "0.4", default-features = false }
serde = { version = "1.0", optional = true, features = ["derive"] }
serde_json = { version = "1.0", optional = true }
serde = { version = "1", optional = true, features = ["derive"] }
serde_json = { version = "1", optional = true }
shawshank = "0.2"

[dev-dependencies]
clap = "2.25"
clap = "2"
diff = "0.1"
env_logger = "0.4"
termcolor = "0.3"
Expand Down
Loading

0 comments on commit f5a96ae

Please sign in to comment.