Merge pull request #11 from marco-c/remove_old_activedata_etl_format

Remove old ActiveData-ETL format
This commit is contained in:
Marco 2017-03-10 18:09:44 +01:00 коммит произвёл GitHub
Родитель e076d188c2 593ee20b74
Коммит 05e1ea195a
7 изменённых файлов: 89 добавлений и 99 удалений

Просмотреть файл

@ -24,7 +24,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::thread;
use crossbeam::sync::MsQueue;
use walkdir::WalkDir;
use serde_json::{Value, Map};
use serde_json::Value;
use semver::Version;
use crypto::md5::Md5;
use crypto::digest::Digest;
@ -361,51 +361,6 @@ fn clean_covered_lines(results: &mut HashMap<String,Result>) {
}
}
fn output_old_activedata_etl(results: &mut HashMap<String,Result>) {
for (key, result) in results {
let ref mut result = *result;
let end: u32 = cmp::max(result.covered.last().unwrap_or(&0), result.uncovered.last().unwrap_or(&0)) + 1;
let mut methods = Map::new();
if result.covered.len() > 0 {
let mut start_indexes: Vec<u32> = Vec::new();
for function in result.functions.values() {
start_indexes.push(function.start);
}
start_indexes.sort();
for (name, function) in result.functions.drain() {
// println!("{} {} {}", name, function.executed, function.start);
if !function.executed {
continue;
}
let mut func_end = end;
for start in start_indexes.iter() {
if *start > function.start {
func_end = *start;
break;
}
}
let lines_covered: Vec<u32> = result.covered.iter().filter(|&&x| x >= function.start && x < func_end).cloned().collect();
methods.insert(name, Value::from(lines_covered));
}
}
println!("{}", json!({
"sourceFile": key,
"covered": result.covered,
"uncovered": result.uncovered,
"methods": methods,
}).to_string());
}
}
fn to_activedata_etl_vec(normal_vec: &Vec<u32>) -> Vec<Value> {
normal_vec.iter().map(|&x| json!({"line": x})).collect()
}
@ -469,8 +424,10 @@ fn output_activedata_etl(results: &mut HashMap<String,Result>) {
}));
}
let orphan_covered = orphan_covered.into_iter().collect();
let orphan_uncovered: Vec<u32> = orphan_uncovered.into_iter().collect();
let mut orphan_covered: Vec<u32> = orphan_covered.into_iter().collect();
orphan_covered.sort();
let mut orphan_uncovered: Vec<u32> = orphan_uncovered.into_iter().collect();
orphan_uncovered.sort();
// The orphan lines will represent the file as a whole.
println!("{}", json!({
@ -696,7 +653,7 @@ fn main() {
i += 1;
}
if output_type != "ade" && output_type != "old_ade" && output_type != "lcov" && output_type != "coveralls" {
if output_type != "ade" && output_type != "lcov" && output_type != "coveralls" {
println!("[ERROR]: '{}' output format is not supported.\n", output_type);
print_usage(&args[0]);
return;
@ -778,8 +735,6 @@ fn main() {
if output_type == "ade" {
output_activedata_etl(results_obj);
} else if output_type == "old_ade" {
output_old_activedata_etl(results_obj);
} else if output_type == "lcov" {
output_lcov(results_obj);
} else if output_type == "coveralls" {

Просмотреть файл

@ -1 +1,2 @@
{"covered":[3,5,6,7,10,15],"methods":{"main":[3,5,6,7,10,15]},"sourceFile":"main.c","uncovered":[11]}
{"file":{"name":"main.c"},"method":{"covered":[{"line":3},{"line":5},{"line":6},{"line":7},{"line":10},{"line":15}],"name":"main","percentage_covered":0.8571428656578064,"total_covered":6,"total_uncovered":1,"uncovered":[11]}}
{"file":{"covered":[{"line":3},{"line":5},{"line":6},{"line":7},{"line":10},{"line":15}],"name":"main.c","percentage_covered":0.8571428656578064,"total_covered":6,"total_uncovered":1,"uncovered":[11]},"is_file":true,"method":{"covered":[],"percentage_covered":0.0,"total_covered":0,"total_uncovered":0,"uncovered":[]}}

Просмотреть файл

@ -1,3 +1,11 @@
{"covered":[74],"methods":{},"sourceFile":"/usr/include/c++/6/iostream","uncovered":[]}
{"covered":[6,8,9,10,12,13,24,26,28,29,31,35,36],"methods":{"_GLOBAL__sub_I_main":[36],"_Z41__static_initialization_and_destruction_0ii":[36],"_ZN4Ciao7getNameB5cxx11Ev":[12,13],"_ZN4Ciao7setNameENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE":[8,9,10],"_ZN4CiaoC2Ev":[6],"_ZN4CiaoD2Ev":[6],"main":[24,26,28,29,31,35]},"sourceFile":"main.cpp","uncovered":[16,17,18,32]}
{"covered":[5084,5086],"methods":{"_ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_":[5084,5086]},"sourceFile":"/usr/include/c++/6/bits/basic_string.h","uncovered":[]}
{"file":{"name":"/usr/include/c++/6/bits/basic_string.h"},"method":{"covered":[{"line":5084},{"line":5086}],"name":"_ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}}
{"file":{"covered":[{"line":5084},{"line":5086}],"name":"/usr/include/c++/6/bits/basic_string.h","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]},"is_file":true,"method":{"covered":[],"percentage_covered":0.0,"total_covered":0,"total_uncovered":0,"uncovered":[]}}
{"file":{"covered":[{"line":74}],"name":"/usr/include/c++/6/iostream","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]},"is_file":true,"method":{"covered":[{"line":74}],"percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":36}],"name":"_Z41__static_initialization_and_destruction_0ii","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":24},{"line":26},{"line":28},{"line":29},{"line":31},{"line":35}],"name":"main","percentage_covered":0.8571428656578064,"total_covered":6,"total_uncovered":1,"uncovered":[32]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":6}],"name":"_ZN4CiaoC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":36}],"name":"_GLOBAL__sub_I_main","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":6}],"name":"_ZN4CiaoD2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":12},{"line":13}],"name":"_ZN4Ciao7getNameB5cxx11Ev","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":8},{"line":9},{"line":10}],"name":"_ZN4Ciao7setNameENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]}}
{"file":{"covered":[{"line":6},{"line":8},{"line":9},{"line":10},{"line":12},{"line":13},{"line":24},{"line":26},{"line":28},{"line":29},{"line":31},{"line":35},{"line":36}],"name":"main.cpp","percentage_covered":0.7647058963775635,"total_covered":13,"total_uncovered":4,"uncovered":[16,17,18,32]},"is_file":true,"method":{"covered":[],"percentage_covered":0.0,"total_covered":0,"total_uncovered":3,"uncovered":[16,17,18]}}

Просмотреть файл

@ -1,4 +1,14 @@
{"covered":[6,10,11,12],"methods":{"_ZN4Ciao14calledFromFileEv":[10,11,12],"_ZN4CiaoC2Ev":[6],"_ZN4CiaoD2Ev":[6]},"sourceFile":"include.h","uncovered":[]}
{"covered":[74],"methods":{},"sourceFile":"/usr/include/c++/6/iostream","uncovered":[]}
{"covered":[3,5,7,8,10,11],"methods":{"_GLOBAL__sub_I_main":[11],"_Z41__static_initialization_and_destruction_0ii":[11],"main":[3,5,7,8,10]},"sourceFile":"main.cpp","uncovered":[]}
{"covered":[3,4,5,7,8,9,10],"methods":{"_GLOBAL__sub_I__ZN4Ciao7setNameENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE":[10],"_Z41__static_initialization_and_destruction_0ii":[10],"_ZN4Ciao7getNameB5cxx11Ev":[7,8,9],"_ZN4Ciao7setNameENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE":[3,4,5]},"sourceFile":"file.cpp","uncovered":[]}
{"file":{"covered":[{"line":74}],"name":"/usr/include/c++/6/iostream","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]},"is_file":true,"method":{"covered":[{"line":74}],"percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"file.cpp"},"method":{"covered":[{"line":10}],"name":"_Z41__static_initialization_and_destruction_0ii","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"file.cpp"},"method":{"covered":[{"line":7},{"line":8},{"line":9}],"name":"_ZN4Ciao7getNameB5cxx11Ev","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"file.cpp"},"method":{"covered":[{"line":3},{"line":4},{"line":5}],"name":"_ZN4Ciao7setNameENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"file.cpp"},"method":{"covered":[{"line":10}],"name":"_GLOBAL__sub_I__ZN4Ciao7setNameENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"covered":[{"line":3},{"line":4},{"line":5},{"line":7},{"line":8},{"line":9},{"line":10}],"name":"file.cpp","percentage_covered":1.0,"total_covered":7,"total_uncovered":0,"uncovered":[]},"is_file":true,"method":{"covered":[],"percentage_covered":0.0,"total_covered":0,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"include.h"},"method":{"covered":[{"line":10},{"line":11},{"line":12}],"name":"_ZN4Ciao14calledFromFileEv","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"include.h"},"method":{"covered":[{"line":6}],"name":"_ZN4CiaoD2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"include.h"},"method":{"covered":[{"line":6}],"name":"_ZN4CiaoC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"covered":[{"line":6},{"line":10},{"line":11},{"line":12}],"name":"include.h","percentage_covered":1.0,"total_covered":4,"total_uncovered":0,"uncovered":[]},"is_file":true,"method":{"covered":[],"percentage_covered":0.0,"total_covered":0,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":11}],"name":"_Z41__static_initialization_and_destruction_0ii","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":11}],"name":"_GLOBAL__sub_I_main","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":3},{"line":5},{"line":7},{"line":8},{"line":10}],"name":"main","percentage_covered":1.0,"total_covered":5,"total_uncovered":0,"uncovered":[]}}
{"file":{"covered":[{"line":3},{"line":5},{"line":7},{"line":8},{"line":10},{"line":11}],"name":"main.cpp","percentage_covered":1.0,"total_covered":6,"total_uncovered":0,"uncovered":[]},"is_file":true,"method":{"covered":[],"percentage_covered":0.0,"total_covered":0,"total_uncovered":0,"uncovered":[]}}

