From 5d905d3503e8c189f8b1f03c53d71b65ecd7b870 Mon Sep 17 00:00:00 2001 From: calixteman Date: Tue, 14 May 2019 12:25:43 +0200 Subject: [PATCH] Add an output format for FuzzManager (#286) --- src/covdir.rs | 119 ++++++++++++ src/defs.rs | 25 +++ src/lib.rs | 3 + src/main.rs | 4 +- src/output.rs | 183 +++++++++++++++--- src/path_rewriting.rs | 21 +- test/test_covdir.json | 93 +++++++++ tests/basic/expected_gcc.covdir | 33 ++++ tests/basic/expected_llvm.covdir | 33 ++++ tests/basic/expected_llvm_7.covdir | 33 ++++ tests/basic/expected_llvm_mac.covdir | 33 ++++ tests/basic_zip_dir/expected_gcc.covdir | 33 ++++ tests/basic_zip_dir/expected_llvm.covdir | 33 ++++ tests/basic_zip_dir/expected_llvm_7.covdir | 33 ++++ tests/basic_zip_dir/expected_llvm_mac.covdir | 33 ++++ tests/basic_zip_zip/expected_gcc.covdir | 33 ++++ tests/basic_zip_zip/expected_llvm.covdir | 33 ++++ tests/basic_zip_zip/expected_llvm_7.covdir | 33 ++++ tests/basic_zip_zip/expected_llvm_mac.covdir | 33 ++++ .../basic_zip_zip/expected_no_gcda_gcc.covdir | 33 ++++ .../expected_no_gcda_llvm.covdir | 33 ++++ .../expected_no_gcda_llvm_7.covdir | 33 ++++ .../expected_no_gcda_llvm_mac.covdir | 33 ++++ .../expected_two_gcda_gcc.covdir | 33 ++++ .../expected_two_gcda_llvm.covdir | 33 ++++ .../expected_two_gcda_llvm_7.covdir | 33 ++++ .../expected_two_gcda_llvm_mac.covdir | 33 ++++ tests/class/expected_gcc.covdir | 54 ++++++ tests/class/expected_gcc_7.covdir | 54 ++++++ tests/class/expected_llvm.covdir | 54 ++++++ tests/class/expected_llvm_7_linux.covdir | 54 ++++++ tests/class/expected_llvm_mac.covdir | 54 ++++++ tests/include/expected_gcc.covdir | 69 +++++++ tests/include/expected_llvm.ade | 8 +- tests/include/expected_llvm.covdir | 68 +++++++ tests/include/expected_llvm_7_linux.ade | 8 +- tests/include/expected_llvm_7_linux.covdir | 68 +++++++ tests/include/expected_llvm_mac.ade | 12 +- tests/include/expected_llvm_mac.covdir | 68 +++++++ tests/include2/expected_gcc.covdir | 73 +++++++ tests/include2/expected_gcc_7.covdir | 73 +++++++ tests/include2/expected_llvm.ade | 8 +- tests/include2/expected_llvm.covdir | 72 +++++++ tests/include2/expected_llvm_7_linux.ade | 8 +- tests/include2/expected_llvm_7_linux.covdir | 72 +++++++ tests/include2/expected_llvm_mac.ade | 12 +- tests/include2/expected_llvm_mac.covdir | 72 +++++++ tests/switch/expected_gcc.covdir | 55 ++++++ tests/switch/expected_gcc_7.covdir | 55 ++++++ tests/switch/expected_llvm.covdir | 55 ++++++ tests/switch/expected_llvm_7.covdir | 55 ++++++ tests/switch/expected_llvm_mac.covdir | 55 ++++++ tests/template/expected_gcc.covdir | 50 +++++ tests/template/expected_llvm.covdir | 50 +++++ tests/template/expected_llvm_7_linux.covdir | 50 +++++ tests/template/expected_llvm_mac.covdir | 50 +++++ tests/test.rs | 60 +++++- 57 files changed, 2540 insertions(+), 64 deletions(-) create mode 100644 src/covdir.rs create mode 100644 test/test_covdir.json create mode 100644 tests/basic/expected_gcc.covdir create mode 100644 tests/basic/expected_llvm.covdir create mode 100644 tests/basic/expected_llvm_7.covdir create mode 100644 tests/basic/expected_llvm_mac.covdir create mode 100644 tests/basic_zip_dir/expected_gcc.covdir create mode 100644 tests/basic_zip_dir/expected_llvm.covdir create mode 100644 tests/basic_zip_dir/expected_llvm_7.covdir create mode 100644 tests/basic_zip_dir/expected_llvm_mac.covdir create mode 100644 tests/basic_zip_zip/expected_gcc.covdir create mode 100644 tests/basic_zip_zip/expected_llvm.covdir create mode 100644 tests/basic_zip_zip/expected_llvm_7.covdir create mode 100644 tests/basic_zip_zip/expected_llvm_mac.covdir create mode 100644 tests/basic_zip_zip/expected_no_gcda_gcc.covdir create mode 100644 tests/basic_zip_zip/expected_no_gcda_llvm.covdir create mode 100644 tests/basic_zip_zip/expected_no_gcda_llvm_7.covdir create mode 100644 tests/basic_zip_zip/expected_no_gcda_llvm_mac.covdir create mode 100644 tests/basic_zip_zip/expected_two_gcda_gcc.covdir create mode 100644 tests/basic_zip_zip/expected_two_gcda_llvm.covdir create mode 100644 tests/basic_zip_zip/expected_two_gcda_llvm_7.covdir create mode 100644 tests/basic_zip_zip/expected_two_gcda_llvm_mac.covdir create mode 100644 tests/class/expected_gcc.covdir create mode 100644 tests/class/expected_gcc_7.covdir create mode 100644 tests/class/expected_llvm.covdir create mode 100644 tests/class/expected_llvm_7_linux.covdir create mode 100644 tests/class/expected_llvm_mac.covdir create mode 100644 tests/include/expected_gcc.covdir create mode 100644 tests/include/expected_llvm.covdir create mode 100644 tests/include/expected_llvm_7_linux.covdir create mode 100644 tests/include/expected_llvm_mac.covdir create mode 100644 tests/include2/expected_gcc.covdir create mode 100644 tests/include2/expected_gcc_7.covdir create mode 100644 tests/include2/expected_llvm.covdir create mode 100644 tests/include2/expected_llvm_7_linux.covdir create mode 100644 tests/include2/expected_llvm_mac.covdir create mode 100644 tests/switch/expected_gcc.covdir create mode 100644 tests/switch/expected_gcc_7.covdir create mode 100644 tests/switch/expected_llvm.covdir create mode 100644 tests/switch/expected_llvm_7.covdir create mode 100644 tests/switch/expected_llvm_mac.covdir create mode 100644 tests/template/expected_gcc.covdir create mode 100644 tests/template/expected_llvm.covdir create mode 100644 tests/template/expected_llvm_7_linux.covdir create mode 100644 tests/template/expected_llvm_mac.covdir diff --git a/src/covdir.rs b/src/covdir.rs new file mode 100644 index 000000000..5132da73d --- /dev/null +++ b/src/covdir.rs @@ -0,0 +1,119 @@ +use serde_json::map::Map; +use std::collections::BTreeMap; + +pub use crate::defs::*; + +impl CDStats { + + pub fn new(total: usize, covered: usize) -> Self { + let missed = total - covered; + Self { + total, + covered, + missed, + percent: Self::get_percent(covered, total), + } + } + + pub fn add(&mut self, other: &Self) { + // Add stats to self without recomputing the percentage because it's time consuming. + // So once all the stats are merged into one for a directory + // then need to call set_percent() + self.total += other.total; + self.covered += other.covered; + self.missed += other.missed; + } + + pub fn set_percent(&mut self) { + self.percent = Self::get_percent(self.covered, self.total); + } + + pub fn get_percent(x: usize, y: usize) -> f64 { + if y != 0 { + f64::round(x as f64 / (y as f64) * 10_000.) / 100. + } else { + 0.0 + } + } +} + +impl CDFileStats { + + pub fn new(name: String, coverage: BTreeMap) -> Self { + let (total, covered, lines) = Self::get_coverage(coverage); + Self { + name, + stats: CDStats::new(total, covered), + coverage: lines, + } + } + + fn get_coverage(coverage: BTreeMap) -> (usize, usize, Vec) { + let mut covered = 0; + let last_line = *coverage.keys().last().unwrap_or(&0) as usize; + let total = coverage.len(); + let mut lines: Vec = vec![-1; last_line]; + for (line_num, line_count) in coverage.iter() { + let line_count = *line_count; + unsafe { + *lines.get_unchecked_mut((*line_num - 1) as usize) = line_count as i64; + } + covered += (line_count > 0) as usize; + } + (total, covered, lines) + } + + pub fn to_json(&self) -> serde_json::Value { + json!({ + "name": self.name, + "linesTotal": self.stats.total, + "linesCovered": self.stats.covered, + "linesMissed": self.stats.missed, + "coveragePercent": self.stats.percent, + "coverage": self.coverage, + }) + } +} + +impl CDDirStats { + + pub fn new(name: String) -> Self { + Self { + name, + files: Vec::new(), + dirs: Vec::new(), + stats: Default::default(), + } + } + + pub fn set_stats(&mut self) { + for file in self.files.iter() { + self.stats.add(&file.stats); + } + for dir in self.dirs.iter() { + let mut dir = dir.borrow_mut(); + dir.set_stats(); + self.stats.add(&dir.stats); + } + self.stats.set_percent(); + } + + pub fn to_json(&mut self) -> serde_json::Value { + let mut children = Map::new(); + for file in self.files.drain(..) { + children.insert(file.name.clone(), file.to_json()); + } + for dir in self.dirs.drain(..) { + let mut dir = dir.borrow_mut(); + children.insert(dir.name.clone(), dir.to_json()); + } + json!({ + "name": self.name, + "linesTotal": self.stats.total, + "linesCovered": self.stats.covered, + "linesMissed": self.stats.missed, + "coveragePercent": self.stats.percent, + "children": children, + }) + } +} diff --git a/src/defs.rs b/src/defs.rs index 3d4f1db22..9d567878a 100755 --- a/src/defs.rs +++ b/src/defs.rs @@ -1,7 +1,9 @@ use crossbeam::channel::{Receiver, Sender}; use rustc_hash::FxHashMap; +use std::cell::RefCell; use std::collections::BTreeMap; use std::path::PathBuf; +use std::rc::Rc; use std::sync::Mutex; #[derive(Debug, Clone, PartialEq)] @@ -52,3 +54,26 @@ pub type JobSender = Sender>; pub type CovResultMap = FxHashMap; pub type SyncCovResultMap = Mutex; pub type CovResultIter = Box>; + +#[derive(Debug, Default)] +pub struct CDStats { + pub total: usize, + pub covered: usize, + pub missed: usize, + pub percent: f64, +} + +#[derive(Debug)] +pub struct CDFileStats { + pub name: String, + pub stats: CDStats, + pub coverage: Vec, +} + +#[derive(Debug)] +pub struct CDDirStats { + pub name: String, + pub files: Vec, + pub dirs: Vec>>, + pub stats: CDStats, +} diff --git a/src/lib.rs b/src/lib.rs index 3d3b3f55b..cb4d4be7d 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,6 +35,9 @@ pub use crate::output::*; mod reader; pub use crate::reader::*; +mod covdir; +pub use crate::covdir::*; + use std::collections::{btree_map, hash_map}; use std::fs; use std::io::{BufReader, Cursor}; diff --git a/src/main.rs b/src/main.rs index 402ca6822..9ca9c0359 100755 --- a/src/main.rs +++ b/src/main.rs @@ -45,7 +45,7 @@ fn main() { .long("output-type") .value_name("OUTPUT TYPE") .default_value("lcov") - .possible_values(&["ade", "lcov", "coveralls", "coveralls+", "files"]) + .possible_values(&["ade", "lcov", "coveralls", "coveralls+", "files", "covdir"]) .takes_value(true)) .arg(Arg::with_name("output_file") @@ -315,6 +315,8 @@ fn main() { ); } else if output_type == "files" { output_files(iterator, output_file_path); + } else if output_type == "covdir" { + output_covdir(iterator, output_file_path); } else { assert!(false, "{} is not a supported output type", output_type); } diff --git a/src/output.rs b/src/output.rs index 0e817a6bc..4288eb0d9 100755 --- a/src/output.rs +++ b/src/output.rs @@ -1,8 +1,11 @@ +use rustc_hash::FxHashMap; use serde_json::{self, Value}; -use std::collections::BTreeSet; +use std::cell::RefCell; +use std::collections::{hash_map, BTreeSet}; use std::fs::File; use std::io::{self, BufWriter, Read, Write}; use std::path::PathBuf; +use std::rc::Rc; use uuid::Uuid; use md5::{Md5, Digest}; @@ -83,19 +86,19 @@ pub fn output_activedata_etl(results: CovResultIter, output_file: Option<&str>) writer, "{}", json!({ - "language": "c/c++", - "file": { - "name": rel_path, - }, - "method": { - "name": name, - "covered": lines_covered, - "uncovered": lines_uncovered, - "total_covered": lines_covered.len(), - "total_uncovered": lines_uncovered.len(), - "percentage_covered": lines_covered.len() as f32 / (lines_covered.len() + lines_uncovered.len()) as f32, - } - }) + "language": "c/c++", + "file": { + "name": rel_path, + }, + "method": { + "name": name, + "covered": lines_covered, + "uncovered": lines_uncovered, + "total_covered": lines_covered.len(), + "total_uncovered": lines_uncovered.len(), + "percentage_covered": lines_covered.len() as f32 / (lines_covered.len() + lines_uncovered.len()) as f32, + } + }) ).unwrap(); } @@ -107,28 +110,82 @@ pub fn output_activedata_etl(results: CovResultIter, output_file: Option<&str>) writer, "{}", json!({ - "language": "c/c++", - "is_file": true, - "file": { - "name": rel_path, - "covered": covered, - "uncovered": uncovered, - "total_covered": covered.len(), - "total_uncovered": uncovered.len(), - "percentage_covered": covered.len() as f32 / (covered.len() + uncovered.len()) as f32, - }, - "method": { - "covered": orphan_covered, - "uncovered": orphan_uncovered, - "total_covered": orphan_covered.len(), - "total_uncovered": orphan_uncovered.len(), - "percentage_covered": orphan_covered.len() as f32 / (orphan_covered.len() + orphan_uncovered.len()) as f32, - } - }) + "language": "c/c++", + "is_file": true, + "file": { + "name": rel_path, + "covered": covered, + "uncovered": uncovered, + "total_covered": covered.len(), + "total_uncovered": uncovered.len(), + "percentage_covered": covered.len() as f32 / (covered.len() + uncovered.len()) as f32, + }, + "method": { + "covered": orphan_covered, + "uncovered": orphan_uncovered, + "total_covered": orphan_covered.len(), + "total_uncovered": orphan_uncovered.len(), + "percentage_covered": orphan_covered.len() as f32 / (orphan_covered.len() + orphan_uncovered.len()) as f32, + } + }) ).unwrap(); } } +pub fn output_covdir(results: CovResultIter, output_file: Option<&str>) { + let mut writer = BufWriter::new(get_target_output_writable(output_file)); + let mut relative: FxHashMap>> = FxHashMap::default(); + let global = Rc::new(RefCell::new(CDDirStats::new("".to_string()))); + relative.insert(PathBuf::from(""), global.clone()); + + for (abs_path, rel_path, result) in results { + let path = if rel_path.is_relative() { + rel_path + } else { + abs_path + }; + + let parent = path.parent().unwrap(); + let mut ancestors = Vec::new(); + for ancestor in parent.ancestors() { + ancestors.push(ancestor); + if relative.contains_key(ancestor) { + break; + } + } + + let mut prev_stats = global.clone(); + + while let Some(ancestor) = ancestors.pop() { + prev_stats = match relative.entry(ancestor.to_path_buf()) { + hash_map::Entry::Occupied(s) => s.get().clone(), + hash_map::Entry::Vacant(p) => { + let mut prev_stats = prev_stats.borrow_mut(); + let path_tail = if ancestor == PathBuf::from("/") { + "/".to_string() + } else { + ancestor.file_name().unwrap().to_str().unwrap().to_string() + }; + prev_stats.dirs.push(Rc::new(RefCell::new(CDDirStats::new(path_tail)))); + let last = prev_stats.dirs.last_mut().unwrap(); + p.insert(last.clone()); + last.clone() + }, + }; + } + + prev_stats.borrow_mut().files.push(CDFileStats::new(path.file_name().unwrap().to_str().unwrap().to_string(), result.lines)); + } + + let mut global = global.borrow_mut(); + global.set_stats(); + + serde_json::to_writer( + &mut writer, + &global.to_json(), + ).unwrap(); +} + pub fn output_lcov(results: CovResultIter, output_file: Option<&str>) { let mut writer = BufWriter::new(get_target_output_writable(output_file)); writer.write_all(b"TN:\n").unwrap(); @@ -296,3 +353,65 @@ pub fn output_files(results: CovResultIter, output_file: Option<&str>) { writeln!(writer, "{}", rel_path.display()).unwrap(); } } + +#[cfg(test)] +mod tests { + + extern crate tempfile; + use super::*; + use std::collections::BTreeMap; + + fn read_file(path: &PathBuf) -> String { + let mut f = File::open(path).expect(format!("{:?} file not found", path.file_name()).as_str()); + let mut s = String::new(); + f.read_to_string(&mut s).unwrap(); + s + } + + #[test] + fn test_covdir() { + let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory"); + let file_name = "test_covdir.json"; + let file_path = tmp_dir.path().join(&file_name); + + let results = vec![ + (PathBuf::from("foo/bar/a.cpp"), + PathBuf::from("foo/bar/a.cpp"), + CovResult { + lines: [(1, 10), (2, 11)].iter().cloned().collect(), + branches: BTreeMap::new(), + functions: FxHashMap::default(), + }), + (PathBuf::from("foo/bar/b.cpp"), + PathBuf::from("foo/bar/b.cpp"), + CovResult { + lines: [(1, 0), (2, 10), (4, 0)].iter().cloned().collect(), + branches: BTreeMap::new(), + functions: FxHashMap::default(), + }), + (PathBuf::from("foo/c.cpp"), + PathBuf::from("foo/c.cpp"), + CovResult { + lines: [(1, 10), (4, 1)].iter().cloned().collect(), + branches: BTreeMap::new(), + functions: FxHashMap::default(), + }), + (PathBuf::from("/foo/d.cpp"), + PathBuf::from("/foo/d.cpp"), + CovResult { + lines: [(1, 10), (2, 0)].iter().cloned().collect(), + branches: BTreeMap::new(), + functions: FxHashMap::default(), + }), + ]; + + let results = Box::new(results.into_iter()); + output_covdir(results, Some(file_path.to_str().unwrap())); + + let results: Value = serde_json::from_str(&read_file(&file_path)).unwrap(); + let expected_path = PathBuf::from("./test/").join(&file_name); + let expected: Value = serde_json::from_str(&read_file(&expected_path)).unwrap(); + + assert_eq!(results, expected); + } +} diff --git a/src/path_rewriting.rs b/src/path_rewriting.rs index f44ca5d99..b8346a3fc 100755 --- a/src/path_rewriting.rs +++ b/src/path_rewriting.rs @@ -5,7 +5,7 @@ use std::collections::hash_map; use std::fs; use std::io; use std::mem; -use std::path::{Path, PathBuf}; +use std::path::{Component, Path, PathBuf}; use walkdir::{DirEntry, WalkDir}; use crate::defs::*; @@ -40,6 +40,16 @@ pub fn canonicalize_path>(path: P) -> io::Result { Ok(path) } +fn normalize_path>(path: P) -> PathBuf { + let mut new_path = PathBuf::from(""); + for component in path.as_ref().components() { + if component != Component::CurDir { + new_path.push(component); + } + } + new_path +} + // Search the source file's path in the mapping. fn apply_mapping(mapping: &Option, path: &str) -> PathBuf { if let Some(mapping) = mapping { @@ -121,6 +131,9 @@ fn get_abs_path( // Fixup the relative path, in case the absolute path was a symlink. let rel_path = fixup_rel_path(&source_dir, &abs_path, rel_path); + + // Normalize the path in removing './' or '//' + let rel_path = normalize_path(rel_path); (abs_path, rel_path) } @@ -1187,4 +1200,10 @@ mod tests { } assert_eq!(count, 1); } + + #[test] + fn test_normalize_path() { + assert_eq!(normalize_path("./foo//bar"), PathBuf::from("foo/bar")); + assert_eq!(normalize_path("./foo/./bar/./oof/"), PathBuf::from("foo/bar/oof")); + } } diff --git a/test/test_covdir.json b/test/test_covdir.json new file mode 100644 index 000000000..436145de6 --- /dev/null +++ b/test/test_covdir.json @@ -0,0 +1,93 @@ +{ + "children": { + "/": { + "children": { + "foo": { + "children": { + "d.cpp": { + "coverage": [ + 10, + 0 + ], + "coveragePercent": 50.0, + "linesCovered": 1, + "linesMissed": 1, + "linesTotal": 2, + "name": "d.cpp" + } + }, + "coveragePercent": 50.0, + "linesCovered": 1, + "linesMissed": 1, + "linesTotal": 2, + "name": "foo" + } + }, + "coveragePercent": 50.0, + "linesCovered": 1, + "linesMissed": 1, + "linesTotal": 2, + "name": "/" + }, + "foo": { + "children": { + "bar": { + "children": { + "a.cpp": { + "coverage": [ + 10, + 11 + ], + "coveragePercent": 100.0, + "linesCovered": 2, + "linesMissed": 0, + "linesTotal": 2, + "name": "a.cpp" + }, + "b.cpp": { + "coverage": [ + 0, + 10, + -1, + 0 + ], + "coveragePercent": 33.33, + "linesCovered": 1, + "linesMissed": 2, + "linesTotal": 3, + "name": "b.cpp" + } + }, + "coveragePercent": 60.0, + "linesCovered": 3, + "linesMissed": 2, + "linesTotal": 5, + "name": "bar" + }, + "c.cpp": { + "coverage": [ + 10, + -1, + -1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 2, + "linesMissed": 0, + "linesTotal": 2, + "name": "c.cpp" + } + }, + "coveragePercent": 71.43, + "linesCovered": 5, + "linesMissed": 2, + "linesTotal": 7, + "name": "foo" + } + }, + "coveragePercent": 66.67, + "linesCovered": 6, + "linesMissed": 3, + "linesTotal": 9, + "name": "" +} diff --git a/tests/basic/expected_gcc.covdir b/tests/basic/expected_gcc.covdir new file mode 100644 index 000000000..2e5a2a869 --- /dev/null +++ b/tests/basic/expected_gcc.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + 1, + -1, + 10, + 9, + 3, + -1, + -1, + 9, + 0, + -1, + -1, + -1, + 1 + ], + "coveragePercent": 85.71, + "linesCovered": 6, + "linesMissed": 1, + "linesTotal": 7, + "name": "main.c" + } + }, + "coveragePercent": 85.71, + "linesCovered": 6, + "linesMissed": 1, + "linesTotal": 7, + "name": "" +} diff --git a/tests/basic/expected_llvm.covdir b/tests/basic/expected_llvm.covdir new file mode 100644 index 000000000..9b159317f --- /dev/null +++ b/tests/basic/expected_llvm.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + 1, + -1, + 10, + 9, + 3, + 3, + -1, + 9, + 0, + 0, + 9, + -1, + 1 + ], + "coveragePercent": 80.0, + "linesCovered": 8, + "linesMissed": 2, + "linesTotal": 10, + "name": "main.c" + } + }, + "coveragePercent": 80.0, + "linesCovered": 8, + "linesMissed": 2, + "linesTotal": 10, + "name": "" +} diff --git a/tests/basic/expected_llvm_7.covdir b/tests/basic/expected_llvm_7.covdir new file mode 100644 index 000000000..9a92c1e8a --- /dev/null +++ b/tests/basic/expected_llvm_7.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + -1, + -1, + 10, + 9, + 3, + 3, + -1, + 9, + 0, + 0, + 9, + -1, + 1 + ], + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "main.c" + } + }, + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "" +} diff --git a/tests/basic/expected_llvm_mac.covdir b/tests/basic/expected_llvm_mac.covdir new file mode 100644 index 000000000..9a92c1e8a --- /dev/null +++ b/tests/basic/expected_llvm_mac.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + -1, + -1, + 10, + 9, + 3, + 3, + -1, + 9, + 0, + 0, + 9, + -1, + 1 + ], + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "main.c" + } + }, + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "" +} diff --git a/tests/basic_zip_dir/expected_gcc.covdir b/tests/basic_zip_dir/expected_gcc.covdir new file mode 100644 index 000000000..2e5a2a869 --- /dev/null +++ b/tests/basic_zip_dir/expected_gcc.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + 1, + -1, + 10, + 9, + 3, + -1, + -1, + 9, + 0, + -1, + -1, + -1, + 1 + ], + "coveragePercent": 85.71, + "linesCovered": 6, + "linesMissed": 1, + "linesTotal": 7, + "name": "main.c" + } + }, + "coveragePercent": 85.71, + "linesCovered": 6, + "linesMissed": 1, + "linesTotal": 7, + "name": "" +} diff --git a/tests/basic_zip_dir/expected_llvm.covdir b/tests/basic_zip_dir/expected_llvm.covdir new file mode 100644 index 000000000..9b159317f --- /dev/null +++ b/tests/basic_zip_dir/expected_llvm.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + 1, + -1, + 10, + 9, + 3, + 3, + -1, + 9, + 0, + 0, + 9, + -1, + 1 + ], + "coveragePercent": 80.0, + "linesCovered": 8, + "linesMissed": 2, + "linesTotal": 10, + "name": "main.c" + } + }, + "coveragePercent": 80.0, + "linesCovered": 8, + "linesMissed": 2, + "linesTotal": 10, + "name": "" +} diff --git a/tests/basic_zip_dir/expected_llvm_7.covdir b/tests/basic_zip_dir/expected_llvm_7.covdir new file mode 100644 index 000000000..9a92c1e8a --- /dev/null +++ b/tests/basic_zip_dir/expected_llvm_7.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + -1, + -1, + 10, + 9, + 3, + 3, + -1, + 9, + 0, + 0, + 9, + -1, + 1 + ], + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "main.c" + } + }, + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "" +} diff --git a/tests/basic_zip_dir/expected_llvm_mac.covdir b/tests/basic_zip_dir/expected_llvm_mac.covdir new file mode 100644 index 000000000..9a92c1e8a --- /dev/null +++ b/tests/basic_zip_dir/expected_llvm_mac.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + -1, + -1, + 10, + 9, + 3, + 3, + -1, + 9, + 0, + 0, + 9, + -1, + 1 + ], + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "main.c" + } + }, + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "" +} diff --git a/tests/basic_zip_zip/expected_gcc.covdir b/tests/basic_zip_zip/expected_gcc.covdir new file mode 100644 index 000000000..2e5a2a869 --- /dev/null +++ b/tests/basic_zip_zip/expected_gcc.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + 1, + -1, + 10, + 9, + 3, + -1, + -1, + 9, + 0, + -1, + -1, + -1, + 1 + ], + "coveragePercent": 85.71, + "linesCovered": 6, + "linesMissed": 1, + "linesTotal": 7, + "name": "main.c" + } + }, + "coveragePercent": 85.71, + "linesCovered": 6, + "linesMissed": 1, + "linesTotal": 7, + "name": "" +} diff --git a/tests/basic_zip_zip/expected_llvm.covdir b/tests/basic_zip_zip/expected_llvm.covdir new file mode 100644 index 000000000..9b159317f --- /dev/null +++ b/tests/basic_zip_zip/expected_llvm.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + 1, + -1, + 10, + 9, + 3, + 3, + -1, + 9, + 0, + 0, + 9, + -1, + 1 + ], + "coveragePercent": 80.0, + "linesCovered": 8, + "linesMissed": 2, + "linesTotal": 10, + "name": "main.c" + } + }, + "coveragePercent": 80.0, + "linesCovered": 8, + "linesMissed": 2, + "linesTotal": 10, + "name": "" +} diff --git a/tests/basic_zip_zip/expected_llvm_7.covdir b/tests/basic_zip_zip/expected_llvm_7.covdir new file mode 100644 index 000000000..9a92c1e8a --- /dev/null +++ b/tests/basic_zip_zip/expected_llvm_7.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + -1, + -1, + 10, + 9, + 3, + 3, + -1, + 9, + 0, + 0, + 9, + -1, + 1 + ], + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "main.c" + } + }, + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "" +} diff --git a/tests/basic_zip_zip/expected_llvm_mac.covdir b/tests/basic_zip_zip/expected_llvm_mac.covdir new file mode 100644 index 000000000..9a92c1e8a --- /dev/null +++ b/tests/basic_zip_zip/expected_llvm_mac.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + -1, + -1, + 10, + 9, + 3, + 3, + -1, + 9, + 0, + 0, + 9, + -1, + 1 + ], + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "main.c" + } + }, + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "" +} diff --git a/tests/basic_zip_zip/expected_no_gcda_gcc.covdir b/tests/basic_zip_zip/expected_no_gcda_gcc.covdir new file mode 100644 index 000000000..69d609bd5 --- /dev/null +++ b/tests/basic_zip_zip/expected_no_gcda_gcc.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + 0, + -1, + 0, + 0, + 0, + -1, + -1, + 0, + 0, + -1, + -1, + -1, + 0 + ], + "coveragePercent": 0.0, + "linesCovered": 0, + "linesMissed": 7, + "linesTotal": 7, + "name": "main.c" + } + }, + "coveragePercent": 0.0, + "linesCovered": 0, + "linesMissed": 7, + "linesTotal": 7, + "name": "" +} diff --git a/tests/basic_zip_zip/expected_no_gcda_llvm.covdir b/tests/basic_zip_zip/expected_no_gcda_llvm.covdir new file mode 100644 index 000000000..69762ce47 --- /dev/null +++ b/tests/basic_zip_zip/expected_no_gcda_llvm.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + 0, + -1, + 0, + 0, + 0, + 0, + -1, + 0, + 0, + 0, + 0, + -1, + 0 + ], + "coveragePercent": 0.0, + "linesCovered": 0, + "linesMissed": 10, + "linesTotal": 10, + "name": "main.c" + } + }, + "coveragePercent": 0.0, + "linesCovered": 0, + "linesMissed": 10, + "linesTotal": 10, + "name": "" +} diff --git a/tests/basic_zip_zip/expected_no_gcda_llvm_7.covdir b/tests/basic_zip_zip/expected_no_gcda_llvm_7.covdir new file mode 100644 index 000000000..d8f043d16 --- /dev/null +++ b/tests/basic_zip_zip/expected_no_gcda_llvm_7.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + -1, + -1, + 0, + 0, + 0, + 0, + -1, + 0, + 0, + 0, + 0, + -1, + 0 + ], + "coveragePercent": 0.0, + "linesCovered": 0, + "linesMissed": 9, + "linesTotal": 9, + "name": "main.c" + } + }, + "coveragePercent": 0.0, + "linesCovered": 0, + "linesMissed": 9, + "linesTotal": 9, + "name": "" +} diff --git a/tests/basic_zip_zip/expected_no_gcda_llvm_mac.covdir b/tests/basic_zip_zip/expected_no_gcda_llvm_mac.covdir new file mode 100644 index 000000000..d8f043d16 --- /dev/null +++ b/tests/basic_zip_zip/expected_no_gcda_llvm_mac.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + -1, + -1, + 0, + 0, + 0, + 0, + -1, + 0, + 0, + 0, + 0, + -1, + 0 + ], + "coveragePercent": 0.0, + "linesCovered": 0, + "linesMissed": 9, + "linesTotal": 9, + "name": "main.c" + } + }, + "coveragePercent": 0.0, + "linesCovered": 0, + "linesMissed": 9, + "linesTotal": 9, + "name": "" +} diff --git a/tests/basic_zip_zip/expected_two_gcda_gcc.covdir b/tests/basic_zip_zip/expected_two_gcda_gcc.covdir new file mode 100644 index 000000000..fdabc14db --- /dev/null +++ b/tests/basic_zip_zip/expected_two_gcda_gcc.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + 2, + -1, + 20, + 18, + 6, + -1, + -1, + 18, + 0, + -1, + -1, + -1, + 2 + ], + "coveragePercent": 85.71, + "linesCovered": 6, + "linesMissed": 1, + "linesTotal": 7, + "name": "main.c" + } + }, + "coveragePercent": 85.71, + "linesCovered": 6, + "linesMissed": 1, + "linesTotal": 7, + "name": "" +} diff --git a/tests/basic_zip_zip/expected_two_gcda_llvm.covdir b/tests/basic_zip_zip/expected_two_gcda_llvm.covdir new file mode 100644 index 000000000..43bacad66 --- /dev/null +++ b/tests/basic_zip_zip/expected_two_gcda_llvm.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + 2, + -1, + 20, + 18, + 6, + 6, + -1, + 18, + 0, + 0, + 18, + -1, + 2 + ], + "coveragePercent": 80.0, + "linesCovered": 8, + "linesMissed": 2, + "linesTotal": 10, + "name": "main.c" + } + }, + "coveragePercent": 80.0, + "linesCovered": 8, + "linesMissed": 2, + "linesTotal": 10, + "name": "" +} diff --git a/tests/basic_zip_zip/expected_two_gcda_llvm_7.covdir b/tests/basic_zip_zip/expected_two_gcda_llvm_7.covdir new file mode 100644 index 000000000..e0cc47c79 --- /dev/null +++ b/tests/basic_zip_zip/expected_two_gcda_llvm_7.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + -1, + -1, + 20, + 18, + 6, + 6, + -1, + 18, + 0, + 0, + 18, + -1, + 2 + ], + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "main.c" + } + }, + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "" +} diff --git a/tests/basic_zip_zip/expected_two_gcda_llvm_mac.covdir b/tests/basic_zip_zip/expected_two_gcda_llvm_mac.covdir new file mode 100644 index 000000000..e0cc47c79 --- /dev/null +++ b/tests/basic_zip_zip/expected_two_gcda_llvm_mac.covdir @@ -0,0 +1,33 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + -1, + -1, + 20, + 18, + 6, + 6, + -1, + 18, + 0, + 0, + 18, + -1, + 2 + ], + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "main.c" + } + }, + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "" +} diff --git a/tests/class/expected_gcc.covdir b/tests/class/expected_gcc.covdir new file mode 100644 index 000000000..637f3e350 --- /dev/null +++ b/tests/class/expected_gcc.covdir @@ -0,0 +1,54 @@ +{ + "children": { + "main.cpp": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 2, + -1, + 1, + 1, + 1, + -1, + 2, + 2, + -1, + -1, + 0, + 0, + 0, + -1, + -1, + -1, + -1, + -1, + 1, + -1, + 2, + -1, + 1, + 1, + -1, + 1, + 0, + -1, + -1, + 1, + 3 + ], + "coveragePercent": 76.47, + "linesCovered": 13, + "linesMissed": 4, + "linesTotal": 17, + "name": "main.cpp" + } + }, + "coveragePercent": 76.47, + "linesCovered": 13, + "linesMissed": 4, + "linesTotal": 17, + "name": "" +} diff --git a/tests/class/expected_gcc_7.covdir b/tests/class/expected_gcc_7.covdir new file mode 100644 index 000000000..637f3e350 --- /dev/null +++ b/tests/class/expected_gcc_7.covdir @@ -0,0 +1,54 @@ +{ + "children": { + "main.cpp": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 2, + -1, + 1, + 1, + 1, + -1, + 2, + 2, + -1, + -1, + 0, + 0, + 0, + -1, + -1, + -1, + -1, + -1, + 1, + -1, + 2, + -1, + 1, + 1, + -1, + 1, + 0, + -1, + -1, + 1, + 3 + ], + "coveragePercent": 76.47, + "linesCovered": 13, + "linesMissed": 4, + "linesTotal": 17, + "name": "main.cpp" + } + }, + "coveragePercent": 76.47, + "linesCovered": 13, + "linesMissed": 4, + "linesTotal": 17, + "name": "" +} diff --git a/tests/class/expected_llvm.covdir b/tests/class/expected_llvm.covdir new file mode 100644 index 000000000..970bfc0a1 --- /dev/null +++ b/tests/class/expected_llvm.covdir @@ -0,0 +1,54 @@ +{ + "children": { + "main.cpp": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 2, + -1, + 1, + 1, + 1, + -1, + 2, + 2, + -1, + -1, + 0, + 0, + 0, + -1, + -1, + -1, + -1, + -1, + 1, + -1, + 1, + -1, + 1, + 1, + -1, + 1, + 0, + 0, + -1, + 1, + 1 + ], + "coveragePercent": 72.22, + "linesCovered": 13, + "linesMissed": 5, + "linesTotal": 18, + "name": "main.cpp" + } + }, + "coveragePercent": 72.22, + "linesCovered": 13, + "linesMissed": 5, + "linesTotal": 18, + "name": "" +} diff --git a/tests/class/expected_llvm_7_linux.covdir b/tests/class/expected_llvm_7_linux.covdir new file mode 100644 index 000000000..9fc2736d5 --- /dev/null +++ b/tests/class/expected_llvm_7_linux.covdir @@ -0,0 +1,54 @@ +{ + "children": { + "main.cpp": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 2, + -1, + -1, + 1, + 1, + -1, + -1, + 2, + -1, + -1, + -1, + 0, + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 1, + -1, + 1, + 1, + -1, + 1, + 0, + 0, + -1, + 1, + 1 + ], + "coveragePercent": 71.43, + "linesCovered": 10, + "linesMissed": 4, + "linesTotal": 14, + "name": "main.cpp" + } + }, + "coveragePercent": 71.43, + "linesCovered": 10, + "linesMissed": 4, + "linesTotal": 14, + "name": "" +} diff --git a/tests/class/expected_llvm_mac.covdir b/tests/class/expected_llvm_mac.covdir new file mode 100644 index 000000000..b5e1dfbe3 --- /dev/null +++ b/tests/class/expected_llvm_mac.covdir @@ -0,0 +1,54 @@ +{ + "children": { + "main.cpp": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 4, + -1, + -1, + 1, + 1, + -1, + -1, + 2, + -1, + -1, + -1, + 0, + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + 1, + -1, + 1, + 1, + -1, + 1, + 0, + 0, + -1, + 1, + 1 + ], + "coveragePercent": 71.43, + "linesCovered": 10, + "linesMissed": 4, + "linesTotal": 14, + "name": "main.cpp" + } + }, + "coveragePercent": 71.43, + "linesCovered": 10, + "linesMissed": 4, + "linesTotal": 14, + "name": "" +} diff --git a/tests/include/expected_gcc.covdir b/tests/include/expected_gcc.covdir new file mode 100644 index 000000000..1dd7aaa03 --- /dev/null +++ b/tests/include/expected_gcc.covdir @@ -0,0 +1,69 @@ +{ + "children": { + "file.cpp": { + "coverage": [ + -1, + -1, + 1, + 1, + 1, + -1, + 1, + 1, + 1, + 3 + ], + "coveragePercent": 100.0, + "linesCovered": 7, + "linesMissed": 0, + "linesTotal": 7, + "name": "file.cpp" + }, + "include.h": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 2, + -1, + -1, + -1, + 1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 4, + "linesMissed": 0, + "linesTotal": 4, + "name": "include.h" + }, + "main.cpp": { + "coverage": [ + -1, + -1, + 1, + -1, + 2, + -1, + 1, + 2, + -1, + 1, + 3 + ], + "coveragePercent": 100.0, + "linesCovered": 6, + "linesMissed": 0, + "linesTotal": 6, + "name": "main.cpp" + } + }, + "coveragePercent": 100.0, + "linesCovered": 17, + "linesMissed": 0, + "linesTotal": 17, + "name": "" +} diff --git a/tests/include/expected_llvm.ade b/tests/include/expected_llvm.ade index a69db758b..fdd709c41 100644 --- a/tests/include/expected_llvm.ade +++ b/tests/include/expected_llvm.ade @@ -1,9 +1,9 @@ {"file":{"name":"file.cpp"},"language":"c/c++","method":{"covered":[7,8,9],"name":"_ZN4Ciao7getNameB5cxx11Ev","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]}} {"file":{"name":"file.cpp"},"language":"c/c++","method":{"covered":[3,4,5],"name":"_ZN4Ciao7setNameENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]}} {"file":{"covered":[3,4,5,7,8,9],"name":"file.cpp","percentage_covered":1.0,"total_covered":6,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoD2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[10,11,12],"name":"_ZN4Ciao14calledFromFileEv","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} -{"file":{"covered":[6,10,11,12],"name":"./include.h","percentage_covered":1.0,"total_covered":4,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoD2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[10,11,12],"name":"_ZN4Ciao14calledFromFileEv","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} +{"file":{"covered":[6,10,11,12],"name":"include.h","percentage_covered":1.0,"total_covered":4,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} {"file":{"name":"main.cpp"},"language":"c/c++","method":{"covered":[3,5,7,8,10,11],"name":"main","percentage_covered":1.0,"total_covered":6,"total_uncovered":0,"uncovered":[]}} {"file":{"covered":[3,5,7,8,10,11],"name":"main.cpp","percentage_covered":1.0,"total_covered":6,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} diff --git a/tests/include/expected_llvm.covdir b/tests/include/expected_llvm.covdir new file mode 100644 index 000000000..7d54dc531 --- /dev/null +++ b/tests/include/expected_llvm.covdir @@ -0,0 +1,68 @@ +{ + "children": { + "file.cpp": { + "coverage": [ + -1, + -1, + 1, + 1, + 1, + -1, + 1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 6, + "linesMissed": 0, + "linesTotal": 6, + "name": "file.cpp" + }, + "include.h": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 2, + -1, + -1, + -1, + 1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 4, + "linesMissed": 0, + "linesTotal": 4, + "name": "include.h" + }, + "main.cpp": { + "coverage": [ + -1, + -1, + 1, + -1, + 1, + -1, + 1, + 1, + -1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 6, + "linesMissed": 0, + "linesTotal": 6, + "name": "main.cpp" + } + }, + "coveragePercent": 100.0, + "linesCovered": 16, + "linesMissed": 0, + "linesTotal": 16, + "name": "" +} diff --git a/tests/include/expected_llvm_7_linux.ade b/tests/include/expected_llvm_7_linux.ade index b6ff18098..29055177d 100644 --- a/tests/include/expected_llvm_7_linux.ade +++ b/tests/include/expected_llvm_7_linux.ade @@ -1,7 +1,7 @@ -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoD2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[11,12],"name":"_ZN4Ciao14calledFromFileEv","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}} -{"file":{"covered":[6,11,12],"name":"./include.h","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoD2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[11,12],"name":"_ZN4Ciao14calledFromFileEv","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}} +{"file":{"covered":[6,11,12],"name":"include.h","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} {"file":{"name":"main.cpp"},"language":"c/c++","method":{"covered":[5,7,8,10,11],"name":"main","percentage_covered":1.0,"total_covered":5,"total_uncovered":0,"uncovered":[]}} {"file":{"covered":[5,7,8,10,11],"name":"main.cpp","percentage_covered":1.0,"total_covered":5,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} {"file":{"name":"file.cpp"},"language":"c/c++","method":{"covered":[4,5],"name":"_ZN4Ciao7setNameENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}} diff --git a/tests/include/expected_llvm_7_linux.covdir b/tests/include/expected_llvm_7_linux.covdir new file mode 100644 index 000000000..0a9596806 --- /dev/null +++ b/tests/include/expected_llvm_7_linux.covdir @@ -0,0 +1,68 @@ +{ + "children": { + "file.cpp": { + "coverage": [ + -1, + -1, + -1, + 1, + 1, + -1, + -1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 4, + "linesMissed": 0, + "linesTotal": 4, + "name": "file.cpp" + }, + "include.h": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 2, + -1, + -1, + -1, + -1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 3, + "linesMissed": 0, + "linesTotal": 3, + "name": "include.h" + }, + "main.cpp": { + "coverage": [ + -1, + -1, + -1, + -1, + 1, + -1, + 1, + 1, + -1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 5, + "linesMissed": 0, + "linesTotal": 5, + "name": "main.cpp" + } + }, + "coveragePercent": 100.0, + "linesCovered": 12, + "linesMissed": 0, + "linesTotal": 12, + "name": "" +} diff --git a/tests/include/expected_llvm_mac.ade b/tests/include/expected_llvm_mac.ade index 56c811852..b9e7bddb3 100644 --- a/tests/include/expected_llvm_mac.ade +++ b/tests/include/expected_llvm_mac.ade @@ -3,9 +3,9 @@ {"file":{"name":"file.cpp"},"language":"c/c++","method":{"covered":[4,5],"name":"_ZN4Ciao7setNameENSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}} {"file":{"name":"file.cpp"},"language":"c/c++","method":{"covered":[8,9],"name":"_ZN4Ciao7getNameEv","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}} {"file":{"covered":[4,5,8,9],"name":"file.cpp","percentage_covered":1.0,"total_covered":4,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoC1Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoD1Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoD2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[11,12],"name":"_ZN4Ciao14calledFromFileEv","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} -{"file":{"covered":[6,11,12],"name":"./include.h","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoC1Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoD1Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoD2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[11,12],"name":"_ZN4Ciao14calledFromFileEv","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} +{"file":{"covered":[6,11,12],"name":"include.h","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} diff --git a/tests/include/expected_llvm_mac.covdir b/tests/include/expected_llvm_mac.covdir new file mode 100644 index 000000000..9dcb64f66 --- /dev/null +++ b/tests/include/expected_llvm_mac.covdir @@ -0,0 +1,68 @@ +{ + "children": { + "file.cpp": { + "coverage": [ + -1, + -1, + -1, + 1, + 1, + -1, + -1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 4, + "linesMissed": 0, + "linesTotal": 4, + "name": "file.cpp" + }, + "include.h": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 2, + -1, + -1, + -1, + -1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 3, + "linesMissed": 0, + "linesTotal": 3, + "name": "include.h" + }, + "main.cpp": { + "coverage": [ + -1, + -1, + -1, + -1, + 1, + -1, + 4, + 1, + -1, + 1, + 2 + ], + "coveragePercent": 100.0, + "linesCovered": 5, + "linesMissed": 0, + "linesTotal": 5, + "name": "main.cpp" + } + }, + "coveragePercent": 100.0, + "linesCovered": 12, + "linesMissed": 0, + "linesTotal": 12, + "name": "" +} diff --git a/tests/include2/expected_gcc.covdir b/tests/include2/expected_gcc.covdir new file mode 100644 index 000000000..2c8f64d28 --- /dev/null +++ b/tests/include2/expected_gcc.covdir @@ -0,0 +1,73 @@ +{ + "children": { + "file.cpp": { + "coverage": [ + -1, + -1, + 1, + 1, + 1, + -1, + 1, + 1, + 1, + 3 + ], + "coveragePercent": 100.0, + "linesCovered": 7, + "linesMissed": 0, + "linesTotal": 7, + "name": "file.cpp" + }, + "include.h": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 2, + -1, + -1, + -1, + 1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 4, + "linesMissed": 0, + "linesTotal": 4, + "name": "include.h" + }, + "main.cpp": { + "coverage": [ + -1, + -1, + 1, + -1, + 2, + -1, + 1, + 2, + -1, + 1, + 0, + -1, + -1, + 1, + 3 + ], + "coveragePercent": 87.5, + "linesCovered": 7, + "linesMissed": 1, + "linesTotal": 8, + "name": "main.cpp" + } + }, + "coveragePercent": 94.74, + "linesCovered": 18, + "linesMissed": 1, + "linesTotal": 19, + "name": "" +} diff --git a/tests/include2/expected_gcc_7.covdir b/tests/include2/expected_gcc_7.covdir new file mode 100644 index 000000000..2c8f64d28 --- /dev/null +++ b/tests/include2/expected_gcc_7.covdir @@ -0,0 +1,73 @@ +{ + "children": { + "file.cpp": { + "coverage": [ + -1, + -1, + 1, + 1, + 1, + -1, + 1, + 1, + 1, + 3 + ], + "coveragePercent": 100.0, + "linesCovered": 7, + "linesMissed": 0, + "linesTotal": 7, + "name": "file.cpp" + }, + "include.h": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 2, + -1, + -1, + -1, + 1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 4, + "linesMissed": 0, + "linesTotal": 4, + "name": "include.h" + }, + "main.cpp": { + "coverage": [ + -1, + -1, + 1, + -1, + 2, + -1, + 1, + 2, + -1, + 1, + 0, + -1, + -1, + 1, + 3 + ], + "coveragePercent": 87.5, + "linesCovered": 7, + "linesMissed": 1, + "linesTotal": 8, + "name": "main.cpp" + } + }, + "coveragePercent": 94.74, + "linesCovered": 18, + "linesMissed": 1, + "linesTotal": 19, + "name": "" +} diff --git a/tests/include2/expected_llvm.ade b/tests/include2/expected_llvm.ade index 56ff4d6bd..218672130 100644 --- a/tests/include2/expected_llvm.ade +++ b/tests/include2/expected_llvm.ade @@ -1,7 +1,7 @@ -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[10,11,12],"name":"_ZN4Ciao14calledFromFileEv","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoD2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} -{"file":{"covered":[6,10,11,12],"name":"./include.h","percentage_covered":1.0,"total_covered":4,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[10,11,12],"name":"_ZN4Ciao14calledFromFileEv","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoD2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} +{"file":{"covered":[6,10,11,12],"name":"include.h","percentage_covered":1.0,"total_covered":4,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} {"file":{"name":"file.cpp"},"language":"c/c++","method":{"covered":[7,8,9],"name":"_ZN4Ciao7getNameB5cxx11Ev","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]}} {"file":{"name":"file.cpp"},"language":"c/c++","method":{"covered":[3,4,5],"name":"_ZN4Ciao7setNameENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]}} {"file":{"covered":[3,4,5,7,8,9],"name":"file.cpp","percentage_covered":1.0,"total_covered":6,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} diff --git a/tests/include2/expected_llvm.covdir b/tests/include2/expected_llvm.covdir new file mode 100644 index 000000000..3d70aa768 --- /dev/null +++ b/tests/include2/expected_llvm.covdir @@ -0,0 +1,72 @@ +{ + "children": { + "file.cpp": { + "coverage": [ + -1, + -1, + 1, + 1, + 1, + -1, + 1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 6, + "linesMissed": 0, + "linesTotal": 6, + "name": "file.cpp" + }, + "include.h": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 2, + -1, + -1, + -1, + 1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 4, + "linesMissed": 0, + "linesTotal": 4, + "name": "include.h" + }, + "main.cpp": { + "coverage": [ + -1, + -1, + 1, + -1, + 1, + -1, + 1, + 1, + -1, + 1, + 0, + 0, + -1, + 1, + 1 + ], + "coveragePercent": 77.78, + "linesCovered": 7, + "linesMissed": 2, + "linesTotal": 9, + "name": "main.cpp" + } + }, + "coveragePercent": 89.47, + "linesCovered": 17, + "linesMissed": 2, + "linesTotal": 19, + "name": "" +} diff --git a/tests/include2/expected_llvm_7_linux.ade b/tests/include2/expected_llvm_7_linux.ade index 372454b2b..8478c6d59 100644 --- a/tests/include2/expected_llvm_7_linux.ade +++ b/tests/include2/expected_llvm_7_linux.ade @@ -1,7 +1,7 @@ -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[11,12],"name":"_ZN4Ciao14calledFromFileEv","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoD2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} -{"file":{"covered":[6,11,12],"name":"./include.h","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[11,12],"name":"_ZN4Ciao14calledFromFileEv","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoD2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} +{"file":{"covered":[6,11,12],"name":"include.h","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} {"file":{"name":"file.cpp"},"language":"c/c++","method":{"covered":[8,9],"name":"_ZN4Ciao7getNameB5cxx11Ev","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}} {"file":{"name":"file.cpp"},"language":"c/c++","method":{"covered":[4,5],"name":"_ZN4Ciao7setNameENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}} {"file":{"covered":[4,5,8,9],"name":"file.cpp","percentage_covered":1.0,"total_covered":4,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} diff --git a/tests/include2/expected_llvm_7_linux.covdir b/tests/include2/expected_llvm_7_linux.covdir new file mode 100644 index 000000000..95770b302 --- /dev/null +++ b/tests/include2/expected_llvm_7_linux.covdir @@ -0,0 +1,72 @@ +{ + "children": { + "file.cpp": { + "coverage": [ + -1, + -1, + -1, + 1, + 1, + -1, + -1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 4, + "linesMissed": 0, + "linesTotal": 4, + "name": "file.cpp" + }, + "include.h": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 2, + -1, + -1, + -1, + -1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 3, + "linesMissed": 0, + "linesTotal": 3, + "name": "include.h" + }, + "main.cpp": { + "coverage": [ + -1, + -1, + -1, + -1, + 1, + -1, + 1, + 1, + -1, + 1, + 0, + 0, + -1, + 1, + 1 + ], + "coveragePercent": 75.0, + "linesCovered": 6, + "linesMissed": 2, + "linesTotal": 8, + "name": "main.cpp" + } + }, + "coveragePercent": 86.67, + "linesCovered": 13, + "linesMissed": 2, + "linesTotal": 15, + "name": "" +} diff --git a/tests/include2/expected_llvm_mac.ade b/tests/include2/expected_llvm_mac.ade index a2796e894..faa5369a3 100644 --- a/tests/include2/expected_llvm_mac.ade +++ b/tests/include2/expected_llvm_mac.ade @@ -1,11 +1,11 @@ {"file":{"name":"main.cpp"},"language":"c/c++","method":{"covered":[5,7,8,10,14,15],"name":"main","percentage_covered":0.75,"total_covered":6,"total_uncovered":2,"uncovered":[11,12]}} {"file":{"covered":[5,7,8,10,14,15],"name":"main.cpp","percentage_covered":0.75,"total_covered":6,"total_uncovered":2,"uncovered":[11,12]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[11,12],"name":"_ZN4Ciao14calledFromFileEv","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoD1Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoC1Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} -{"file":{"name":"./include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoD2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} -{"file":{"covered":[6,11,12],"name":"./include.h","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[11,12],"name":"_ZN4Ciao14calledFromFileEv","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoD1Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoC1Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} +{"file":{"name":"include.h"},"language":"c/c++","method":{"covered":[6],"name":"_ZN4CiaoD2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}} +{"file":{"covered":[6,11,12],"name":"include.h","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} {"file":{"name":"file.cpp"},"language":"c/c++","method":{"covered":[4,5],"name":"_ZN4Ciao7setNameENSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}} {"file":{"name":"file.cpp"},"language":"c/c++","method":{"covered":[8,9],"name":"_ZN4Ciao7getNameEv","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}} {"file":{"covered":[4,5,8,9],"name":"file.cpp","percentage_covered":1.0,"total_covered":4,"total_uncovered":0,"uncovered":[]},"is_file":true,"language":"c/c++","method":{"covered":[],"percentage_covered":null,"total_covered":0,"total_uncovered":0,"uncovered":[]}} diff --git a/tests/include2/expected_llvm_mac.covdir b/tests/include2/expected_llvm_mac.covdir new file mode 100644 index 000000000..8e1667a02 --- /dev/null +++ b/tests/include2/expected_llvm_mac.covdir @@ -0,0 +1,72 @@ +{ + "children": { + "file.cpp": { + "coverage": [ + -1, + -1, + -1, + 1, + 1, + -1, + -1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 4, + "linesMissed": 0, + "linesTotal": 4, + "name": "file.cpp" + }, + "include.h": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 2, + -1, + -1, + -1, + -1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 3, + "linesMissed": 0, + "linesTotal": 3, + "name": "include.h" + }, + "main.cpp": { + "coverage": [ + -1, + -1, + -1, + -1, + 1, + -1, + 4, + 1, + -1, + 2, + 0, + 0, + -1, + 1, + 2 + ], + "coveragePercent": 75.0, + "linesCovered": 6, + "linesMissed": 2, + "linesTotal": 8, + "name": "main.cpp" + } + }, + "coveragePercent": 86.67, + "linesCovered": 13, + "linesMissed": 2, + "linesTotal": 15, + "name": "" +} diff --git a/tests/switch/expected_gcc.covdir b/tests/switch/expected_gcc.covdir new file mode 100644 index 000000000..e8128beae --- /dev/null +++ b/tests/switch/expected_gcc.covdir @@ -0,0 +1,55 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + 1, + -1, + 10, + 9, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 0, + 0, + -1, + -1, + -1, + 1 + ], + "coveragePercent": 90.91, + "linesCovered": 20, + "linesMissed": 2, + "linesTotal": 22, + "name": "main.c" + } + }, + "coveragePercent": 90.91, + "linesCovered": 20, + "linesMissed": 2, + "linesTotal": 22, + "name": "" +} diff --git a/tests/switch/expected_gcc_7.covdir b/tests/switch/expected_gcc_7.covdir new file mode 100644 index 000000000..045de6bac --- /dev/null +++ b/tests/switch/expected_gcc_7.covdir @@ -0,0 +1,55 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + 1, + -1, + 10, + 9, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + -1, + -1, + -1, + 1 + ], + "coveragePercent": 90.32, + "linesCovered": 28, + "linesMissed": 3, + "linesTotal": 31, + "name": "main.c" + } + }, + "coveragePercent": 90.32, + "linesCovered": 28, + "linesMissed": 3, + "linesTotal": 31, + "name": "" +} diff --git a/tests/switch/expected_llvm.covdir b/tests/switch/expected_llvm.covdir new file mode 100644 index 000000000..b15fa2fd3 --- /dev/null +++ b/tests/switch/expected_llvm.covdir @@ -0,0 +1,55 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + 1, + -1, + 10, + 9, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 0, + 0, + -1, + 9, + -1, + 1 + ], + "coveragePercent": 91.3, + "linesCovered": 21, + "linesMissed": 2, + "linesTotal": 23, + "name": "main.c" + } + }, + "coveragePercent": 91.3, + "linesCovered": 21, + "linesMissed": 2, + "linesTotal": 23, + "name": "" +} diff --git a/tests/switch/expected_llvm_7.covdir b/tests/switch/expected_llvm_7.covdir new file mode 100644 index 000000000..fbd7757eb --- /dev/null +++ b/tests/switch/expected_llvm_7.covdir @@ -0,0 +1,55 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + -1, + -1, + 10, + 9, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 0, + 0, + -1, + 17, + -1, + 1 + ], + "coveragePercent": 90.91, + "linesCovered": 20, + "linesMissed": 2, + "linesTotal": 22, + "name": "main.c" + } + }, + "coveragePercent": 90.91, + "linesCovered": 20, + "linesMissed": 2, + "linesTotal": 22, + "name": "" +} diff --git a/tests/switch/expected_llvm_mac.covdir b/tests/switch/expected_llvm_mac.covdir new file mode 100644 index 000000000..fbd7757eb --- /dev/null +++ b/tests/switch/expected_llvm_mac.covdir @@ -0,0 +1,55 @@ +{ + "children": { + "main.c": { + "coverage": [ + -1, + -1, + -1, + -1, + 10, + 9, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 1, + 1, + -1, + 0, + 0, + -1, + 17, + -1, + 1 + ], + "coveragePercent": 90.91, + "linesCovered": 20, + "linesMissed": 2, + "linesTotal": 22, + "name": "main.c" + } + }, + "coveragePercent": 90.91, + "linesCovered": 20, + "linesMissed": 2, + "linesTotal": 22, + "name": "" +} diff --git a/tests/template/expected_gcc.covdir b/tests/template/expected_gcc.covdir new file mode 100644 index 000000000..7aedafc49 --- /dev/null +++ b/tests/template/expected_gcc.covdir @@ -0,0 +1,50 @@ +{ + "children": { + "main.cpp": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 4, + -1, + -1, + -1, + -1, + 1, + 1, + 1, + -1, + 1, + 1, + -1, + -1, + 2, + 2, + -1, + -1, + -1, + 1, + 2, + 2, + -1, + 1, + 1, + 1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 16, + "linesMissed": 0, + "linesTotal": 16, + "name": "main.cpp" + } + }, + "coveragePercent": 100.0, + "linesCovered": 16, + "linesMissed": 0, + "linesTotal": 16, + "name": "" +} diff --git a/tests/template/expected_llvm.covdir b/tests/template/expected_llvm.covdir new file mode 100644 index 000000000..2da540c7f --- /dev/null +++ b/tests/template/expected_llvm.covdir @@ -0,0 +1,50 @@ +{ + "children": { + "main.cpp": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 4, + -1, + -1, + -1, + -1, + 1, + 1, + 1, + -1, + 1, + 1, + -1, + -1, + 2, + 2, + -1, + -1, + -1, + 1, + 1, + 1, + -1, + 1, + 1, + 1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 16, + "linesMissed": 0, + "linesTotal": 16, + "name": "main.cpp" + } + }, + "coveragePercent": 100.0, + "linesCovered": 16, + "linesMissed": 0, + "linesTotal": 16, + "name": "" +} diff --git a/tests/template/expected_llvm_7_linux.covdir b/tests/template/expected_llvm_7_linux.covdir new file mode 100644 index 000000000..f88c90513 --- /dev/null +++ b/tests/template/expected_llvm_7_linux.covdir @@ -0,0 +1,50 @@ +{ + "children": { + "main.cpp": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 4, + -1, + -1, + -1, + -1, + -1, + 1, + 1, + -1, + -1, + 1, + -1, + -1, + -1, + 2, + -1, + -1, + -1, + -1, + 1, + 1, + -1, + 1, + 1, + 1, + 1, + 1 + ], + "coveragePercent": 100.0, + "linesCovered": 12, + "linesMissed": 0, + "linesTotal": 12, + "name": "main.cpp" + } + }, + "coveragePercent": 100.0, + "linesCovered": 12, + "linesMissed": 0, + "linesTotal": 12, + "name": "" +} diff --git a/tests/template/expected_llvm_mac.covdir b/tests/template/expected_llvm_mac.covdir new file mode 100644 index 000000000..d02c780d4 --- /dev/null +++ b/tests/template/expected_llvm_mac.covdir @@ -0,0 +1,50 @@ +{ + "children": { + "main.cpp": { + "coverage": [ + -1, + -1, + -1, + -1, + -1, + 4, + -1, + -1, + -1, + -1, + -1, + 1, + 1, + -1, + -1, + 1, + -1, + -1, + -1, + 2, + -1, + -1, + -1, + -1, + 2, + 1, + -1, + 4, + 2, + 1, + 1, + 2 + ], + "coveragePercent": 100.0, + "linesCovered": 12, + "linesMissed": 0, + "linesTotal": 12, + "name": "main.cpp" + } + }, + "coveragePercent": 100.0, + "linesCovered": 12, + "linesMissed": 0, + "linesTotal": 12, + "name": "" +} diff --git a/tests/test.rs b/tests/test.rs index 478768b84..45142d993 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -68,6 +68,7 @@ fn run(path: &Path) { } fn read_file(path: &Path) -> String { + println!("Read file: {:?}", path); let mut f = File::open(path).expect(format!("{:?} file not found", path.file_name()).as_str()); let mut s = String::new(); f.read_to_string(&mut s).unwrap(); @@ -357,6 +358,17 @@ fn check_equal_coveralls(expected_output: &str, output: &str, skip_branches: boo ); } +fn check_equal_covdir(expected_output: &str, output: &str) { + let expected: Value = serde_json::from_str(expected_output).unwrap(); + let actual: Value = serde_json::from_str(output).unwrap(); + + println!("{}", serde_json::to_string_pretty(&actual).unwrap()); + + for field in vec!["coveragePercent", "linesCovered", "linesMissed", "linesTotal", "name"] { + assert_eq!(expected[field], actual[field]) + } +} + fn get_version(compiler: &str) -> String { let output = Command::new(compiler) .arg("--version") @@ -463,7 +475,7 @@ fn test_integration() { do_clean(path); if cfg!(target_os = "linux") { - println!("GCC"); + println!("\nGCC: {:?}", path); let gpp = &get_tool("GCC_CXX", "g++"); let gcc_version = get_version(gpp); make(path, gpp); @@ -477,10 +489,14 @@ fn test_integration() { &read_expected(path, "gcc", &gcc_version, "ade", None), &run_grcov(vec![path], &PathBuf::from(""), "ade"), ); + check_equal_covdir( + &read_expected(path, "gcc", &gcc_version, "covdir", None), + &run_grcov(vec![path], path, "covdir"), + ); do_clean(path); } - println!("\nLLVM"); + println!("\nLLVM: {:?}", path); let clangpp = &get_tool("CLANG_CXX", "clang++"); let clang_version = get_version(clangpp); make(path, clangpp); @@ -494,6 +510,10 @@ fn test_integration() { &read_expected(path, "llvm", &clang_version, "ade", None), &run_grcov(vec![path], &PathBuf::from(""), "ade"), ); + check_equal_covdir( + &read_expected(path, "llvm", &clang_version, "covdir", None), + &run_grcov(vec![path], path, "covdir"), + ); do_clean(path); } @@ -553,6 +573,17 @@ fn test_integration_zip_zip() { &run_grcov(vec![&gcno_zip_path, &gcda0_zip_path], path, "coveralls"), false, ); + + check_equal_covdir( + &read_expected( + path, + &name, + &compiler_version, + "covdir", + Some("_no_gcda"), + ), + &run_grcov(vec![&gcno_zip_path, &gcda0_zip_path], path, "covdir"), + ); // one gcda println!("One gcda"); @@ -562,6 +593,11 @@ fn test_integration_zip_zip() { false, ); + check_equal_covdir( + &read_expected(path, &name, &compiler_version, "covdir", None), + &run_grcov(vec![&gcno_zip_path, &gcda_zip_path], path, "covdir"), + ); + // two gcdas std::fs::copy(&gcda_zip_path, &gcda1_zip_path) .expect(&format!("Failed to copy {:?}", &gcda_zip_path)); @@ -583,6 +619,21 @@ fn test_integration_zip_zip() { false, ); + check_equal_covdir( + &read_expected( + path, + &name, + &compiler_version, + "covdir", + Some("_two_gcda"), + ), + &run_grcov( + vec![&gcno_zip_path, &gcda_zip_path, &gcda1_zip_path], + path, + "covdir", + ), + ); + do_clean(path); } } @@ -629,6 +680,11 @@ fn test_integration_zip_dir() { false, ); + check_equal_covdir( + &read_expected(base_path, &name, &compiler_version, "covdir", None), + &run_grcov(vec![&gcno_zip_path, &base_path], path, "covdir"), + ); + do_clean(path); } }