Stephan Herrmann | f80b55d | 2016-10-31 23:56:48 +0100 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | # Copyright (c) 2010 Stephan Herrmann. |
| 3 | # All rights reserved. This program and the accompanying materials |
| 4 | # are made available under the terms of the Eclipse Public License v1.0 |
| 5 | # which accompanies this distribution, and is available at |
| 6 | # http://www.eclipse.org/legal/epl-v10.html |
| 7 | # |
| 8 | # Contributors: |
| 9 | # Stephan Herrmann - initial API and implementation |
| 10 | ############################################################################### |
| 11 | |
| 12 | # ============================================================================= |
| 13 | # MAIN BUILD AND TEST SCRIPT FOR THE OBJECT TEAMS DEVELOPMENT TOOLING (OTDT) |
| 14 | # ============================================================================= |
| 15 | # INPUT: Variables from otdt_prerequisites: |
| 16 | # ----------------------------------------------------------------------------- |
| 17 | # TMPDIR for log output |
| 18 | # TEST_TMPDIR for temp test files |
| 19 | # OT_TESTSUITE_DIR root directory for building and testing |
| 20 | # METADATA directory for metadata from previous builds |
| 21 | # OT_RECIPIENT mail address for failure messages |
| 22 | # SDK_QUALIFIER build qualifier of the base eclipse SDK |
| 23 | # ECLIPSE_SDK_TGZ archive file of the base eclipse SDK build (full path) |
| 24 | # ECLIPSE_TESTLIB_ZIP archive file of the eclipse test framework (full path) |
| 25 | # PUBLISHED_UPDATES directory of previously published plugins&features |
| 26 | # ANT_PROFILE configure the ant process |
Stephan Herrmann | f80b55d | 2016-10-31 23:56:48 +0100 | [diff] [blame] | 27 | # NICE niceness value for nice -n ${NICE} |
| 28 | # ============================================================================= |
| 29 | # OUTPUT: Variables passed to the toplevel ant script |
| 30 | # ----------------------------------------------------------------------------- |
| 31 | ## As Environment Variables: |
| 32 | ## ANT_OPTS configure Ant |
| 33 | ## As Ant Arguments (from ANT_PROFILE): |
| 34 | ## -verbose configure Ant |
| 35 | ## As Java Properties: |
| 36 | ## -Declipse-app.tgz path of eclipse SDK |
| 37 | ## -Declipse.tests.zip path of eclipse test framework |
| 38 | ## -Dpublished.updates path to previously published things |
| 39 | ## -Ddo.build.all true|false: should OTDT and tests be built? |
| 40 | ## -Ddo.run.tests true|false: should test be run? |
| 41 | # ============================================================================= |
| 42 | |
| 43 | usage() |
| 44 | { |
| 45 | echo "Usage:" |
| 46 | echo "$0 [-b|-nobuild]" |
| 47 | echo " -b: build OTDT only, no testing." |
| 48 | echo " -nobuild: don't build OTDT, directly invoke testing." |
| 49 | } |
| 50 | |
| 51 | notifyTestRunFailure() |
| 52 | { |
| 53 | echo "Running the test-cases failed!"; |
| 54 | local subject="OT Testsuite: Failure!" |
| 55 | local message="See the attached log to fix the problems." |
| 56 | local cmdLogfiles="-a ${OT_SUITE_LOG}-tail.gz" |
| 57 | |
| 58 | grep -q "\[java\] BUILD FAILED" "$OT_SUITE_LOG" && { subject="OT Testsuite: Compile/Build Failure!"; } |
| 59 | tail -1000 "$OT_SUITE_LOG" | gzip -f - > "${OT_SUITE_LOG}-tail.gz" |
| 60 | echo -e "$message" | mutt -s "$subject" $cmdLogfiles $OT_RECIPIENT |
| 61 | cleanup |
| 62 | exit 1; |
| 63 | } |
| 64 | |
| 65 | cleanup() |
| 66 | { |
Stephan Herrmann | 423ec26 | 2016-11-01 00:11:19 +0100 | [diff] [blame] | 67 | echo "cleanup(): Currently no cleanup is configured" |
Stephan Herrmann | f80b55d | 2016-10-31 23:56:48 +0100 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | _prefix=`dirname $0` |
| 71 | _prefix=`readlink -f $_prefix` |
| 72 | . "${_prefix}/otdt_prerequisites-hipp.sh" |
| 73 | |
| 74 | echo "=== Sourced otdt_prerequisites-hipp.sh ===" |
| 75 | env |
| 76 | echo "=====================================" |
| 77 | |
| 78 | #LOCAL: log file: |
| 79 | OT_SUITE_LOG=$TMPDIR/ot-testsuite.log |
| 80 | |
| 81 | # LOCAL: the initial ant build file: |
| 82 | BUILDFILE="${_prefix}/run.xml" |
| 83 | |
| 84 | #LOCAL: main ant target: |
| 85 | MAIN_TARGET=${MAIN_TARGET:="ot-junit-all"} |
| 86 | |
| 87 | #LOCAL: should OTDT and tests be built? |
| 88 | DO_BUILD="true" |
| 89 | |
| 90 | #LOCAL: should the tests be run? |
| 91 | DO_RUN="true" |
| 92 | |
Stephan Herrmann | f80b55d | 2016-10-31 23:56:48 +0100 | [diff] [blame] | 93 | |
| 94 | while test $# -gt 0; do |
| 95 | case "$1" in |
| 96 | -b) |
| 97 | MAIN_TARGET="ot-junit-build" |
| 98 | DO_RUN="false" |
| 99 | shift |
| 100 | ;; |
| 101 | -nobuild) |
| 102 | DO_BUILD="false" |
| 103 | shift |
| 104 | ;; |
Stephan Herrmann | f80b55d | 2016-10-31 23:56:48 +0100 | [diff] [blame] | 105 | -tmp) |
| 106 | shift |
| 107 | TEST_TMPDIR="$1" |
| 108 | shift |
| 109 | ;; |
| 110 | *) |
| 111 | echo "Unknown argument: $1" |
| 112 | usage |
| 113 | exit 1 |
| 114 | esac |
| 115 | |
| 116 | done |
| 117 | |
Stephan Herrmann | d9a8573 | 2016-11-01 16:32:04 +0100 | [diff] [blame] | 118 | if [ "${MAIN_TARGET}" == "ot-junit-run" ] |
| 119 | then |
| 120 | DO_BUILD="false" |
| 121 | fi |
| 122 | |
Stephan Herrmann | f80b55d | 2016-10-31 23:56:48 +0100 | [diff] [blame] | 123 | # start working: |
| 124 | |
| 125 | test -d "$TMPDIR" || mkdir -p "$TMPDIR" |
| 126 | test -d "$OT_TESTSUITE_DIR" || mkdir -p "$OT_TESTSUITE_DIR" |
| 127 | cd "$OT_TESTSUITE_DIR" |
| 128 | |
| 129 | # cleanup previous: |
| 130 | if [ "$DO_BUILD" == "true" ] |
| 131 | then |
| 132 | rm -rf build-root |
| 133 | rm -rf test-root |
| 134 | rm -rf updateSite |
| 135 | rm -rf updateSiteTests |
| 136 | rm -rf updateSiteCompiler |
| 137 | rm -rf metadata |
Stephan Herrmann | b6718c1 | 2016-11-01 13:13:07 +0100 | [diff] [blame] | 138 | else |
| 139 | rm -f test-root/eclipse/results/* |
Stephan Herrmann | f80b55d | 2016-10-31 23:56:48 +0100 | [diff] [blame] | 140 | fi |
| 141 | |
| 142 | # preload metadata for appending: |
| 143 | if [ -f "${METADATA}/content.xml" ] |
| 144 | then |
| 145 | mkdir -p metadata |
| 146 | cp ${METADATA}/*.xml metadata |
| 147 | fi |
| 148 | |
| 149 | trap "echo Aborting by SIGTERM; cleanup; exit 130" INT |
| 150 | |
| 151 | # Assemble the Ant call: |
| 152 | ANT_OPTIONS="${ANT_PROFILE} \ |
| 153 | -Declipse-app.tgz=${ECLIPSE_SDK_TGZ} \ |
| 154 | -Declipse.tests.zip=${ECLIPSE_TESTLIB_ZIP} \ |
| 155 | -Declipse.sdk.qualifier=${SDK_QUALIFIER} \ |
| 156 | -Dpublished.updates=${PUBLISHED_UPDATES} \ |
| 157 | -Ddo.run.tests=${DO_RUN} \ |
| 158 | -Ddo.build.all=${DO_BUILD} \ |
Stephan Herrmann | e73f885 | 2016-11-01 00:23:59 +0100 | [diff] [blame] | 159 | -Dtest.tmpDir=${TEST_TMPDIR} \ |
Stephan Herrmann | cf1ce3f | 2016-11-01 01:04:19 +0100 | [diff] [blame] | 160 | -DfetchCacheLocation=${FETCH_CACHE_LOCATION} \ |
Stephan Herrmann | d9a8573 | 2016-11-01 16:32:04 +0100 | [diff] [blame] | 161 | -Dmap.file.path=${MAP_FILE_PATH} \ |
Stephan Herrmann | 74cc41d | 2016-11-01 16:33:39 +0100 | [diff] [blame^] | 162 | -D_hasSaxon.jar=true" |
Stephan Herrmann | f80b55d | 2016-10-31 23:56:48 +0100 | [diff] [blame] | 163 | |
| 164 | ANT_OPTS="-Xmx1024m" |
| 165 | export ANT_OPTS |
| 166 | |
| 167 | CMD="nice -n ${NICE} ant -f ${BUILDFILE} ${ANT_OPTIONS} ${MAIN_TARGET}" |
| 168 | |
Stephan Herrmann | 423ec26 | 2016-11-01 00:11:19 +0100 | [diff] [blame] | 169 | echo "Running $CMD" |
| 170 | eval "$CMD" < /dev/null |
Stephan Herrmann | f80b55d | 2016-10-31 23:56:48 +0100 | [diff] [blame] | 171 | |
| 172 | trap - INT |
| 173 | |
| 174 | |