Просмотреть файл

@ -1,5 +1,16 @@
{"covered":[3,4,5,7,8,9,10],"methods":{"_GLOBAL__sub_I__ZN4Ciao7setNameENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE":[10],"_Z41__static_initialization_and_destruction_0ii":[10],"_ZN4Ciao7getNameB5cxx11Ev":[7,8,9],"_ZN4Ciao7setNameENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE":[3,4,5]},"sourceFile":"file.cpp","uncovered":[]}
{"covered":[74],"methods":{},"sourceFile":"/usr/include/c++/6/iostream","uncovered":[]}
{"covered":[3,5,7,8,10,14,15],"methods":{"_GLOBAL__sub_I_main":[15],"_Z41__static_initialization_and_destruction_0ii":[15],"main":[3,5,7,8,10,14]},"sourceFile":"main.cpp","uncovered":[11]}
{"covered":[6,10,11,12],"methods":{"_ZN4Ciao14calledFromFileEv":[10,11,12],"_ZN4CiaoC2Ev":[6],"_ZN4CiaoD2Ev":[6]},"sourceFile":"include.h","uncovered":[]}
{"covered":[5084,5086],"methods":{"_ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_":[5084,5086]},"sourceFile":"/usr/include/c++/6/bits/basic_string.h","uncovered":[]}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":3},{"line":5},{"line":7},{"line":8},{"line":10},{"line":14}],"name":"main","percentage_covered":0.8571428656578064,"total_covered":6,"total_uncovered":1,"uncovered":[11]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":15}],"name":"_Z41__static_initialization_and_destruction_0ii","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":15}],"name":"_GLOBAL__sub_I_main","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"covered":[{"line":3},{"line":5},{"line":7},{"line":8},{"line":10},{"line":14},{"line":15}],"name":"main.cpp","percentage_covered":0.875,"total_covered":7,"total_uncovered":1,"uncovered":[11]},"is_file":true,"method":{"covered":[],"percentage_covered":0.0,"total_covered":0,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"/usr/include/c++/6/bits/basic_string.h"},"method":{"covered":[{"line":5084},{"line":5086}],"name":"_ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}}
{"file":{"covered":[{"line":5084},{"line":5086}],"name":"/usr/include/c++/6/bits/basic_string.h","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]},"is_file":true,"method":{"covered":[],"percentage_covered":0.0,"total_covered":0,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"include.h"},"method":{"covered":[{"line":10},{"line":11},{"line":12}],"name":"_ZN4Ciao14calledFromFileEv","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"include.h"},"method":{"covered":[{"line":6}],"name":"_ZN4CiaoC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"include.h"},"method":{"covered":[{"line":6}],"name":"_ZN4CiaoD2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"covered":[{"line":6},{"line":10},{"line":11},{"line":12}],"name":"include.h","percentage_covered":1.0,"total_covered":4,"total_uncovered":0,"uncovered":[]},"is_file":true,"method":{"covered":[],"percentage_covered":0.0,"total_covered":0,"total_uncovered":0,"uncovered":[]}}
{"file":{"covered":[{"line":74}],"name":"/usr/include/c++/6/iostream","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]},"is_file":true,"method":{"covered":[{"line":74}],"percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"file.cpp"},"method":{"covered":[{"line":7},{"line":8},{"line":9}],"name":"_ZN4Ciao7getNameB5cxx11Ev","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"file.cpp"},"method":{"covered":[{"line":10}],"name":"_GLOBAL__sub_I__ZN4Ciao7setNameENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"file.cpp"},"method":{"covered":[{"line":10}],"name":"_Z41__static_initialization_and_destruction_0ii","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"file.cpp"},"method":{"covered":[{"line":3},{"line":4},{"line":5}],"name":"_ZN4Ciao7setNameENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]}}
{"file":{"covered":[{"line":3},{"line":4},{"line":5},{"line":7},{"line":8},{"line":9},{"line":10}],"name":"file.cpp","percentage_covered":1.0,"total_covered":7,"total_uncovered":0,"uncovered":[]},"is_file":true,"method":{"covered":[],"percentage_covered":0.0,"total_covered":0,"total_uncovered":0,"uncovered":[]}}

