bin/checkintest.sh

Wed, 19 Feb 2014 13:14:46 -0800

author
katleman
date
Wed, 19 Feb 2014 13:14:46 -0800
changeset 723
f4fc3b50a3ba
parent 7
5a1b0714df0e
child 952
6d5471a497fb
permissions
-rw-r--r--

Added tag jdk8u20-b02 for changeset 43a1183d2ab0

jlaskey@3 1 #!/bin/bash
jlaskey@3 2 #
jlaskey@7 3 # Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
jlaskey@3 4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jlaskey@3 5 #
jlaskey@3 6 # This code is free software; you can redistribute it and/or modify it
jlaskey@3 7 # under the terms of the GNU General Public License version 2 only, as
jlaskey@3 8 # published by the Free Software Foundation.
jlaskey@3 9 #
jlaskey@3 10 # This code is distributed in the hope that it will be useful, but WITHOUT
jlaskey@3 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jlaskey@3 12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jlaskey@3 13 # version 2 for more details (a copy is included in the LICENSE file that
jlaskey@3 14 # accompanied this code).
jlaskey@3 15 #
jlaskey@3 16 # You should have received a copy of the GNU General Public License version
jlaskey@3 17 # 2 along with this work; if not, write to the Free Software Foundation,
jlaskey@3 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jlaskey@3 19 #
jlaskey@3 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jlaskey@3 21 # or visit www.oracle.com if you need additional information or have any
jlaskey@3 22 # questions.
jlaskey@3 23 #
jlaskey@3 24
jlaskey@3 25 #best pass rate at test 262 known
jlaskey@3 26 TEST262_PASS_AT_LEAST=435
jlaskey@3 27
jlaskey@3 28 RUN_TEST="true"
jlaskey@3 29 RUN_TEST262="true"
jlaskey@3 30 RUN_NODE="true"
jlaskey@3 31 KEEP_OUTPUT="true"
jlaskey@3 32 CLEAN_AND_BUILD_NASHORN="true"
jlaskey@3 33
jlaskey@3 34 #the stable node version to sync against
jlaskey@3 35 NODE_LAST_STABLE=v0.6.18
jlaskey@3 36
jlaskey@3 37 #parse args
jlaskey@3 38 for arg in $*
jlaskey@3 39 do
jlaskey@3 40 if [ $arg = "--no-test" ]; then
jlaskey@3 41 RUN_TEST="false"
jlaskey@3 42 echo "**** WARNING - you have disabled 'ant test', which is a minimum checkin requirement..."
jlaskey@3 43 elif [ $arg = "--no-262" ]; then
jlaskey@3 44 RUN_TEST262="false"
jlaskey@3 45 elif [ $arg = "--no-node" ]; then
jlaskey@3 46 RUN_NODE="false"
jlaskey@3 47 elif [ $arg = "--no-build" ]; then
jlaskey@3 48 CLEAN_AND_BUILD_NASHORN="false"
jlaskey@3 49 elif [ $arg = "--no-logs" ]; then
jlaskey@3 50 KEEP_OUTPUT="false"
jlaskey@3 51 fi
jlaskey@3 52 done
jlaskey@3 53
jlaskey@3 54 function lastpart() {
jlaskey@3 55 arr=$(echo $1 | tr "/" "\n")
jlaskey@3 56 for x in $arr
jlaskey@3 57 do
jlaskey@3 58 _last=$x
jlaskey@3 59 done
jlaskey@3 60 echo $_last
jlaskey@3 61 }
jlaskey@3 62
jlaskey@3 63 function check_installed() {
jlaskey@3 64 which $1 >/dev/null
jlaskey@3 65 if [ $? -ne 0 ]; then
jlaskey@3 66 echo "Error $1 not installed: $?"
jlaskey@3 67 exit 2
jlaskey@3 68 fi
jlaskey@3 69 }
jlaskey@3 70
jlaskey@3 71 check_installed hg
jlaskey@3 72 check_installed git
jlaskey@3 73 check_installed mv
jlaskey@3 74 check_installed git
jlaskey@3 75
jlaskey@3 76 PWD=$(pwd);
jlaskey@3 77
jlaskey@3 78 while [ -z $NASHORN_ROOT ]
jlaskey@3 79 do
jlaskey@3 80 if [ -e $PWD/.hg ]; then
jlaskey@3 81 NASHORN_ROOT=${PWD}
jlaskey@3 82 break
jlaskey@3 83 fi
jlaskey@3 84 PWD=$(dirname ${PWD})
jlaskey@3 85 done
jlaskey@3 86
jlaskey@3 87 echo "Nashorn root detected at ${NASHORN_ROOT}"
jlaskey@3 88
jlaskey@3 89 COMMON_ROOT=$(dirname $NASHORN_ROOT)
jlaskey@3 90 echo "Common root is ${COMMON_ROOT}"
jlaskey@3 91
jlaskey@3 92 echo "Running checkintest..."
jlaskey@3 93
jlaskey@3 94 ABSOLUTE_NASHORN_HOME=$COMMON_ROOT/$(lastpart $NASHORN_ROOT)
jlaskey@3 95
jlaskey@3 96 if [ $CLEAN_AND_BUILD_NASHORN != "false" ]; then
jlaskey@3 97 echo "Cleaning and building nashorn at $ABSOLUTE_NASHORN_HOME/nashorn..."
jlaskey@3 98 $(cd $ABSOLUTE_NASHORN_HOME/nashorn; ant clean >/dev/null 2>/dev/null)
jlaskey@3 99 $(cd $ABSOLUTE_NASHORN_HOME/nashorn; ant jar >/dev/null 2>/dev/null)
jlaskey@3 100 echo "Done."
jlaskey@3 101 fi
jlaskey@3 102
jlaskey@3 103 function failure_check() {
jlaskey@3 104 while read line
jlaskey@3 105 do
jlaskey@3 106 LINE=$(echo $line | grep "Tests run")
jlaskey@3 107 if [ "${LINE}" != "" ]; then
jlaskey@3 108 RESULT=$(echo $line | grep "Failures: 0" | grep "Errors: 0")
jlaskey@3 109 if [ "${RESULT}" == "" ]; then
jlaskey@3 110 TESTNAME=$2
jlaskey@3 111 echo "There were errors in ${TESTNAME} : ${LINE}"
jlaskey@3 112 exit 1
jlaskey@3 113 fi
jlaskey@3 114 fi
jlaskey@3 115 done < $1
jlaskey@3 116 }
jlaskey@3 117
jlaskey@3 118 function test() {
jlaskey@3 119 TEST_OUTPUT=$ABSOLUTE_NASHORN_HOME/$(mktemp tmp.XXXXX)
jlaskey@3 120 echo "Running 'ant test' on nashorn from ${ABSOLUTE_NASHORN_HOME}/nashorn..."
jlaskey@3 121 $(cd $ABSOLUTE_NASHORN_HOME/nashorn; ant test >$TEST_OUTPUT)
jlaskey@3 122 echo "Done."
jlaskey@3 123
jlaskey@3 124 failure_check $TEST_OUTPUT
jlaskey@3 125
jlaskey@3 126 echo "**** SUCCESS: 'ant test' successful"
jlaskey@3 127
jlaskey@3 128 if [ $KEEP_OUTPUT == "true" ]; then
jlaskey@3 129 cp $TEST_OUTPUT ./checkintest.test.log
jlaskey@3 130 rm -fr $TEST_OUTPUT
jlaskey@3 131 fi
jlaskey@3 132 }
jlaskey@3 133
jlaskey@3 134 if [ $RUN_TEST != "false" ]; then
jlaskey@3 135 test;
jlaskey@3 136 fi
jlaskey@3 137
jlaskey@3 138 function test262() {
jlaskey@3 139
jlaskey@3 140 echo "Running 'ant test262parallel' on nashorn from ${ABSOLUTE_NASHORN_HOME}/nashorn..."
jlaskey@3 141 TEST262_OUTPUT=$ABSOLUTE_NASHORN_HOME/$(mktemp tmp.XXXXX)
jlaskey@3 142
jlaskey@3 143 echo "Looking for ${ABSOLUTE_NASHORN_HOME}/test/test262..."
jlaskey@3 144
jlaskey@3 145 if [ ! -e $ABSOLUTE_NASHORN_HOME/nashorn/test/test262 ]; then
jlaskey@3 146 echo "test262 is missing... looking in $COMMON_ROOT..."
jlaskey@3 147 if [ ! -e $COMMON_ROOT/test262 ]; then
jlaskey@3 148 echo "... not there either... cloning from repo..."
jlaskey@3 149 hg clone http://hg.ecmascript.org/tests/test262 $COMMON_ROOT/test262 >/dev/null 2>/dev/null
jlaskey@3 150 echo "Done."
jlaskey@3 151 fi
jlaskey@3 152 echo "Adding soft link ${COMMON_ROOT}/test262 -> ${ABSOLUTE_NASHORN_HOME}/test/test262..."
jlaskey@3 153 ln -s $COMMON_ROOT/test262 $ABSOLUTE_NASHORN_HOME/nashorn/test/test262
jlaskey@3 154 echo "Done."
jlaskey@3 155 fi
jlaskey@3 156
jlaskey@3 157 echo "Ensuring test262 is up to date..."
jlaskey@3 158 $(cd $ABSOLUTE_NASHORN_HOME/nashorn/test/test262; hg pull -u >/dev/null 2>/dev/null)
jlaskey@3 159 echo "Done."
jlaskey@3 160
jlaskey@3 161 echo "Running test262..."
jlaskey@3 162 $(cd $ABSOLUTE_NASHORN_HOME/nashorn; ant test262parallel > $TEST262_OUTPUT)
jlaskey@3 163
jlaskey@3 164 FAILED=$(cat $TEST262_OUTPUT|grep "Tests run:"| cut -d ' ' -f 15 |tr -cd '"[[:digit:]]')
jlaskey@3 165 if [ $FAILED -gt $TEST262_PASS_AT_LEAST ]; then
jlaskey@3 166 echo "FAILURE: There are ${FAILED} failures in test262 and can be no more than ${TEST262_PASS_AT_LEAST}"
jlaskey@3 167 cp $TEST262_OUTPUT ./checkintest.test262.log
jlaskey@3 168 echo "See ./checkintest.test262.log"
jlaskey@3 169 echo "Terminating due to error"
jlaskey@3 170 exit 1
jlaskey@3 171 elif [ $FAILED -lt $TEST262_PASS_AT_LEAST ]; then
jlaskey@3 172 echo "There seem to have been fixes to 262. ${FAILED} < ${TEST262_PASS_AT_LEAST}. Please update limit in bin/checkintest.sh"
jlaskey@3 173 fi
jlaskey@3 174
jlaskey@3 175 echo "**** SUCCESS: Test262 passed with no more than ${TEST262_PASS_AT_LEAST} failures."
jlaskey@3 176
jlaskey@3 177 if [ $KEEP_OUTPUT == "true" ]; then
jlaskey@3 178 cp $TEST262_OUTPUT ./checkintest.test262.log
jlaskey@3 179 rm -fr $TEST262_OUTPUT
jlaskey@3 180 fi
jlaskey@3 181 }
jlaskey@3 182
jlaskey@3 183 if [ $RUN_TEST262 != "false" ]; then
jlaskey@3 184 test262;
jlaskey@3 185 fi;
jlaskey@3 186
jlaskey@3 187 function testnode() {
jlaskey@3 188 TESTNODEJAR_OUTPUT=$ABSOLUTE_NASHORN_HOME/$(mktemp tmp.XXXXX)
jlaskey@3 189
jlaskey@3 190 echo "Running node tests..."
jlaskey@3 191 #replace node jar properties nashorn with this nashorn
jlaskey@3 192
jlaskey@3 193 NODEJAR_PROPERTIES=~/nodejar.properties
jlaskey@3 194
jlaskey@3 195 NODE_HOME=$(cat $NODEJAR_PROPERTIES | grep ^node.home | cut -f2 -d=)
jlaskey@3 196 NASHORN_HOME=$(cat $NODEJAR_PROPERTIES | grep ^nashorn.home | cut -f2 -d=)
jlaskey@3 197
jlaskey@3 198 ABSOLUTE_NODE_HOME=$COMMON_ROOT/$(lastpart $NODE_HOME)
jlaskey@3 199
jlaskey@3 200 echo "Writing nodejar.properties..."
jlaskey@3 201
jlaskey@3 202 cat > $NODEJAR_PROPERTIES << EOF
jlaskey@3 203 node.home=../node
jlaskey@3 204 nashorn.home=../$(lastpart $NASHORN_ROOT)
jlaskey@3 205 EOF
jlaskey@3 206 echo "Done."
jlaskey@3 207 echo "Checking node home ${ABSOLUTE_NODE_HOME}..."
jlaskey@3 208
jlaskey@3 209 if [ ! -e $ABSOLUTE_NODE_HOME ]; then
jlaskey@3 210 echo "Node base dir not found. Cloning node..."
jlaskey@3 211 $(cd $COMMON_ROOT; git clone https://github.com/joyent/node.git $(lastpart $NODE_HOME) >/dev/null 2>/dev/null)
jlaskey@3 212 echo "Done."
jlaskey@3 213 echo "Updating to last stable version ${NODE_LAST_STABLE}..."
jlaskey@3 214 $(cd $ABSOLUTE_NODE_HOME; git checkout $NODE_LAST_STABLE >/dev/null 2>/dev/null)
jlaskey@3 215 echo "Done."
jlaskey@3 216 echo "Running configure..."
jlaskey@3 217 $(cd $ABSOLUTE_NODE_HOME; ./configure >/dev/null 2>/dev/null)
jlaskey@3 218 echo "Done."
jlaskey@3 219 fi
jlaskey@3 220
jlaskey@3 221 echo "Ensuring node is built..."
jlaskey@3 222 #make sure node is built
jlaskey@3 223 $(cd $ABSOLUTE_NODE_HOME; make >/dev/null 2>/dev/null)
jlaskey@3 224 echo "Done."
jlaskey@3 225
jlaskey@3 226 NODEJAR_HOME=$COMMON_ROOT/nodejar
jlaskey@3 227
jlaskey@3 228 if [ ! -e $NODEJAR_HOME ]; then
jlaskey@3 229 echo "No node jar home found. cloning from depot..."
jlaskey@3 230 $(cd $COMMON_ROOT; hg clone https://hg.kenai.com/hg/nodejs~source nodejar >/dev/null 2>/dev/null)
jlaskey@3 231 $(cd $COMMON_ROOT/nodejar; ant >/dev/null)
jlaskey@3 232 echo "Done."
jlaskey@3 233 echo "Copying node files..."
jlaskey@3 234 $(cd $COMMON_ROOT/nodejar; ant copy-node-files >/dev/null 2>/dev/null)
jlaskey@3 235 echo "Patching node files..."
jlaskey@3 236 $(cd $COMMON_ROOT/nodejar; ant patch-node-files >/dev/null 2>/dev/null)
jlaskey@3 237 echo "Done."
jlaskey@3 238 fi
jlaskey@3 239
jlaskey@3 240 echo "Ensuring node.jar is up to date from source depot..."
jlaskey@3 241 $(cd $COMMON_ROOT/nodejar; hg pull -u >/dev/null 2>/dev/null)
jlaskey@3 242 echo "Done."
jlaskey@3 243
jlaskey@3 244 echo "Installing nashorn..."
jlaskey@3 245 $(cd $COMMON_ROOT/nodejar; ant >/dev/null)
jlaskey@3 246 echo "Done."
jlaskey@3 247
jlaskey@3 248 echo "Running node.jar test..."
jlaskey@3 249 $(cd $COMMON_ROOT/nodejar; mvn clean verify >$TESTNODEJAR_OUTPUT)
jlaskey@3 250 echo "Done."
jlaskey@3 251
jlaskey@3 252 failure_check $TESTNODEJAR_OUTPUT
jlaskey@3 253
jlaskey@3 254 echo "**** SUCCESS: Node test successful."
jlaskey@3 255
jlaskey@3 256 if [ $KEEP_OUTPUT == "true" ]; then
jlaskey@3 257 rm -fr $TESTNODEJAR_OUTPUT
jlaskey@3 258 cp $TESTNODEJAR_OUTPUT ./checkintest.nodejar.log
jlaskey@3 259 fi
jlaskey@3 260 }
jlaskey@3 261
jlaskey@3 262 if [ $RUN_NODE != "false" ]; then
jlaskey@3 263 testnode;
jlaskey@3 264 fi;
jlaskey@3 265
jlaskey@3 266 echo "Finished"

mercurial