Skip to content

Commit

Permalink
Merge branch 'master' of github.com:marco-c/grcov
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-c committed Mar 4, 2017
2 parents 4a7ac51 + 430f71c commit bd1525d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
21 changes: 11 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
sudo: required
language: rust
rust:
- nightly
script:
- sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- sudo -E apt-get -yq update &>> ~/apt-get-update.log
- sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install gcc-$COMPILER_VER g++-$COMPILER_VER
- mkdir -p gcc-symlinks
- ln -s /usr/bin/g++-6 gcc-symlinks/g++
- ln -s /usr/bin/gcc-6 gcc-symlinks/gcc
- ln -s /usr/bin/gcov-6 gcc-symlinks/gcov
- ln -s /usr/bin/g++-$COMPILER_VER gcc-symlinks/g++
- ln -s /usr/bin/gcc-$COMPILER_VER gcc-symlinks/gcc
- ln -s /usr/bin/gcov-$COMPILER_VER gcc-symlinks/gcov
- export PATH=$PWD/gcc-symlinks:$PATH
- cargo build --verbose
- cargo test -- --nocapture
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-6
- g++-6
env:
- COMPILER_VER=4.9
- COMPILER_VER=5
- COMPILER_VER=6
26 changes: 24 additions & 2 deletions tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extern crate walkdir;
extern crate serde_json;

use std::env;
use std::process::Command;
use walkdir::WalkDir;
use std::path::Path;
Expand Down Expand Up @@ -77,25 +78,46 @@ fn check_equal(expected_output: Vec<String>, output: Vec<String>) {
actual.push(serde_json::from_str(line).unwrap());
}

// On CI and without gcc-6, don't check /usr/include files, as they are different between GCC versions and the expected files are built using gcc-6.
let skip_builtin = env::var("COMPILER_VER").is_ok() && env::var("COMPILER_VER").unwrap() != "6";
// On CI, don't check methods, as on different machines names are slightly differently mangled.
let skip_methods = skip_builtin || env::var("CONTINUOUS_INTEGRATION").is_ok();

for out in actual.iter() {
if out["sourceFile"].as_str().unwrap().contains("/usr/include") && skip_builtin {
continue;
}

let exp = expected.iter().find(|&&ref x| x["sourceFile"] == out["sourceFile"]);
assert!(exp.is_some(), "Got unexpected {}", out["sourceFile"]);
let exp_val = exp.unwrap();
assert_eq!(out["testUrl"], exp_val["testUrl"]);
assert_eq!(out["covered"], exp_val["covered"]);
assert_eq!(out["uncovered"], exp_val["uncovered"]);
assert_eq!(out["methods"].as_object().unwrap().len(), exp_val["methods"].as_object().unwrap().len());
if skip_methods {
assert_eq!(out["methods"].as_object().unwrap().len(), exp_val["methods"].as_object().unwrap().len());
} else {
assert_eq!(out["methods"], exp_val["methods"]);
}
}

for exp in expected.iter() {
if exp["sourceFile"].as_str().unwrap().contains("/usr/include") && skip_builtin {
continue;
}

let out = actual.iter().find(|&&ref x| x["sourceFile"] == exp["sourceFile"]);
assert!(out.is_some(), "Missing {}", exp["sourceFile"]);
assert!(out.is_some());
let out_val = out.unwrap();
assert_eq!(exp["testUrl"], out_val["testUrl"]);
assert_eq!(exp["covered"], out_val["covered"]);
assert_eq!(exp["uncovered"], out_val["uncovered"]);
assert_eq!(exp["methods"].as_object().unwrap().len(), out_val["methods"].as_object().unwrap().len());
if skip_methods {
assert_eq!(exp["methods"].as_object().unwrap().len(), out_val["methods"].as_object().unwrap().len());
} else {
assert_eq!(exp["methods"], out_val["methods"]);
}
}
}

Expand Down

0 comments on commit bd1525d

Please sign in to comment.