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
24 # ABI check is done by abi-check.sh
25 if [ "${OPJ_CI_ABI_CHECK:-}" == "1" ]; then
29 # Set-up some variables
30 if [ "${OPJ_CI_BUILD_CONFIGURATION:-}" == "" ]; then
31 export OPJ_CI_BUILD_CONFIGURATION=Release #default
33 OPJ_SOURCE_DIR=$(cd $(dirname $0)/../.. && pwd)
35 if [ "${OPJ_DO_SUBMIT:-}" == "" ]; then
36 OPJ_DO_SUBMIT=0 # Do not flood cdash by default
38 if [ "${TRAVIS_REPO_SLUG:-}" != "" ]; then
39 OPJ_OWNER=$(echo "${TRAVIS_REPO_SLUG}" | sed 's/\(^.*\)\/.*/\1/')
40 OPJ_SITE="${OPJ_OWNER}.travis-ci.org"
41 if [ "${OPJ_OWNER}" == "uclouvain" ]; then
45 OPJ_SITE="$(hostname)"
48 if [ "${TRAVIS_OS_NAME:-}" == "" ]; then
49 # Let's guess OS for testing purposes
51 if uname -s | grep -i Darwin &> /dev/null; then
53 elif uname -s | grep -i Linux &> /dev/null; then
55 if [ "${CC:-}" == "" ]; then
59 elif uname -s | grep -i CYGWIN &> /dev/null; then
60 TRAVIS_OS_NAME=windows
61 elif uname -s | grep -i MINGW32 &> /dev/null; then
62 TRAVIS_OS_NAME=windows
64 echo "Failed to guess OS"; exit 1
66 echo "${TRAVIS_OS_NAME}"
69 if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
70 OPJ_OS_NAME=$(sw_vers -productName | tr -d ' ')$(sw_vers -productVersion | sed 's/\([^0-9]*\.[0-9]*\).*/\1/')
71 OPJ_CC_VERSION=$(xcodebuild -version | grep -i xcode)
72 OPJ_CC_VERSION=xcode${OPJ_CC_VERSION:6}
73 elif [ "${TRAVIS_OS_NAME}" == "linux" ]; then
75 if which lsb_release > /dev/null; then
76 OPJ_OS_NAME=$(lsb_release -si)$(lsb_release -sr | sed 's/\([^0-9]*\.[0-9]*\).*/\1/')
78 if [ -z "${CC##*gcc*}" ]; then
79 OPJ_CC_VERSION=$(${CC} --version | head -1 | sed 's/.*\ \([0-9.]*[0-9]\)/\1/')
80 if [ -z "${CC##*mingw*}" ]; then
81 OPJ_CC_VERSION=mingw${OPJ_CC_VERSION}
82 # disable testing for now
83 export OPJ_CI_SKIP_TESTS=1
85 OPJ_CC_VERSION=gcc${OPJ_CC_VERSION}
87 elif [ -z "${CC##*clang*}" ]; then
88 OPJ_CC_VERSION=clang$(${CC} --version | grep version | sed 's/.*version \([^0-9.]*[0-9.]*\).*/\1/')
90 echo "Compiler not supported: ${CC}"; exit 1
92 elif [ "${TRAVIS_OS_NAME}" == "windows" ]; then
96 echo "OS not supported: ${TRAVIS_OS_NAME}"; exit 1
99 if [ "${OPJ_CI_ARCH:-}" == "" ]; then
100 echo "Guessing build architecture"
101 MACHINE_ARCH=$(uname -m)
102 if [ "${MACHINE_ARCH}" == "x86_64" ]; then
103 export OPJ_CI_ARCH=x86_64
105 echo "${OPJ_CI_ARCH}"
108 if [ "${TRAVIS_BRANCH:-}" == "" ]; then
109 if [ "${APPVEYOR_REPO_BRANCH:-}" != "" ]; then
110 TRAVIS_BRANCH=${APPVEYOR_REPO_BRANCH}
112 echo "Guessing branch"
113 TRAVIS_BRANCH=$(git -C ${OPJ_SOURCE_DIR} branch | grep '*' | tr -d '*[[:blank:]]')
117 OPJ_BUILDNAME=${OPJ_OS_NAME}-${OPJ_CC_VERSION}-${OPJ_CI_ARCH}-${TRAVIS_BRANCH}
118 OPJ_BUILDNAME_TEST=${OPJ_OS_NAME}-${OPJ_CC_VERSION}-${OPJ_CI_ARCH}
119 if [ "${TRAVIS_PULL_REQUEST:-}" != "false" ] && [ "${TRAVIS_PULL_REQUEST:-}" != "" ]; then
120 OPJ_BUILDNAME=${OPJ_BUILDNAME}-pr${TRAVIS_PULL_REQUEST}
121 elif [ "${APPVEYOR_PULL_REQUEST_NUMBER:-}" != "" ]; then
122 OPJ_BUILDNAME=${OPJ_BUILDNAME}-pr${APPVEYOR_PULL_REQUEST_NUMBER}
124 OPJ_BUILDNAME=${OPJ_BUILDNAME}-${OPJ_CI_BUILD_CONFIGURATION}-3rdP
125 OPJ_BUILDNAME_TEST=${OPJ_BUILDNAME_TEST}-${OPJ_CI_BUILD_CONFIGURATION}-3rdP
126 if [ "${OPJ_CI_ASAN:-}" == "1" ]; then
127 OPJ_BUILDNAME=${OPJ_BUILDNAME}-ASan
128 OPJ_BUILDNAME_TEST=${OPJ_BUILDNAME_TEST}-ASan
131 if [ "${OPJ_NONCOMMERCIAL:-}" == "1" ] && [ "${OPJ_CI_SKIP_TESTS:-}" != "1" ] && [ -d kdu ]; then
133 Testing will use Kakadu trial binaries. Here's the copyright notice from kakadu:
134 Copyright is owned by NewSouth Innovations Pty Limited, commercial arm of the UNSW Australia in Sydney.
135 You are free to trial these executables and even to re-distribute them,
136 so long as such use or re-distribution is accompanied with this copyright notice and is not for commercial gain.
137 Note: Binaries can only be used for non-commercial purposes.
141 if [ -d cmake-install ]; then
142 export PATH=${PWD}/cmake-install/bin:${PATH}
146 # This will print configuration
147 # travis-ci doesn't dump cmake version in system info, let's print it
150 export OPJ_SITE=${OPJ_SITE}
151 export OPJ_BUILDNAME=${OPJ_BUILDNAME}
152 export OPJ_SOURCE_DIR=${OPJ_SOURCE_DIR}
153 export OPJ_BUILD_CONFIGURATION=${OPJ_CI_BUILD_CONFIGURATION}
154 export OPJ_DO_SUBMIT=${OPJ_DO_SUBMIT}
156 ctest -S ${OPJ_SOURCE_DIR}/tools/ctest_scripts/travis-ci.cmake -V || true
157 # ctest will exit with various error codes depending on version.
158 # ignore ctest exit code & parse this ourselves
161 # let's parse configure/build/tests for failure
164 Parsing logs for failures
169 OPJ_CONFIGURE_XML=$(find build -path 'build/Testing/*' -name 'Configure.xml')
170 if [ ! -f "${OPJ_CONFIGURE_XML}" ]; then
171 echo "No configure log found"
174 if ! grep '<ConfigureStatus>0</ConfigureStatus>' ${OPJ_CONFIGURE_XML} &> /dev/null; then
175 echo "Errors were found in configure log"
181 # We must have one Build.xml file
182 OPJ_BUILD_XML=$(find build -path 'build/Testing/*' -name 'Build.xml')
183 if [ ! -f "${OPJ_BUILD_XML}" ]; then
184 echo "No build log found"
187 if grep '<Error>' ${OPJ_BUILD_XML} &> /dev/null; then
188 echo "Errors were found in build log"
193 if [ ${OPJ_CI_RESULT} -ne 0 ]; then
194 # Don't trash output with failing tests when there are configure/build errors
195 exit ${OPJ_CI_RESULT}
198 if [ "${OPJ_CI_SKIP_TESTS:-}" != "1" ]; then
199 OPJ_TEST_XML=$(find build -path 'build/Testing/*' -name 'Test.xml')
200 if [ ! -f "${OPJ_TEST_XML}" ]; then
201 echo "No test log found"
204 echo "Parsing tests for new/unknown failures"
206 OPJ_FAILEDTEST_LOG=$(find build -path 'build/Testing/Temporary/*' -name 'LastTestsFailed_*.log')
207 if [ -f "${OPJ_FAILEDTEST_LOG}" ]; then
208 awk -F: '{ print $2 }' ${OPJ_FAILEDTEST_LOG} > failures.txt
209 while read FAILEDTEST; do
210 # Start with common errors
211 if grep -x "${FAILEDTEST}" ${OPJ_SOURCE_DIR}/tools/travis-ci/knownfailures-all.txt > /dev/null; then
214 if [ -f ${OPJ_SOURCE_DIR}/tools/travis-ci/knownfailures-${OPJ_BUILDNAME_TEST}.txt ]; then
215 if grep -x "${FAILEDTEST}" ${OPJ_SOURCE_DIR}/tools/travis-ci/knownfailures-${OPJ_BUILDNAME_TEST}.txt > /dev/null; then
225 if [ ${OPJ_CI_RESULT} -eq 0 ]; then
226 echo "No new/unknown test failure found
230 New/unknown test failure found!!!
235 OPJ_MEMCHECK_XML=$(find build -path 'build/Testing/*' -name 'DynamicAnalysis.xml')
236 if [ -f "${OPJ_MEMCHECK_XML}" ]; then
237 if grep '<Defect Type' ${OPJ_MEMCHECK_XML} 2> /dev/null; then
238 echo "Errors were found in dynamic analysis log"
244 exit ${OPJ_CI_RESULT}