Skip to content

Commit

Permalink
Merge branch 'version020'
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytm committed Jun 4, 2016
2 parents 55f12a3 + aa2d78d commit 2e61f56
Show file tree
Hide file tree
Showing 12 changed files with 505 additions and 77 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ os:

rust:
- 1.8.0
- 1.9.0
- beta
- nightly

Expand Down Expand Up @@ -50,11 +51,10 @@ install:
fi
script:
- cargo test --target "$HOST"
- RUSTFLAGS="-C link-dead-code" cargo test --target "$HOST"

after_success:
# Note: we skip the `check-specimen` test in coverage because kcov cannot do recursive-ptrace.
# Track this file: https://github.com/SimonKagstrom/kcov/blob/master/tests/recursive-ptrace/main.cc
- cargo clean
- cargo run -- kcov --bin cargo-kcov --coveralls -- --verify
- cargo run -- kcov --target "$HOST" --no-clean-rebuild --lib --coveralls -- --verify

79 changes: 76 additions & 3 deletions Cargo.lock

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

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
[package]
name = "cargo-kcov"
version = "0.1.0"
version = "0.2.0"
authors = ["kennytm <[email protected]>"]
description = "Cargo subcommand to run kcov to get coverage report on Linux"
repository = "https://github.com/kennytm/cargo-kcov"
keywords = ["cargo", "subcommand", "kcov", "coverage"]
license = "MIT"

[dependencies]
clap = "2.5.1"
clap = "2.5.2"
shlex = "0.1.1"
term = "0.4.4"
rustc-serialize = "0.3.19" # use serde instead? we just use it to parse a simple JSON...
regex = "0.1.71"

[dev-dependencies]
rquery = "0.2.1"
tempdir = "0.3.4"

1 change: 1 addition & 0 deletions specimen/benches/cargo-kcov-test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
4 changes: 4 additions & 0 deletions specimen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ pub fn test_this_in_eighth() -> bool {
true
}

pub fn test_this_in_korean() -> bool {
true
}

pub fn should_never_test_this() -> bool {
true
}
Expand Down
1 change: 1 addition & 0 deletions specimen/tests/cargo-kcov-test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
10 changes: 10 additions & 0 deletions specimen/tests/한국어이름.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
extern crate cargo_kcov_test;

fn main() {
assert!(cargo_kcov_test::test_this_in_korean());
}

#[test]
fn test_korean() {
main();
}
29 changes: 19 additions & 10 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub enum Error {
},
KcovFailed(Option<io::Error>),
NoCoverallsId,
CannotFindTestTargets(Option<io::Error>),
}

impl Error {
Expand All @@ -41,6 +42,7 @@ impl Error {
Error::CannotCreateCoverageDirectory(_) => "cannot create coverage output directory",
Error::KcovFailed(_) => "failed to get coverage",
Error::NoCoverallsId => "missing environment variable TRAVIS_JOB_ID for coveralls",
Error::CannotFindTestTargets(_) => "cannot find test targets",
}
}

Expand All @@ -52,6 +54,7 @@ impl Error {
Error::Json(ref e) => e.as_ref().map(|a| a as &Display),
Error::CannotCreateCoverageDirectory(ref e) => Some(e),
Error::KcovFailed(ref e) => e.as_ref().map(|a| a as &Display),
Error::CannotFindTestTargets(ref e) => e.as_ref().map(|a| a as &Display),
_ => None,
}
}
Expand Down Expand Up @@ -118,16 +121,22 @@ impl Error {
t.fg(WHITE).unwrap();
t.write_all(b" $ ").unwrap();
t.reset().unwrap();
writeln!(t, "wget https://github.com/SimonKagstrom/kcov/archive/v{0}.tar.gz &&
tar xzf v{0}.tar.gz &&
cd kcov-{0} &&
mkdir build &&
cd build &&
cmake -DCMAKE_BUILD_TYPE=Release .. &&
make &&
cp src/kcov src/libkcov_sowrapper.so ~/.cargo/bin
", 31).unwrap();
writeln!(t, "cargo kcov --print-install-kcov-sh | sh").unwrap();
}
Error::CannotFindTestTargets(_) => {
t.fg(GREEN).unwrap();
t.attr(Attr::Bold).unwrap();
t.write_all(b"note: ").unwrap();
t.reset().unwrap();
t.write_all(b"try a clean rebuild first:\n\n").unwrap();
t.fg(WHITE).unwrap();
t.write_all(b" $ ").unwrap();
t.reset().unwrap();
writeln!(t, "cargo clean &&
RUSTFLAGS=\"-C link-dead-code\" cargo test --no-run &&
cargo kcov --no-clean-rebuild
").unwrap();
}
_ => {}
}
Expand Down
15 changes: 15 additions & 0 deletions src/install_kcov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

set -euo pipefail

KCOV_VERSION=31

wget https://github.com/SimonKagstrom/kcov/archive/v${KCOV_VERSION}.tar.gz
tar xzf v${KCOV_VERSION}.tar.gz
cd kcov-${KCOV_VERSION}
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
cp src/kcov src/libkcov_sowrapper.so ~/.cargo/bin

Loading

0 comments on commit 2e61f56

Please sign in to comment.