Skip to content

Commit

Permalink
CI/Testing: many improvements for testing and code coverage (#3730)
Browse files Browse the repository at this point in the history
* When checking code coverage, don't abort for failed tests
* Rejigger imagebufalgo_test a bit for better IBA test coverage
* Test zover
* Have testsuite/oiiotool-fixnan test with deep images
* Add to the extisting --fixnan tests a test for 'error' mode.
* Make testsuite/oiiotool-color test all colormap names
* Test 2D filters in filter_test
* Exclude python scripts in src/doc from coverage analysis
* Remove redundant attribute-seting code from the python internals
* Remove unused python_array_code function
* Exclude some imported code from coverage testing
* Re-enable and improve coverage testing from 'make CODECOV=1'
* Exclude unused/unexposed parts of xxhash.cpp from compilation
  • Loading branch information
lgritz authored Dec 28, 2022
1 parent ec2fb00 commit 9aabd43
Show file tree
Hide file tree
Showing 26 changed files with 491 additions and 137 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ test: build
cd ${build_dir} ; \
lcov -b . -d . -c -o cov.info ; \
lcov --remove cov.info "/usr*" -o cov.info ; \
lcov --remove cov.info "*/usr/incude" -o cov.info ; \
lcov --remove cov.info "/Library/Developer/*" -o cov.info ; \
lcov --remove cov.info "*/detail/pugixml/*" -o cov.info ; \
lcov --remove cov.info "*/detail/fmt/*" -o cov.info ; \
lcov --remove cov.info "*/v1/*" -o cov.info ; \
lcov --remove cov.info "*/ext/robin-map/*" -o cov.info ; \
lcov --remove cov.info "*/kissfft.hh" -o cov.info ; \
lcov --remove cov.info "*/stb_sprintf.h" -o cov.info ; \
genhtml -o ./cov -t "Test coverage" --num-spaces 4 cov.info ; \
fi )

Expand Down
4 changes: 2 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ sonar.projectKey=OpenImageIO_oiio

# Source properties
sonar.sources=src
sonar.exclusions=src/include/OpenImageIO/detail/pugixml/**,src/libutil/stb_sprintf.h,src/libutil/xxhash.cpp,src/include/OpenImageIO/detail/farmhash.h,src/libutil/farmhash.cpp
sonar.exclusions=src/doc/**,src/include/OpenImageIO/detail/pugixml/**,src/libutil/stb_sprintf.h,src/libutil/xxhash.cpp,src/include/OpenImageIO/detail/farmhash.h,src/libutil/farmhash.cpp
sonar.sourceEncoding=UTF-8

# C/C++ analyzer properties
sonar.cfamily.build-wrapper-output=build/bw_output
sonar.cfamily.gcov.reportsPath=_coverage
sonar.coverage.exclusions=src/iv/**,src/include/OpenImageIO/detail/pugixml/**
sonar.coverage.exclusions=src/iv/**,src/include/OpenImageIO/detail/pugixml/**,src/include/OpenImageIO/detail/fmt/**,src/libOpenImageIO/kissfft.hh

sonar.cfamily.cache.enabled=true
sonar.cfamily.cache.path=/tmp/sonarcache
Expand Down
2 changes: 1 addition & 1 deletion src/build-scripts/ci-coverage.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# Run code coverage analysis
# This assumes that the build occurred with CODECOV=1 andtests have already
# This assumes that the build occurred with CODECOV=1 and tests have already
# fully run.

set -ex
Expand Down
5 changes: 4 additions & 1 deletion src/build-scripts/ci-test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

# Important: set -ex causes this whole script to terminate with error if
# any command in it fails. This is crucial for CI tests.
set -ex
# (Though we let it run all the way through for code coverage workflows.)
if [[ "${CODECOV}" == "" ]]; then
set -ex
fi

: ${CTEST_EXCLUSIONS:="broken"}
: ${CTEST_TEST_TIMEOUT:=180}
Expand Down
2 changes: 1 addition & 1 deletion src/cmake/compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ option (CODECOV "Build code coverage tests" OFF)
if (CODECOV AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG))
message (STATUS "Compiling for code coverage analysis")
add_compile_options (-ftest-coverage -fprofile-arcs)
add_link_options (-ftest-coverage -fprofile-arcs)
add_definitions ("-D${PROJ_NAME}_CODE_COVERAGE=1")
link_libraries(gcov)
endif ()


Expand Down
3 changes: 3 additions & 0 deletions src/include/OpenImageIO/imagebufalgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ class Image_or_Const {
Image_or_Const (const float *v, size_t s) : m_type(VAL), m_val(v,s) {}
Image_or_Const (const float *v, int s) : m_type(VAL), m_val(v,s) {}

template<size_t N>
Image_or_Const(const float (&array)[N]) : Image_or_Const(cspan<float>(array)) {}

bool is_img () const { return m_type == IMG; }
bool is_val () const { return m_type == VAL; }
bool is_empty () const { return m_type == NONE; }
Expand Down
Loading

0 comments on commit 9aabd43

Please sign in to comment.