Просмотреть файл

@ -1 +1,10 @@
{"covered":[6,11,12,13,15,16,19,20,24,25,26,28,29,30,31,32],"methods":{"_ZN4CiaoINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE3setES5_":[11,12,13],"_ZN4CiaoINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE4get2Ev":[19,20],"_ZN4CiaoINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEC2Ev":[6],"_ZN4CiaoINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEED2Ev":[6],"_ZN4CiaoINSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEE3getEv":[15,16],"_ZN4CiaoINSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEE4get2Ev":[19,20],"_ZN4CiaoINSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEEC2Ev":[6],"_ZN4CiaoINSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEED2Ev":[6],"main":[24,25,26,28,29,30,31,32]},"sourceFile":"main.cpp","uncovered":[]}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":19},{"line":20}],"name":"_ZN4CiaoINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE4get2Ev","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":6}],"name":"_ZN4CiaoINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEED2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":6}],"name":"_ZN4CiaoINSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEED2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":15},{"line":16}],"name":"_ZN4CiaoINSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEE3getEv","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":11},{"line":12},{"line":13}],"name":"_ZN4CiaoINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE3setES5_","percentage_covered":1.0,"total_covered":3,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":19},{"line":20}],"name":"_ZN4CiaoINSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEE4get2Ev","percentage_covered":1.0,"total_covered":2,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":24},{"line":25},{"line":26},{"line":28},{"line":29},{"line":30},{"line":31},{"line":32}],"name":"main","percentage_covered":1.0,"total_covered":8,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":6}],"name":"_ZN4CiaoINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"name":"main.cpp"},"method":{"covered":[{"line":6}],"name":"_ZN4CiaoINSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEEC2Ev","percentage_covered":1.0,"total_covered":1,"total_uncovered":0,"uncovered":[]}}
{"file":{"covered":[{"line":6},{"line":11},{"line":12},{"line":13},{"line":15},{"line":16},{"line":19},{"line":20},{"line":24},{"line":25},{"line":26},{"line":28},{"line":29},{"line":30},{"line":31},{"line":32}],"name":"main.cpp","percentage_covered":1.0,"total_covered":16,"total_uncovered":0,"uncovered":[]},"is_file":true,"method":{"covered":[],"percentage_covered":0.0,"total_covered":0,"total_uncovered":0,"uncovered":[]}}

