bin/checkintest.sh

changeset 0
b1a7da25b547
child 952
6d5471a497fb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/bin/checkintest.sh	Wed Apr 27 01:36:41 2016 +0800
     1.3 @@ -0,0 +1,266 @@
     1.4 +#!/bin/bash
     1.5 +#
     1.6 +# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8 +# 
     1.9 +# This code is free software; you can redistribute it and/or modify it
    1.10 +# under the terms of the GNU General Public License version 2 only, as
    1.11 +# published by the Free Software Foundation.
    1.12 +# 
    1.13 +# This code is distributed in the hope that it will be useful, but WITHOUT
    1.14 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.15 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.16 +# version 2 for more details (a copy is included in the LICENSE file that
    1.17 +# accompanied this code).
    1.18 +# 
    1.19 +# You should have received a copy of the GNU General Public License version
    1.20 +# 2 along with this work; if not, write to the Free Software Foundation,
    1.21 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.22 +# 
    1.23 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.24 +# or visit www.oracle.com if you need additional information or have any
    1.25 +# questions.
    1.26 +#
    1.27 +
    1.28 +#best pass rate at test 262 known
    1.29 +TEST262_PASS_AT_LEAST=435
    1.30 +
    1.31 +RUN_TEST="true"
    1.32 +RUN_TEST262="true"
    1.33 +RUN_NODE="true"
    1.34 +KEEP_OUTPUT="true"
    1.35 +CLEAN_AND_BUILD_NASHORN="true"
    1.36 +
    1.37 +#the stable node version to sync against
    1.38 +NODE_LAST_STABLE=v0.6.18
    1.39 +
    1.40 +#parse args
    1.41 +for arg in $*
    1.42 +do
    1.43 +    if [ $arg = "--no-test" ]; then
    1.44 +	RUN_TEST="false"
    1.45 +	echo "**** WARNING - you have disabled 'ant test', which is a minimum checkin requirement..."
    1.46 +    elif [ $arg = "--no-262" ]; then
    1.47 +	RUN_TEST262="false"
    1.48 +    elif [ $arg = "--no-node" ]; then
    1.49 +	RUN_NODE="false"
    1.50 +    elif [ $arg = "--no-build" ]; then
    1.51 +	CLEAN_AND_BUILD_NASHORN="false"
    1.52 +    elif [ $arg = "--no-logs" ]; then
    1.53 +	KEEP_OUTPUT="false"
    1.54 +    fi
    1.55 +done
    1.56 +
    1.57 +function lastpart() {        
    1.58 +    arr=$(echo $1 | tr "/" "\n")
    1.59 +    for x in $arr
    1.60 +    do
    1.61 +	_last=$x
    1.62 +    done
    1.63 +    echo $_last
    1.64 +}
    1.65 +
    1.66 +function check_installed() {
    1.67 +    which $1 >/dev/null
    1.68 +    if [ $? -ne 0 ]; then
    1.69 +	echo "Error $1 not installed: $?"
    1.70 +	exit 2
    1.71 +    fi
    1.72 +}
    1.73 +
    1.74 +check_installed hg
    1.75 +check_installed git
    1.76 +check_installed mv
    1.77 +check_installed git
    1.78 +
    1.79 +PWD=$(pwd);
    1.80 +
    1.81 +while [ -z $NASHORN_ROOT ]
    1.82 +do
    1.83 +    if [ -e $PWD/.hg ]; then
    1.84 +	NASHORN_ROOT=${PWD}
    1.85 +	break
    1.86 +    fi
    1.87 +    PWD=$(dirname ${PWD})
    1.88 +done
    1.89 +
    1.90 +echo "Nashorn root detected at ${NASHORN_ROOT}"
    1.91 +
    1.92 +COMMON_ROOT=$(dirname $NASHORN_ROOT)
    1.93 +echo "Common root is ${COMMON_ROOT}"
    1.94 +
    1.95 +echo "Running checkintest..."
    1.96 +
    1.97 +ABSOLUTE_NASHORN_HOME=$COMMON_ROOT/$(lastpart $NASHORN_ROOT)
    1.98 +
    1.99 +if [ $CLEAN_AND_BUILD_NASHORN != "false" ]; then
   1.100 +    echo "Cleaning and building nashorn at $ABSOLUTE_NASHORN_HOME/nashorn..."
   1.101 +    $(cd $ABSOLUTE_NASHORN_HOME/nashorn; ant clean >/dev/null 2>/dev/null)
   1.102 +    $(cd $ABSOLUTE_NASHORN_HOME/nashorn; ant jar >/dev/null 2>/dev/null)
   1.103 +    echo "Done."
   1.104 +fi
   1.105 +
   1.106 +function failure_check() {
   1.107 +    while read line
   1.108 +    do
   1.109 +	LINE=$(echo $line | grep "Tests run")    
   1.110 +	if [ "${LINE}" != "" ]; then
   1.111 +	    RESULT=$(echo $line | grep "Failures: 0" | grep "Errors: 0")
   1.112 +	    if [ "${RESULT}" == "" ]; then
   1.113 +		TESTNAME=$2
   1.114 +		echo "There were errors in ${TESTNAME} : ${LINE}"
   1.115 +		exit 1
   1.116 +	    fi
   1.117 +	fi
   1.118 +    done < $1
   1.119 +}
   1.120 +
   1.121 +function test() {
   1.122 +    TEST_OUTPUT=$ABSOLUTE_NASHORN_HOME/$(mktemp tmp.XXXXX)
   1.123 +    echo "Running 'ant test' on nashorn from ${ABSOLUTE_NASHORN_HOME}/nashorn..."
   1.124 +    $(cd $ABSOLUTE_NASHORN_HOME/nashorn; ant test >$TEST_OUTPUT)
   1.125 +    echo "Done."
   1.126 +
   1.127 +    failure_check $TEST_OUTPUT
   1.128 +
   1.129 +    echo "**** SUCCESS: 'ant test' successful"
   1.130 +
   1.131 +    if [ $KEEP_OUTPUT == "true" ]; then
   1.132 +	cp $TEST_OUTPUT ./checkintest.test.log
   1.133 +	rm -fr $TEST_OUTPUT
   1.134 +    fi
   1.135 +}
   1.136 +
   1.137 +if [ $RUN_TEST != "false" ]; then
   1.138 +    test;
   1.139 +fi
   1.140 +
   1.141 +function test262() {
   1.142 +
   1.143 +    echo "Running 'ant test262parallel' on nashorn from ${ABSOLUTE_NASHORN_HOME}/nashorn..."
   1.144 +    TEST262_OUTPUT=$ABSOLUTE_NASHORN_HOME/$(mktemp tmp.XXXXX)
   1.145 +
   1.146 +    echo "Looking for ${ABSOLUTE_NASHORN_HOME}/test/test262..."
   1.147 +
   1.148 +    if [ ! -e $ABSOLUTE_NASHORN_HOME/nashorn/test/test262 ]; then
   1.149 +	echo "test262 is missing... looking in $COMMON_ROOT..."
   1.150 +	if [ ! -e $COMMON_ROOT/test262 ]; then
   1.151 +	    echo "... not there either... cloning from repo..."
   1.152 +	    hg clone http://hg.ecmascript.org/tests/test262 $COMMON_ROOT/test262 >/dev/null 2>/dev/null
   1.153 +	    echo "Done."
   1.154 +	fi
   1.155 +	echo "Adding soft link ${COMMON_ROOT}/test262 -> ${ABSOLUTE_NASHORN_HOME}/test/test262..."
   1.156 +	ln -s $COMMON_ROOT/test262 $ABSOLUTE_NASHORN_HOME/nashorn/test/test262
   1.157 +	echo "Done."
   1.158 +    fi
   1.159 +
   1.160 +    echo "Ensuring test262 is up to date..."
   1.161 +    $(cd $ABSOLUTE_NASHORN_HOME/nashorn/test/test262; hg pull -u >/dev/null 2>/dev/null)
   1.162 +    echo "Done."
   1.163 +
   1.164 +    echo "Running test262..."
   1.165 +    $(cd $ABSOLUTE_NASHORN_HOME/nashorn; ant test262parallel > $TEST262_OUTPUT)
   1.166 +    
   1.167 +    FAILED=$(cat $TEST262_OUTPUT|grep "Tests run:"| cut -d ' ' -f 15 |tr -cd '"[[:digit:]]')
   1.168 +    if [ $FAILED -gt $TEST262_PASS_AT_LEAST ]; then 
   1.169 +	echo "FAILURE: There are ${FAILED} failures in test262 and can be no more than ${TEST262_PASS_AT_LEAST}"
   1.170 +	cp $TEST262_OUTPUT ./checkintest.test262.log
   1.171 +	echo "See ./checkintest.test262.log"
   1.172 +	echo "Terminating due to error"
   1.173 +	exit 1
   1.174 +    elif [ $FAILED -lt $TEST262_PASS_AT_LEAST ]; then
   1.175 +	echo "There seem to have been fixes to 262. ${FAILED} < ${TEST262_PASS_AT_LEAST}. Please update limit in bin/checkintest.sh"
   1.176 +    fi
   1.177 +    
   1.178 +    echo "**** SUCCESS: Test262 passed with no more than ${TEST262_PASS_AT_LEAST} failures."
   1.179 +
   1.180 +    if [ $KEEP_OUTPUT == "true" ]; then
   1.181 +	cp $TEST262_OUTPUT ./checkintest.test262.log
   1.182 +	rm -fr $TEST262_OUTPUT
   1.183 +    fi    
   1.184 +}
   1.185 +
   1.186 +if [ $RUN_TEST262 != "false" ]; then
   1.187 +    test262;    
   1.188 +fi;
   1.189 +
   1.190 +function testnode() {
   1.191 +    TESTNODEJAR_OUTPUT=$ABSOLUTE_NASHORN_HOME/$(mktemp tmp.XXXXX)
   1.192 +   
   1.193 +    echo "Running node tests..."
   1.194 +#replace node jar properties nashorn with this nashorn
   1.195 +    
   1.196 +    NODEJAR_PROPERTIES=~/nodejar.properties
   1.197 +    
   1.198 +    NODE_HOME=$(cat $NODEJAR_PROPERTIES | grep ^node.home | cut -f2 -d=)    
   1.199 +    NASHORN_HOME=$(cat $NODEJAR_PROPERTIES | grep ^nashorn.home | cut -f2 -d=)
   1.200 +    
   1.201 +    ABSOLUTE_NODE_HOME=$COMMON_ROOT/$(lastpart $NODE_HOME)    
   1.202 +    
   1.203 +    echo "Writing nodejar.properties..."
   1.204 +
   1.205 +    cat > $NODEJAR_PROPERTIES << EOF
   1.206 +node.home=../node
   1.207 +nashorn.home=../$(lastpart $NASHORN_ROOT)
   1.208 +EOF
   1.209 +    echo "Done."
   1.210 +    echo "Checking node home ${ABSOLUTE_NODE_HOME}..."
   1.211 +
   1.212 +    if [ ! -e $ABSOLUTE_NODE_HOME ]; then
   1.213 +	echo "Node base dir not found. Cloning node..."    
   1.214 +	$(cd $COMMON_ROOT; git clone https://github.com/joyent/node.git $(lastpart $NODE_HOME) >/dev/null 2>/dev/null)
   1.215 +	echo "Done."
   1.216 +	echo "Updating to last stable version ${NODE_LAST_STABLE}..."
   1.217 +	$(cd $ABSOLUTE_NODE_HOME; git checkout $NODE_LAST_STABLE >/dev/null 2>/dev/null)
   1.218 +	echo "Done."
   1.219 +	echo "Running configure..."
   1.220 +	$(cd $ABSOLUTE_NODE_HOME; ./configure >/dev/null 2>/dev/null)
   1.221 +	echo "Done."
   1.222 +    fi
   1.223 +    
   1.224 +    echo "Ensuring node is built..."
   1.225 +#make sure node is built
   1.226 +    $(cd $ABSOLUTE_NODE_HOME; make >/dev/null 2>/dev/null)
   1.227 +    echo "Done."
   1.228 +
   1.229 +    NODEJAR_HOME=$COMMON_ROOT/nodejar
   1.230 +
   1.231 +    if [ ! -e $NODEJAR_HOME ]; then
   1.232 +	echo "No node jar home found. cloning from depot..."
   1.233 +	$(cd $COMMON_ROOT; hg clone https://hg.kenai.com/hg/nodejs~source nodejar >/dev/null 2>/dev/null) 
   1.234 +	$(cd $COMMON_ROOT/nodejar; ant >/dev/null)
   1.235 +	echo "Done."
   1.236 +	echo "Copying node files..."
   1.237 +	$(cd $COMMON_ROOT/nodejar; ant copy-node-files >/dev/null 2>/dev/null)
   1.238 +	echo "Patching node files..."
   1.239 +	$(cd $COMMON_ROOT/nodejar; ant patch-node-files >/dev/null 2>/dev/null)
   1.240 +	echo "Done."
   1.241 +    fi
   1.242 +    
   1.243 +    echo "Ensuring node.jar is up to date from source depot..."
   1.244 +    $(cd $COMMON_ROOT/nodejar; hg pull -u >/dev/null 2>/dev/null)
   1.245 +    echo "Done."
   1.246 +
   1.247 +    echo "Installing nashorn..."
   1.248 +    $(cd $COMMON_ROOT/nodejar; ant >/dev/null)
   1.249 +    echo "Done."
   1.250 +
   1.251 +    echo "Running node.jar test..."
   1.252 +    $(cd $COMMON_ROOT/nodejar; mvn clean verify >$TESTNODEJAR_OUTPUT)
   1.253 +    echo "Done."
   1.254 +
   1.255 +    failure_check $TESTNODEJAR_OUTPUT
   1.256 +    
   1.257 +    echo "**** SUCCESS: Node test successful."
   1.258 +
   1.259 +    if [ $KEEP_OUTPUT == "true" ]; then
   1.260 +	rm -fr $TESTNODEJAR_OUTPUT
   1.261 +	cp $TESTNODEJAR_OUTPUT ./checkintest.nodejar.log
   1.262 +    fi
   1.263 +}
   1.264 +
   1.265 +if [ $RUN_NODE != "false" ]; then
   1.266 +    testnode;
   1.267 +fi;
   1.268 +
   1.269 +echo "Finished"

mercurial