3 # This script executes the script step when running under travis-ci
7 *cygwin*) OPJ_CI_IS_CYGWIN=1;;
11 if [ "${OPJ_CI_IS_CYGWIN:-}" == "1" ]; then
14 # PATH is not yet set up
15 export PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
19 # Set-up some bash options
20 set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
21 set -o errexit ## set -e : exit the script if any statement returns a non-true return value
22 set -o pipefail ## Fail on error in pipe
26 if [ "${OPJ_CI_IS_CYGWIN:-}" == "1" ]; then
33 # ABI check is done by abi-check.sh
34 if [ "${OPJ_CI_ABI_CHECK:-}" == "1" ]; then
38 # Set-up some variables
39 if [ "${OPJ_CI_BUILD_CONFIGURATION:-}" == "" ]; then
40 export OPJ_CI_BUILD_CONFIGURATION=Release #default
42 OPJ_SOURCE_DIR=$(cd $(dirname $0)/../.. && pwd)
44 if [ "${OPJ_DO_SUBMIT:-}" == "" ]; then
45 OPJ_DO_SUBMIT=0 # Do not flood cdash by default
47 if [ "${TRAVIS_REPO_SLUG:-}" != "" ]; then
48 OPJ_OWNER=$(echo "${TRAVIS_REPO_SLUG}" | sed 's/\(^.*\)\/.*/\1/')
49 OPJ_SITE="${OPJ_OWNER}.travis-ci.org"
50 if [ "${OPJ_OWNER}" == "uclouvain" ]; then
54 OPJ_SITE="$(hostname)"
57 if [ "${TRAVIS_OS_NAME:-}" == "" ]; then
58 # Let's guess OS for testing purposes
60 if uname -s | grep -i Darwin &> /dev/null; then
62 elif uname -s | grep -i Linux &> /dev/null; then
64 if [ "${CC:-}" == "" ]; then
68 elif uname -s | grep -i CYGWIN &> /dev/null; then
69 TRAVIS_OS_NAME=windows
70 elif uname -s | grep -i MINGW32 &> /dev/null; then
71 TRAVIS_OS_NAME=windows
73 echo "Failed to guess OS"; exit 1
75 echo "${TRAVIS_OS_NAME}"
78 if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
79 OPJ_OS_NAME=$(sw_vers -productName | tr -d ' ')$(sw_vers -productVersion | sed 's/\([^0-9]*\.[0-9]*\).*/\1/')
80 OPJ_CC_VERSION=$(xcodebuild -version | grep -i xcode)
81 OPJ_CC_VERSION=xcode${OPJ_CC_VERSION:6}
82 elif [ "${TRAVIS_OS_NAME}" == "linux" ]; then
84 if which lsb_release > /dev/null; then
85 OPJ_OS_NAME=$(lsb_release -si)$(lsb_release -sr | sed 's/\([^0-9]*\.[0-9]*\).*/\1/')
87 if [ -z "${CC##*gcc*}" ]; then
88 OPJ_CC_VERSION=$(${CC} --version | head -1 | sed 's/.*\ \([0-9.]*[0-9]\)/\1/')
89 if [ -z "${CC##*mingw*}" ]; then
90 OPJ_CC_VERSION=mingw${OPJ_CC_VERSION}
91 # disable testing for now
92 export OPJ_CI_SKIP_TESTS=1
94 OPJ_CC_VERSION=gcc${OPJ_CC_VERSION}
96 elif [ -z "${CC##*clang*}" ]; then
97 OPJ_CC_VERSION=clang$(${CC} --version | grep version | sed 's/.*version \([^0-9.]*[0-9.]*\).*/\1/')
99 echo "Compiler not supported: ${CC}"; exit 1
101 elif [ "${TRAVIS_OS_NAME}" == "windows" ]; then
103 OPJ_CC_VERSION=vs2015
105 echo "OS not supported: ${TRAVIS_OS_NAME}"; exit 1
108 if [ "${OPJ_CI_ARCH:-}" == "" ]; then
109 echo "Guessing build architecture"
110 MACHINE_ARCH=$(uname -m)
111 if [ "${MACHINE_ARCH}" == "x86_64" ]; then
112 export OPJ_CI_ARCH=x86_64
114 echo "${OPJ_CI_ARCH}"
117 if [ "${TRAVIS_BRANCH:-}" == "" ]; then
118 if [ "${APPVEYOR_REPO_BRANCH:-}" != "" ]; then
119 TRAVIS_BRANCH=${APPVEYOR_REPO_BRANCH}
121 echo "Guessing branch"
122 TRAVIS_BRANCH=$(git -C ${OPJ_SOURCE_DIR} branch | grep '*' | tr -d '*[[:blank:]]')
126 OPJ_BUILDNAME=${OPJ_OS_NAME}-${OPJ_CC_VERSION}-${OPJ_CI_ARCH}-${TRAVIS_BRANCH}
127 OPJ_BUILDNAME_TEST=${OPJ_OS_NAME}-${OPJ_CC_VERSION}-${OPJ_CI_ARCH}
128 if [ "${TRAVIS_PULL_REQUEST:-}" != "false" ] && [ "${TRAVIS_PULL_REQUEST:-}" != "" ]; then
129 OPJ_BUILDNAME=${OPJ_BUILDNAME}-pr${TRAVIS_PULL_REQUEST}
130 elif [ "${APPVEYOR_PULL_REQUEST_NUMBER:-}" != "" ]; then
131 OPJ_BUILDNAME=${OPJ_BUILDNAME}-pr${APPVEYOR_PULL_REQUEST_NUMBER}
133 OPJ_BUILDNAME=${OPJ_BUILDNAME}-${OPJ_CI_BUILD_CONFIGURATION}-3rdP
134 OPJ_BUILDNAME_TEST=${OPJ_BUILDNAME_TEST}-${OPJ_CI_BUILD_CONFIGURATION}-3rdP
135 if [ "${OPJ_CI_ASAN:-}" == "1" ]; then
136 OPJ_BUILDNAME=${OPJ_BUILDNAME}-ASan
137 OPJ_BUILDNAME_TEST=${OPJ_BUILDNAME_TEST}-ASan
140 if [ "${OPJ_NONCOMMERCIAL:-}" == "1" ] && [ "${OPJ_CI_SKIP_TESTS:-}" != "1" ] && [ -d kdu ]; then
142 Testing will use Kakadu trial binaries. Here's the copyright notice from kakadu:
143 Copyright is owned by NewSouth Innovations Pty Limited, commercial arm of the UNSW Australia in Sydney.
144 You are free to trial these executables and even to re-distribute them,
145 so long as such use or re-distribution is accompanied with this copyright notice and is not for commercial gain.
146 Note: Binaries can only be used for non-commercial purposes.
150 if [ -d cmake-install ]; then
151 export PATH=${PWD}/cmake-install/bin:${PATH}
155 # This will print configuration
156 # travis-ci doesn't dump cmake version in system info, let's print it
159 export TRAVIS_OS_NAME=${TRAVIS_OS_NAME}
160 export OPJ_SITE=${OPJ_SITE}
161 export OPJ_BUILDNAME=${OPJ_BUILDNAME}
162 export OPJ_SOURCE_DIR=$(opjpath -m ${OPJ_SOURCE_DIR})
163 export OPJ_BINARY_DIR=$(opjpath -m ${PWD}/build)
164 export OPJ_BUILD_CONFIGURATION=${OPJ_CI_BUILD_CONFIGURATION}
165 export OPJ_DO_SUBMIT=${OPJ_DO_SUBMIT}
167 ctest -S ${OPJ_SOURCE_DIR}/tools/ctest_scripts/travis-ci.cmake -VV || true
168 # ctest will exit with various error codes depending on version.
169 # ignore ctest exit code & parse this ourselves
172 # let's parse configure/build/tests for failure
175 Parsing logs for failures
183 OPJ_CONFIGURE_XML=$(find build -path 'build/Testing/*' -name 'Configure.xml')
184 if [ ! -f "${OPJ_CONFIGURE_XML}" ]; then
185 echo "No configure log found"
188 if ! grep '<ConfigureStatus>0</ConfigureStatus>' ${OPJ_CONFIGURE_XML} &> /dev/null; then
189 echo "Errors were found in configure log"
195 # We must have one Build.xml file
196 OPJ_BUILD_XML=$(find build -path 'build/Testing/*' -name 'Build.xml')
197 if [ ! -f "${OPJ_BUILD_XML}" ]; then
198 echo "No build log found"
201 if grep '<Error>' ${OPJ_BUILD_XML} &> /dev/null; then
202 echo "Errors were found in build log"
207 if [ ${OPJ_CI_RESULT} -ne 0 ]; then
208 # Don't trash output with failing tests when there are configure/build errors
209 exit ${OPJ_CI_RESULT}
212 if [ "${OPJ_CI_SKIP_TESTS:-}" != "1" ]; then
213 OPJ_TEST_XML=$(find build -path 'build/Testing/*' -name 'Test.xml')
214 if [ ! -f "${OPJ_TEST_XML}" ]; then
215 echo "No test log found"
218 echo "Parsing tests for new/unknown failures"
220 OPJ_FAILEDTEST_LOG=$(find build -path 'build/Testing/Temporary/*' -name 'LastTestsFailed_*.log')
221 if [ -f "${OPJ_FAILEDTEST_LOG}" ]; then
222 awk -F: '{ print $2 }' ${OPJ_FAILEDTEST_LOG} > failures.txt
223 while read FAILEDTEST; do
224 # Start with common errors
225 if grep -x "${FAILEDTEST}" $(opjpath -u ${OPJ_SOURCE_DIR})/tools/travis-ci/knownfailures-all.txt > /dev/null; then
228 if [ -f $(opjpath -u ${OPJ_SOURCE_DIR})/tools/travis-ci/knownfailures-${OPJ_BUILDNAME_TEST}.txt ]; then
229 if grep -x "${FAILEDTEST}" $(opjpath -u ${OPJ_SOURCE_DIR})/tools/travis-ci/knownfailures-${OPJ_BUILDNAME_TEST}.txt > /dev/null; then
239 if [ ${OPJ_CI_RESULT} -eq 0 ]; then
240 echo "No new/unknown test failure found
244 New/unknown test failure found!!!
249 OPJ_MEMCHECK_XML=$(find build -path 'build/Testing/*' -name 'DynamicAnalysis.xml')
250 if [ -f "${OPJ_MEMCHECK_XML}" ]; then
251 if grep '<Defect Type' ${OPJ_MEMCHECK_XML} 2> /dev/null; then
252 echo "Errors were found in dynamic analysis log"
258 exit ${OPJ_CI_RESULT}