3 # This script executes the script step when running under travis-ci
7 *cygwin*) OPJ_CI_IS_CYGWIN=1;;
11 # Hack for appveyor to get GNU find in path before windows one.
12 export PATH=$(dirname ${BASH}):$PATH
14 # Set-up some bash options
15 set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
16 set -o errexit ## set -e : exit the script if any statement returns a non-true return value
17 set -o pipefail ## Fail on error in pipe
21 if [ "${OPJ_CI_IS_CYGWIN:-}" == "1" ]; then
28 # ABI check is done by abi-check.sh
29 if [ "${OPJ_CI_ABI_CHECK:-}" == "1" ]; then
33 # Set-up some variables
34 if [ "${OPJ_CI_BUILD_CONFIGURATION:-}" == "" ]; then
35 export OPJ_CI_BUILD_CONFIGURATION=Release #default
37 OPJ_SOURCE_DIR=$(cd $(dirname $0)/../.. && pwd)
39 if [ "${OPJ_DO_SUBMIT:-}" == "" ]; then
40 OPJ_DO_SUBMIT=0 # Do not flood cdash by default
42 if [ "${TRAVIS_REPO_SLUG:-}" != "" ]; then
43 OPJ_OWNER=$(echo "${TRAVIS_REPO_SLUG}" | sed 's/\(^.*\)\/.*/\1/')
44 OPJ_SITE="${OPJ_OWNER}.travis-ci.org"
45 if [ "${OPJ_OWNER}" == "uclouvain" ]; then
48 elif [ "${APPVEYOR_REPO_NAME:-}" != "" ]; then
49 OPJ_OWNER=$(echo "${APPVEYOR_REPO_NAME}" | sed 's/\(^.*\)\/.*/\1/')
50 OPJ_SITE="${OPJ_OWNER}.appveyor.com"
51 if [ "${OPJ_OWNER}" == "uclouvain" ]; then
55 OPJ_SITE="$(hostname)"
58 if [ "${TRAVIS_OS_NAME:-}" == "" ]; then
59 # Let's guess OS for testing purposes
61 if uname -s | grep -i Darwin &> /dev/null; then
63 elif uname -s | grep -i Linux &> /dev/null; then
65 if [ "${CC:-}" == "" ]; then
69 elif uname -s | grep -i CYGWIN &> /dev/null; then
70 TRAVIS_OS_NAME=windows
71 elif uname -s | grep -i MINGW &> /dev/null; then
72 TRAVIS_OS_NAME=windows
74 echo "Failed to guess OS"; exit 1
76 echo "${TRAVIS_OS_NAME}"
79 if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
80 OPJ_OS_NAME=$(sw_vers -productName | tr -d ' ')$(sw_vers -productVersion | sed 's/\([^0-9]*\.[0-9]*\).*/\1/')
81 OPJ_CC_VERSION=$(xcodebuild -version | grep -i xcode)
82 OPJ_CC_VERSION=xcode${OPJ_CC_VERSION:6}
83 elif [ "${TRAVIS_OS_NAME}" == "linux" ]; then
85 if which lsb_release > /dev/null; then
86 OPJ_OS_NAME=$(lsb_release -si)$(lsb_release -sr | sed 's/\([^0-9]*\.[0-9]*\).*/\1/')
88 if [ -z "${CC##*gcc*}" ]; then
89 OPJ_CC_VERSION=$(${CC} --version | head -1 | sed 's/.*\ \([0-9.]*[0-9]\)/\1/')
90 if [ -z "${CC##*mingw*}" ]; then
91 OPJ_CC_VERSION=mingw${OPJ_CC_VERSION}
92 # disable testing for now
93 export OPJ_CI_SKIP_TESTS=1
95 OPJ_CC_VERSION=gcc${OPJ_CC_VERSION}
97 elif [ -z "${CC##*clang*}" ]; then
98 OPJ_CC_VERSION=clang$(${CC} --version | grep version | sed 's/.*version \([^0-9.]*[0-9.]*\).*/\1/')
100 echo "Compiler not supported: ${CC}"; exit 1
102 elif [ "${TRAVIS_OS_NAME}" == "windows" ]; then
104 if which cl > /dev/null; then
105 OPJ_CL_VERSION=$(cl 2>&1 | grep Version | sed 's/.*Version \([0-9]*\).*/\1/')
106 if [ ${OPJ_CL_VERSION} -eq 19 ]; then
107 OPJ_CC_VERSION=vs2015
108 elif [ ${OPJ_CL_VERSION} -eq 18 ]; then
109 OPJ_CC_VERSION=vs2013
110 elif [ ${OPJ_CL_VERSION} -eq 17 ]; then
111 OPJ_CC_VERSION=vs2012
112 elif [ ${OPJ_CL_VERSION} -eq 16 ]; then
113 OPJ_CC_VERSION=vs2010
114 elif [ ${OPJ_CL_VERSION} -eq 15 ]; then
115 OPJ_CC_VERSION=vs2008
116 elif [ ${OPJ_CL_VERSION} -eq 14 ]; then
117 OPJ_CC_VERSION=vs2005
119 OPJ_CC_VERSION=vs????
123 echo "OS not supported: ${TRAVIS_OS_NAME}"; exit 1
126 if [ "${OPJ_CI_ARCH:-}" == "" ]; then
127 echo "Guessing build architecture"
128 MACHINE_ARCH=$(uname -m)
129 if [ "${MACHINE_ARCH}" == "x86_64" ]; then
130 export OPJ_CI_ARCH=x86_64
132 echo "${OPJ_CI_ARCH}"
135 if [ "${TRAVIS_BRANCH:-}" == "" ]; then
136 if [ "${APPVEYOR_REPO_BRANCH:-}" != "" ]; then
137 TRAVIS_BRANCH=${APPVEYOR_REPO_BRANCH}
139 echo "Guessing branch"
140 TRAVIS_BRANCH=$(git -C ${OPJ_SOURCE_DIR} branch | grep '*' | tr -d '*[[:blank:]]')
144 OPJ_BUILDNAME=${OPJ_OS_NAME}-${OPJ_CC_VERSION}-${OPJ_CI_ARCH}-${TRAVIS_BRANCH}
145 OPJ_BUILDNAME_TEST=${OPJ_OS_NAME}-${OPJ_CC_VERSION}-${OPJ_CI_ARCH}
146 if [ "${TRAVIS_PULL_REQUEST:-}" != "false" ] && [ "${TRAVIS_PULL_REQUEST:-}" != "" ]; then
147 OPJ_BUILDNAME=${OPJ_BUILDNAME}-pr${TRAVIS_PULL_REQUEST}
148 elif [ "${APPVEYOR_PULL_REQUEST_NUMBER:-}" != "" ]; then
149 OPJ_BUILDNAME=${OPJ_BUILDNAME}-pr${APPVEYOR_PULL_REQUEST_NUMBER}
151 OPJ_BUILDNAME=${OPJ_BUILDNAME}-${OPJ_CI_BUILD_CONFIGURATION}-3rdP
152 OPJ_BUILDNAME_TEST=${OPJ_BUILDNAME_TEST}-${OPJ_CI_BUILD_CONFIGURATION}-3rdP
153 if [ "${OPJ_CI_ASAN:-}" == "1" ]; then
154 OPJ_BUILDNAME=${OPJ_BUILDNAME}-ASan
155 OPJ_BUILDNAME_TEST=${OPJ_BUILDNAME_TEST}-ASan
158 if [ "${OPJ_NONCOMMERCIAL:-}" == "1" ] && [ "${OPJ_CI_SKIP_TESTS:-}" != "1" ] && [ -d kdu ]; then
160 Testing will use Kakadu trial binaries. Here's the copyright notice from kakadu:
161 Copyright is owned by NewSouth Innovations Pty Limited, commercial arm of the UNSW Australia in Sydney.
162 You are free to trial these executables and even to re-distribute them,
163 so long as such use or re-distribution is accompanied with this copyright notice and is not for commercial gain.
164 Note: Binaries can only be used for non-commercial purposes.
168 if [ -d cmake-install ]; then
169 export PATH=${PWD}/cmake-install/bin:${PATH}
173 # This will print configuration
174 # travis-ci doesn't dump cmake version in system info, let's print it
177 export TRAVIS_OS_NAME=${TRAVIS_OS_NAME}
178 export OPJ_SITE=${OPJ_SITE}
179 export OPJ_BUILDNAME=${OPJ_BUILDNAME}
180 export OPJ_SOURCE_DIR=$(opjpath -m ${OPJ_SOURCE_DIR})
181 export OPJ_BINARY_DIR=$(opjpath -m ${PWD}/build)
182 export OPJ_BUILD_CONFIGURATION=${OPJ_CI_BUILD_CONFIGURATION}
183 export OPJ_DO_SUBMIT=${OPJ_DO_SUBMIT}
185 ctest -S ${OPJ_SOURCE_DIR}/tools/ctest_scripts/travis-ci.cmake -V || true
186 # ctest will exit with various error codes depending on version.
187 # ignore ctest exit code & parse this ourselves
190 # let's parse configure/build/tests for failure
193 Parsing logs for failures
198 OPJ_CONFIGURE_XML=$(find build -path 'build/Testing/*' -name 'Configure.xml')
199 if [ ! -f "${OPJ_CONFIGURE_XML}" ]; then
200 echo "No configure log found"
203 if ! grep '<ConfigureStatus>0</ConfigureStatus>' ${OPJ_CONFIGURE_XML} &> /dev/null; then
204 echo "Errors were found in configure log"
210 # We must have one Build.xml file
211 OPJ_BUILD_XML=$(find build -path 'build/Testing/*' -name 'Build.xml')
212 if [ ! -f "${OPJ_BUILD_XML}" ]; then
213 echo "No build log found"
216 if grep '<Error>' ${OPJ_BUILD_XML} &> /dev/null; then
217 echo "Errors were found in build log"
222 if [ ${OPJ_CI_RESULT} -ne 0 ]; then
223 # Don't trash output with failing tests when there are configure/build errors
224 exit ${OPJ_CI_RESULT}
227 if [ "${OPJ_CI_SKIP_TESTS:-}" != "1" ]; then
228 OPJ_TEST_XML=$(find build -path 'build/Testing/*' -name 'Test.xml')
229 if [ ! -f "${OPJ_TEST_XML}" ]; then
230 echo "No test log found"
233 echo "Parsing tests for new/unknown failures"
235 OPJ_FAILEDTEST_LOG=$(find build -path 'build/Testing/Temporary/*' -name 'LastTestsFailed_*.log')
236 if [ -f "${OPJ_FAILEDTEST_LOG}" ]; then
237 awk -F: '{ print $2 }' ${OPJ_FAILEDTEST_LOG} > failures.txt
238 while read FAILEDTEST; do
239 # Start with common errors
240 if grep -x "${FAILEDTEST}" $(opjpath -u ${OPJ_SOURCE_DIR})/tools/travis-ci/knownfailures-all.txt > /dev/null; then
243 if [ -f $(opjpath -u ${OPJ_SOURCE_DIR})/tools/travis-ci/knownfailures-${OPJ_BUILDNAME_TEST}.txt ]; then
244 if grep -x "${FAILEDTEST}" $(opjpath -u ${OPJ_SOURCE_DIR})/tools/travis-ci/knownfailures-${OPJ_BUILDNAME_TEST}.txt > /dev/null; then
254 if [ ${OPJ_CI_RESULT} -eq 0 ]; then
255 echo "No new/unknown test failure found
259 New/unknown test failure found!!!
264 OPJ_MEMCHECK_XML=$(find build -path 'build/Testing/*' -name 'DynamicAnalysis.xml')
265 if [ -f "${OPJ_MEMCHECK_XML}" ]; then
266 if grep '<Defect Type' ${OPJ_MEMCHECK_XML} 2> /dev/null; then
267 echo "Errors were found in dynamic analysis log"
273 exit ${OPJ_CI_RESULT}