bin/checkintest.sh

Wed, 27 Apr 2016 01:36:41 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:36:41 +0800
changeset 0
b1a7da25b547
child 952
6d5471a497fb
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/nashorn/
changeset: 1034:4b9cc65dd24d
tag: jdk8u25-b17

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

mercurial