Skip to content

Commit dbd7109

Browse files
committed
[#491] Add test coverage reports into the runtime documentation
1 parent d953148 commit dbd7109

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

cmake/coverage_utils.cmake

+7-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function(create_coverage_target)
2828
endif ()
2929

3030
set(cov_binary_dir "${PROJECT_BINARY_DIR}/${cov_tgt_name}")
31+
set(cov_install_dir "${CMAKE_INSTALL_PREFIX}/cpp/zserio_doc/coverage")
3132

3233
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
3334
set(cov_fail)
@@ -49,7 +50,8 @@ function(create_coverage_target)
4950
-r ${PROJECT_SOURCE_DIR}
5051
--object-directory=${PROJECT_BINARY_DIR}
5152
${cov_fail}
52-
${cov_exclude}
53+
${cov_exclude} > ${cov_binary_dir}/coverage_report.txt
54+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${cov_binary_dir} ${cov_install_dir}/gcc
5355
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
5456
VERBATIM
5557
COMMENT "Generating html code coverage report in ${cov_binary_dir}/index.html")
@@ -72,11 +74,15 @@ function(create_coverage_target)
7274
COMMAND ${LLVM_COV_BIN} report ${cov_test_exectable}
7375
-instr-profile=${cov_binary_dir}/runtime.profdata
7476
${cov_exclude}
77+
COMMAND bash -c "${LLVM_COV_BIN} report ${cov_test_exectable} \
78+
-instr-profile=${cov_binary_dir}/runtime.profdata ${cov_exclude} \
79+
> ${cov_binary_dir}/coverage_report.txt"
7580
COMMAND bash -c "(( \
7681
`${LLVM_COV_BIN} report ${cov_test_exectable} \
7782
-instr-profile=${cov_binary_dir}/runtime.profdata ${cov_exclude} | grep TOTAL | \
7883
tr -s ' ' | cut -d' ' -f 10 | cut -d. -f 1` >= ${cov_INCOMPLETE_COVERAGE_FAIL} \
7984
))"
85+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${cov_binary_dir} ${cov_install_dir}/clang
8086
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
8187
VERBATIM
8288
COMMENT "Generating html code coverage report in ${cov_binary_dir}/index.html")

compiler/extensions/java/runtime/build.xml

+12
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ spotbugs.home_dir - Location of the spotbugs tool. If not set, spo
5454
value="${zserio_java_runtime.test.build_dir}/coverage"/>
5555
<property name="zserio_java_runtime.test.coverage_file"
5656
value="${zserio_java_runtime.test.coverage_dir}/jacoco_coverage.bin"/>
57+
<property name="zserio_java_runtime.test.coverage_jar_file"
58+
value="${zserio_java_runtime.install_dir}/zserio_runtime_coverage.jar"/>
5759

5860
<property name="zserio_java_runtime.jar_dir" value="${zserio_java_runtime.build_dir}/jar"/>
5961
<property name="zserio_java_runtime.jar_file" value="${zserio_java_runtime.jar_dir}/zserio_runtime.jar"/>
@@ -311,13 +313,23 @@ spotbugs.home_dir - Location of the spotbugs tool. If not set, spo
311313
</structure>
312314

313315
<html destdir="${zserio_java_runtime.test.coverage_dir}"/>
316+
<xml destfile="${zserio_java_runtime.test.coverage_dir}/jacoco_report.xml"/>
314317

315318
<check>
316319
<rule element="BUNDLE">
317320
<limit counter="INSTRUCTION" value="COVEREDRATIO" minimum="92%"/>
318321
</rule>
319322
</check>
320323
</jacoco:report>
324+
325+
<jar destfile="${zserio_java_runtime.test.coverage_jar_file}">
326+
<fileset dir="${zserio_java_runtime.test.coverage_dir}">
327+
<include name="**"/>
328+
</fileset>
329+
<manifest>
330+
<attribute name="Implementation-Version" value="${zserio_java_runtime.version}"/>
331+
</manifest>
332+
</jar>
321333
</target>
322334

323335
<target name="test" depends="test.run">

scripts/build.sh

+17
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ test_python_runtime()
3838
ZSERIO_CPP_DIR=$(ls -d1 "${BUILD_DIR}/zserio_cpp/lib"*)
3939
if [ $? -ne 0 ] ; then
4040
stderr_echo "Failed to locate C++ runtime binding to Python!"
41+
popd > /dev/null
4142
return 1
4243
fi
4344

@@ -66,6 +67,14 @@ test_python_runtime()
6667
return 1
6768
fi
6869

70+
python -m coverage xml -o "coverage/coverage_report.xml" --fail-under=100 --omit="*test_object*"
71+
local COVERAGE_RESULT=$?
72+
if [ ${COVERAGE_RESULT} -ne 0 ] ; then
73+
stderr_echo "Running python coverage report failed with return code ${COVERAGE_RESULT}!"
74+
popd > /dev/null
75+
return 1
76+
fi
77+
6978
popd > /dev/null
7079
echo
7180

@@ -176,6 +185,14 @@ install_python_runtime()
176185
return 1
177186
fi
178187

188+
# install test coverage report
189+
echo "Installing test coverage report"
190+
cp -r "${PYTHON_RUNTIME_BUILD_DIR}/coverage" "${PYTHON_RUNTIME_DISTR_DIR}/zserio_doc/coverage"
191+
if [ $? -ne 0 ] ; then
192+
stderr_echo "Failed to install documentation!"
193+
return 1
194+
fi
195+
179196
return 0
180197
}
181198

scripts/release.sh

+6
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,12 @@ update_web_pages()
534534
stderr_echo "Cannot unzip zserio runtime javadocs jar!"
535535
return 1
536536
fi
537+
"${UNZIP}" -q "${WEB_PAGES_BUILD_DIR}"/runtime_libs/java/zserio_runtime_coverage.jar \
538+
-d "${WEB_PAGES_BUILD_DIR}"/runtime_libs/java/zserio_doc/coverage -x META-INF/*
539+
if [ $? -ne 0 ] ; then
540+
stderr_echo "Cannot unzip zserio runtime javadocs jar!"
541+
return 1
542+
fi
537543
echo "Done"
538544

539545
echo -ne "Copying Zserio runtime libraries..."

0 commit comments

Comments
 (0)