Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI/Testing: many improvements for testing and code coverage #3730

Merged
merged 1 commit into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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