Skip to content

Commit

Permalink
Release 0.8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
xd009642 committed Jun 9, 2019
2 parents 1633451 + bff70fb commit 1f54f99
Show file tree
Hide file tree
Showing 13 changed files with 201 additions and 94 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ env:
global:
- CRATE_NAME=cargo-tarpaulin
rust:
- stable
- beta
- nightly
script:
- cargo clean
- RUST_BACKTRACE=1 cargo build
- cargo test -- --test-threads 1
- |
if [[ "$TRAVIS_RUST_VERSION" == nightly ]]; then
cargo test -- --test-threads 1 --ignored
fi
after_success: |
test $TRAVIS_BRANCH = develop &&
test $TRAVIS_RUST_VERSION = nightly &&
Expand Down
170 changes: 85 additions & 85 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-tarpaulin"
version = "0.8.3"
version = "0.8.4"
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
26 changes: 19 additions & 7 deletions src/report/safe_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ impl serde_json::ser::Formatter for SafeFormatter {
W: io::Write,
{
let mut start = 0;

for (i, ch) in fragment.chars().enumerate() {
let mut code_length = 0;
for ch in fragment.chars() {
code_length += ch.len_utf8();
let escape = match ch {
'<' | '>' | '&' => CharEscape::AsciiControl(ch as u8),
_ => continue,
};

if start < i {
self.0.write_string_fragment(writer, &fragment[start..i])?;
if start < code_length - 1 {
self.0.write_string_fragment(writer, &fragment[start..code_length-1])?;
}

self.write_char_escape(writer, escape)?;

start = i + 1;
start = code_length;
}

if start < fragment.len() {
if start < code_length {
self.0.write_string_fragment(writer, &fragment[start..])?;
}
Ok(())
Expand Down Expand Up @@ -76,4 +76,16 @@ mod tests {
r#"{"a":1,"b":"c","d":"text with \"quotes\" inside","h":"some \u003cscript\u003ealert(\"Alert\")\u003c/script\u003e html"}"#
);
}

#[test]
fn test_json_unicode() {
let x = json!({
"a": 1,
"b": "a<❌>b",
});
assert_eq!(
to_string_safe(&x).unwrap().as_str(),
r#"{"a":1,"b":"a\u003c❌\u003eb"}"#
);
}
}
6 changes: 6 additions & 0 deletions tests/data/matches/Cargo.lock

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

9 changes: 9 additions & 0 deletions tests/data/matches/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "matches"
version = "0.1.0"
authors = ["xd009642 <[email protected]>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
39 changes: 39 additions & 0 deletions tests/data/matches/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

pub fn check_match(x: usize) -> usize {
match x {
0 => 1,
1...5 => 2,
6 | 8 => 3,
x if x % 2 == 0 => x,
_ => 0,
}
}

pub fn destructuring_match(x: u32, y: u32) {
let _y = match (x, y) {
(1, _) => 1,
(_, 1) => 1,
(2, 2) => 2,
_ => 0,
};

}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
check_match(0);
check_match(2);
check_match(999999);
check_match(8);
check_match(9998);

destructuring_match(1, 3);
destructuring_match(2, 1);
destructuring_match(2, 2);
destructuring_match(3, 2);
}
}
6 changes: 6 additions & 0 deletions tests/data/paths/Cargo.lock

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

9 changes: 9 additions & 0 deletions tests/data/paths/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "paths"
version = "0.1.0"
authors = ["xd009642 <[email protected]>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
14 changes: 14 additions & 0 deletions tests/data/paths/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::cmp::{
min,
max
};

pub fn junk() -> Vec<u8> {
Vec::<u8>::with_capacity(max(1, min(10, 0)))
}


#[test]
fn it_works() {
junk();
}
1 change: 1 addition & 0 deletions tests/doc_coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::env;
use std::time::Duration;

#[test]
#[ignore]
fn doc_test_coverage() {
let mut config = Config::default();
config.verbose = true;
Expand Down
5 changes: 5 additions & 0 deletions tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,8 @@ fn loops_expr_coverage() {
fn loops_assigns_coverage() {
check_percentage("assigns", 1.0f64, true);
}

#[test]
fn paths_coverage() {
check_percentage("paths", 1.0f64, true);
}
2 changes: 1 addition & 1 deletion travis-install.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
curl -sL https://github.com/xd009642/tarpaulin/releases/download/0.8.3/cargo-tarpaulin-0.8.3-travis.tar.gz | tar xvz -C $HOME/.cargo/bin
curl -sL https://github.com/xd009642/tarpaulin/releases/download/0.8.4/cargo-tarpaulin-0.8.4-travis.tar.gz | tar xvz -C $HOME/.cargo/bin
echo "WARNING This method is no longer recommended. Use docker or crates.io to install tarpaulin"

0 comments on commit 1f54f99

Please sign in to comment.