blob: 185225951b1308a6b39366452eef7bf2bc37178d [file] [log] [blame]
Stephan Herrmannf80b55d2016-10-31 23:56:48 +01001#! /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 Herrmannf80b55d2016-10-31 23:56:48 +010027# 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
43usage()
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
51notifyTestRunFailure()
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
65cleanup()
66{
Stephan Herrmann423ec262016-11-01 00:11:19 +010067 echo "cleanup(): Currently no cleanup is configured"
Stephan Herrmannf80b55d2016-10-31 23:56:48 +010068}
69
70_prefix=`dirname $0`
71_prefix=`readlink -f $_prefix`
72. "${_prefix}/otdt_prerequisites-hipp.sh"
73
74echo "=== Sourced otdt_prerequisites-hipp.sh ==="
75env
76echo "====================================="
77
78#LOCAL: log file:
79OT_SUITE_LOG=$TMPDIR/ot-testsuite.log
80
81# LOCAL: the initial ant build file:
82BUILDFILE="${_prefix}/run.xml"
83
84#LOCAL: main ant target:
85MAIN_TARGET=${MAIN_TARGET:="ot-junit-all"}
86
87#LOCAL: should OTDT and tests be built?
88DO_BUILD="true"
89
90#LOCAL: should the tests be run?
91DO_RUN="true"
92
Stephan Herrmannf80b55d2016-10-31 23:56:48 +010093
94while 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 Herrmannf80b55d2016-10-31 23:56:48 +0100105 -tmp)
106 shift
107 TEST_TMPDIR="$1"
108 shift
109 ;;
110 *)
111 echo "Unknown argument: $1"
112 usage
113 exit 1
114 esac
115
116done
117
Stephan Herrmannd9a85732016-11-01 16:32:04 +0100118if [ "${MAIN_TARGET}" == "ot-junit-run" ]
119then
120 DO_BUILD="false"
121fi
122
Stephan Herrmannf80b55d2016-10-31 23:56:48 +0100123# start working:
124
125test -d "$TMPDIR" || mkdir -p "$TMPDIR"
126test -d "$OT_TESTSUITE_DIR" || mkdir -p "$OT_TESTSUITE_DIR"
127cd "$OT_TESTSUITE_DIR"
128
129# cleanup previous:
130if [ "$DO_BUILD" == "true" ]
131then
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 Herrmannb6718c12016-11-01 13:13:07 +0100138else
139 rm -f test-root/eclipse/results/*
Stephan Herrmannf80b55d2016-10-31 23:56:48 +0100140fi
141
142# preload metadata for appending:
143if [ -f "${METADATA}/content.xml" ]
144then
145 mkdir -p metadata
146 cp ${METADATA}/*.xml metadata
147fi
148
149trap "echo Aborting by SIGTERM; cleanup; exit 130" INT
150
151# Assemble the Ant call:
152ANT_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 Herrmanne73f8852016-11-01 00:23:59 +0100159 -Dtest.tmpDir=${TEST_TMPDIR} \
Stephan Herrmanncf1ce3f2016-11-01 01:04:19 +0100160 -DfetchCacheLocation=${FETCH_CACHE_LOCATION} \
Stephan Herrmannd9a85732016-11-01 16:32:04 +0100161 -Dmap.file.path=${MAP_FILE_PATH} \
Stephan Herrmann74cc41d2016-11-01 16:33:39 +0100162 -D_hasSaxon.jar=true"
Stephan Herrmannf80b55d2016-10-31 23:56:48 +0100163
164ANT_OPTS="-Xmx1024m"
165export ANT_OPTS
166
167CMD="nice -n ${NICE} ant -f ${BUILDFILE} ${ANT_OPTIONS} ${MAIN_TARGET}"
168
Stephan Herrmann423ec262016-11-01 00:11:19 +0100169echo "Running $CMD"
170eval "$CMD" < /dev/null
Stephan Herrmannf80b55d2016-10-31 23:56:48 +0100171
172trap - INT
173
174