1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
8 # Make sure that test data are not newer than release;
9 # otherwise we will see "Found-But-No-Test" test failures!
10 MY_TESTDATA_COMMIT="c07f38fae1e67adc288c2d6679df5d3652017fbe"
12 DESCRIPTION="Open-source JPEG 2000 library"
13 HOMEPAGE="https://www.openjpeg.org"
14 SRC_URI="https://github.com/uclouvain/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz
15 test? ( https://github.com/uclouvain/openjpeg-data/archive/${MY_TESTDATA_COMMIT}.tar.gz -> ${PN}-data_20170814.tar.gz )"
18 SLOT="2/7" # based on SONAME
19 KEYWORDS="alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
20 IUSE="doc static-libs test"
28 doc? ( app-doc/doxygen )"
30 DOCS=( AUTHORS.md CHANGELOG.md NEWS.md README.md THANKS.md )
33 "${FILESDIR}/${P}-fix-disable-static-libs.patch" # bug 650322
34 "${FILESDIR}/${P}-gnuinstalldirs.patch" # bug 667150
39 mv "${WORKDIR}"/openjpeg-data-${MY_TESTDATA_COMMIT} "${WORKDIR}"/data ||
40 die "Failed to rename test data"
43 cmake-utils_src_prepare
46 multilib_src_configure() {
48 -DBUILD_PKGCONFIG_FILES=ON # always build pkgconfig files, bug #539834
49 -DBUILD_TESTING="$(multilib_native_usex test)"
50 -DBUILD_DOC=$(multilib_native_usex doc ON OFF)
51 -DBUILD_CODEC=$(multilib_is_native_abi && echo ON || echo OFF)
52 -DBUILD_STATIC_LIBS=$(usex static-libs)
55 cmake-utils_src_configure
59 if ! multilib_is_native_abi ; then
60 elog "Cannot run tests for non-multilib abi."
66 pushd "${BUILD_DIR}" > /dev/null || die
67 [[ -e CTestTestfile.cmake ]] || die "Test suite not available! Check source!"
69 [[ -n ${TEST_VERBOSE} ]] && myctestargs+=( --extra-verbose --output-on-failure )
71 echo ctest "${myctestargs[@]}" "$@"
72 if ctest "${myctestargs[@]}" "$@" ; then
73 einfo "Tests succeeded."
74 popd > /dev/null || die
77 local FAILEDTEST_LOG="${BUILD_DIR}/Testing/Temporary/LastTestsFailed.log"
79 if [[ ! -f "${FAILEDTEST_LOG}" ]] ; then
81 die "Cannot analyze test failures: LastTestsFailed.log is missing!"
85 einfo "Note: Upstream is maintaining a list of known test failures."
86 einfo "We will now compare our test results against this list and sort out any known failure."
88 local KNOWN_FAILURES_LIST="${T}/known_failures_compiled.txt"
89 cat "${S}/tools/travis-ci/knownfailures-all.txt" > "${KNOWN_FAILURES_LIST}" || die
91 local ARCH_SPECIFIC_FAILURES=
93 ARCH_SPECIFIC_FAILURES="$(find "${S}/tools/travis-ci/" -name 'knownfailures-*x86_64*.txt' -print0 | sort -z | tail -z -n 1 | tr -d '\0')"
94 elif use x86 || use arm || use arm64; then
95 ARCH_SPECIFIC_FAILURES="$(find "${S}/tools/travis-ci/" -name 'knownfailures-*i386*.txt' -print0 | sort -z | tail -z -n 1 | tr -d '\0')"
98 if [[ -f "${ARCH_SPECIFIC_FAILURES}" ]] ; then
99 einfo "Adding architecture specific failures (${ARCH_SPECIFIC_FAILURES}) to known failures list ..."
100 cat "${ARCH_SPECIFIC_FAILURES}" >> "${KNOWN_FAILURES_LIST}" || die
103 # Logic copied from $S/tools/travis-ci/run.sh
105 local FAILURES_LOG="${BUILD_DIR}/Testing/Temporary/failures.txt"
106 local HAS_UNKNOWN_TEST_FAILURES=0
110 awk -F: '{ print $2 }' "${FAILEDTEST_LOG}" > "${FAILURES_LOG}"
111 while read FAILEDTEST; do
112 # is this failure known?
113 if grep -x "${FAILEDTEST}" "${KNOWN_FAILURES_LIST}" > /dev/null; then
114 ewarn "Test '${FAILEDTEST}' is known to fail, ignoring ..."
118 eerror "New/unknown test failure found: '${FAILEDTEST}'"
119 HAS_UNKNOWN_TEST_FAILURES=1
120 done < "${FAILURES_LOG}"
122 if [[ ${HAS_UNKNOWN_TEST_FAILURES} -ne 0 ]]; then
123 die "Test suite failed. New/unknown test failure(s) found!"
126 einfo "Test suite passed. No new/unknown test failure(s) found!"