Просмотреть файл

@ -40,9 +40,6 @@ fn run_grcov(path: &Path) -> Vec<String> {
let output = Command::new("cargo")
.arg("run")
.arg(path)
.arg("--")
.arg("-t")
.arg("old_ade")
.output()
.expect("Failed to run grcov");
let s = String::from_utf8(output.stdout).unwrap();
@ -62,20 +59,28 @@ fn make_clean(path: &Path) {
assert!(status.success());
}
fn check_equal_inner(a: &Value, b: &Value, skip_methods: bool) -> bool {
a["is_file"] == b["is_file"] &&
(skip_methods || a["method"]["name"] == b["method"]["name"]) &&
a["method"]["covered"] == b["method"]["covered"] &&
a["method"]["uncovered"] == b["method"]["uncovered"] &&
a["method"]["percentage_covered"] == b["method"]["percentage_covered"] &&
a["method"]["total_covered"] == b["method"]["total_covered"] &&
a["method"]["total_uncovered"] == b["method"]["total_uncovered"] &&
a["file"]["name"] == b["file"]["name"] &&
a["file"]["covered"] == b["file"]["covered"] &&
a["file"]["uncovered"] == b["file"]["uncovered"] &&
a["file"]["percentage_covered"] == b["file"]["percentage_covered"] &&
a["file"]["total_covered"] == b["file"]["total_covered"] &&
a["file"]["total_uncovered"] == b["file"]["total_uncovered"]
}
fn check_equal(expected_output: Vec<String>, output: Vec<String>) {
println!("Expected:");
for line in expected_output.iter() {
println!("{}", line);
}
let mut expected: Vec<Value> = Vec::new();
for line in expected_output.iter() {
expected.push(serde_json::from_str(line).unwrap());
}
println!("Got:");
for line in output.iter() {
println!("{}", line);
}
let mut actual: Vec<Value> = Vec::new();
for line in output.iter() {
actual.push(serde_json::from_str(line).unwrap());
@ -86,40 +91,29 @@ fn check_equal(expected_output: Vec<String>, output: Vec<String>) {
// 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();
let mut actual_len = 0;
for out in actual.iter() {
if out["sourceFile"].as_str().unwrap().contains("/usr/include") && skip_builtin {
if out["file"]["name"].as_str().unwrap().contains("/usr/include") && skip_builtin {
continue;
}
actual_len += 1;
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["covered"], exp_val["covered"]);
assert_eq!(out["uncovered"], exp_val["uncovered"]);
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"]);
}
let exp = expected.iter().find(|&&ref x| check_equal_inner(x, out, skip_methods));
assert!(exp.is_some(), "Got unexpected {}", out);
}
let mut expected_len = 0;
for exp in expected.iter() {
if exp["sourceFile"].as_str().unwrap().contains("/usr/include") && skip_builtin {
if exp["file"]["name"].as_str().unwrap().contains("/usr/include") && skip_builtin {
continue;
}
expected_len += 1;
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["covered"], out_val["covered"]);
assert_eq!(exp["uncovered"], out_val["uncovered"]);
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"]);
}
let out = actual.iter().find(|&&ref x| check_equal_inner(x, exp, skip_methods));
assert!(out.is_some(), "Missing {}", exp);
}
assert_eq!(expected_len, actual_len, "Got same number of expected records.")
}
#[test]
@ -128,6 +122,8 @@ fn test_integration() {
let entry = entry.unwrap();
let path = entry.path();
if path.is_dir() {
println!("{}", path.display());
make(path);
run(path);