我正在使用类似以下结构的C ++项目中工作:
--- /src
|--comms
|--utils
|--interfaces
…
CMakeList.txt
--- /test
|---test1/
|--main.cpp
|--CMakelists.txt
--CMakeLists.txt
我确实需要控制测试的覆盖范围,为此我以这种方式使用GCOV和LCOV:
在所有CMakeLists.txt中启用coverage标志,以生成.gcno文件。
SET(CMAKE_CXX_FLAGS "-g -O0 -Wall -fprofile-arcs -ftest-coverage")
SET(CMAKE_C_FLAGS "-g -O0 -Wall -W -fprofile-arcs -ftest-coverage")
SET(CMAKE_EXE_LINKER_FLAGS "-fprofile-arcs -ftest-coverage")
运行测试,生成相应的.gcda
文件。
此时,文件gcno和gcda与相应的.o
文件位于同一目录中。我无法移动这些文件,因为如果我这样做,报告覆盖率生成就不起作用了。
从文件.gcno
和.gcda
所在的目录中,我执行以下操作:
lcov –c –d . –o name.info
使用以下方法生成HTML报告:
genhtml name.info.
当我编译项目时,我有重复的.gcno
文件,因为编译测试时需要重新编译它们的依赖项(comms,utils,...),因为我没有为它生成库这些依赖关系。如果我不使用图书馆,我认为没有办法避免这种情况。
但是,当我尝试为全球项目生成index.html
(覆盖率报告)时,它无法正常工作。
我使用Shell脚本创建项目的相同文件夹结构,并将每个.gcno
和.gcda
复制到相应的目录。我执行命令lcov
和genhtml
,但index.html
不包括所有项目范围。
我将不胜感激。
答案 0 :(得分:0)
尝试将genhtml命令放在<!DOCTYPE html>
<html>
<head>
<title>Snapshot Three JS</title>
</head>
<body>
<script src="http://cdnjs.cloudflare.com/ajax/libs/three.js/r69/three.min.js"></script>
<script src="http://threejs.org/examples/js/libs/stats.min.js"></script>
<script type="text/javascript">
var camera, scene, renderer;
var mesh;
var strDownloadMime = "image/octet-stream";
init();
animate();
function init() {
var saveLink = document.createElement('div');
saveLink.style.position = 'absolute';
saveLink.style.top = '10px';
saveLink.style.width = '100%';
saveLink.style.background = '#FFFFFF';
saveLink.style.textAlign = 'center';
saveLink.innerHTML =
'<button href="#" id="clickButton">Save Frame</button>';
document.body.appendChild(saveLink);
// document.getElementById("saveLink").addEventListener('click', saveAsImage);
renderer = new THREE.WebGLRenderer({
preserveDrawingBuffer: true,
captureId
});
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
//
camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 1, 1000);
camera.position.z = 400;
scene = new THREE.Scene();
var geometry = new THREE.BoxGeometry(200, 200, 200);
var captureId = document.getElementById('image');
// var renderer = new Three.WebGLRenderer({captureId});
var material = new THREE.MeshBasicMaterial({
color: 0x00ff00
});
mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
console.log(captureId);
window.addEventListener('resize', onWindowResize, false);
document.getElementById('clickButton').addEventListener('click', buttonClick);
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
function animate() {
requestAnimationFrame(animate);
mesh.rotation.x += 0.005;
mesh.rotation.y += 0.01;
renderer.render(scene, camera);
}
function buttonClick() {
renderer.render(scene, camera);
document.getElementById('image').src = renderer.domElement.toDataURL();
console.log(image);
}
</script>
<style type="text/css">
html,
body {
padding: 0px;
margin: 0px;
}
canvas {
width: 100%;
height: 100%
}
#clickButton {
position: absolute;
top: 10px;
left: 10px;
z-index: 2;
cursor: pointer;
}
#image {
position: absolute;
top: 10px;
right: 10px;
max-width: 150px;
width: 150px;
height: 90px;
z-index: 3;
border: 1px solid #fff;
}
</style>
<img id="image" src="" />
</body>
中:
--ignore-errors