annotate bin/checkintest.sh @ 673:f0d3ac2474ee

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