aoqi@0: #!/bin/bash aoqi@0: # aoqi@0: # Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: # aoqi@0: # This code is free software; you can redistribute it and/or modify it aoqi@0: # under the terms of the GNU General Public License version 2 only, as aoqi@0: # published by the Free Software Foundation. aoqi@0: # aoqi@0: # This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: # version 2 for more details (a copy is included in the LICENSE file that aoqi@0: # accompanied this code). aoqi@0: # aoqi@0: # You should have received a copy of the GNU General Public License version aoqi@0: # 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: # aoqi@0: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: # or visit www.oracle.com if you need additional information or have any aoqi@0: # questions. aoqi@0: # aoqi@0: aoqi@0: #best pass rate at test 262 known aoqi@0: TEST262_PASS_AT_LEAST=435 aoqi@0: aoqi@0: RUN_TEST="true" aoqi@0: RUN_TEST262="true" aoqi@0: RUN_NODE="true" aoqi@0: KEEP_OUTPUT="true" aoqi@0: CLEAN_AND_BUILD_NASHORN="true" aoqi@0: aoqi@0: #the stable node version to sync against aoqi@0: NODE_LAST_STABLE=v0.6.18 aoqi@0: aoqi@0: #parse args aoqi@0: for arg in $* aoqi@0: do aoqi@0: if [ $arg = "--no-test" ]; then aoqi@0: RUN_TEST="false" aoqi@0: echo "**** WARNING - you have disabled 'ant test', which is a minimum checkin requirement..." aoqi@0: elif [ $arg = "--no-262" ]; then aoqi@0: RUN_TEST262="false" aoqi@0: elif [ $arg = "--no-node" ]; then aoqi@0: RUN_NODE="false" aoqi@0: elif [ $arg = "--no-build" ]; then aoqi@0: CLEAN_AND_BUILD_NASHORN="false" aoqi@0: elif [ $arg = "--no-logs" ]; then aoqi@0: KEEP_OUTPUT="false" aoqi@0: fi aoqi@0: done aoqi@0: aoqi@0: function lastpart() { aoqi@0: arr=$(echo $1 | tr "/" "\n") aoqi@0: for x in $arr aoqi@0: do aoqi@0: _last=$x aoqi@0: done aoqi@0: echo $_last aoqi@0: } aoqi@0: aoqi@0: function check_installed() { aoqi@0: which $1 >/dev/null aoqi@0: if [ $? -ne 0 ]; then aoqi@0: echo "Error $1 not installed: $?" aoqi@0: exit 2 aoqi@0: fi aoqi@0: } aoqi@0: aoqi@0: check_installed hg aoqi@0: check_installed git aoqi@0: check_installed mv aoqi@0: check_installed git aoqi@0: aoqi@0: PWD=$(pwd); aoqi@0: aoqi@0: while [ -z $NASHORN_ROOT ] aoqi@0: do aoqi@0: if [ -e $PWD/.hg ]; then aoqi@0: NASHORN_ROOT=${PWD} aoqi@0: break aoqi@0: fi aoqi@0: PWD=$(dirname ${PWD}) aoqi@0: done aoqi@0: aoqi@0: echo "Nashorn root detected at ${NASHORN_ROOT}" aoqi@0: aoqi@0: COMMON_ROOT=$(dirname $NASHORN_ROOT) aoqi@0: echo "Common root is ${COMMON_ROOT}" aoqi@0: aoqi@0: echo "Running checkintest..." aoqi@0: aoqi@0: ABSOLUTE_NASHORN_HOME=$COMMON_ROOT/$(lastpart $NASHORN_ROOT) aoqi@0: aoqi@0: if [ $CLEAN_AND_BUILD_NASHORN != "false" ]; then aoqi@0: echo "Cleaning and building nashorn at $ABSOLUTE_NASHORN_HOME/nashorn..." aoqi@0: $(cd $ABSOLUTE_NASHORN_HOME/nashorn; ant clean >/dev/null 2>/dev/null) aoqi@0: $(cd $ABSOLUTE_NASHORN_HOME/nashorn; ant jar >/dev/null 2>/dev/null) aoqi@0: echo "Done." aoqi@0: fi aoqi@0: aoqi@0: function failure_check() { aoqi@0: while read line aoqi@0: do aoqi@0: LINE=$(echo $line | grep "Tests run") aoqi@0: if [ "${LINE}" != "" ]; then aoqi@0: RESULT=$(echo $line | grep "Failures: 0" | grep "Errors: 0") aoqi@0: if [ "${RESULT}" == "" ]; then aoqi@0: TESTNAME=$2 aoqi@0: echo "There were errors in ${TESTNAME} : ${LINE}" aoqi@0: exit 1 aoqi@0: fi aoqi@0: fi aoqi@0: done < $1 aoqi@0: } aoqi@0: aoqi@0: function test() { aoqi@0: TEST_OUTPUT=$ABSOLUTE_NASHORN_HOME/$(mktemp tmp.XXXXX) aoqi@0: echo "Running 'ant test' on nashorn from ${ABSOLUTE_NASHORN_HOME}/nashorn..." aoqi@0: $(cd $ABSOLUTE_NASHORN_HOME/nashorn; ant test >$TEST_OUTPUT) aoqi@0: echo "Done." aoqi@0: aoqi@0: failure_check $TEST_OUTPUT aoqi@0: aoqi@0: echo "**** SUCCESS: 'ant test' successful" aoqi@0: aoqi@0: if [ $KEEP_OUTPUT == "true" ]; then aoqi@0: cp $TEST_OUTPUT ./checkintest.test.log aoqi@0: rm -fr $TEST_OUTPUT aoqi@0: fi aoqi@0: } aoqi@0: aoqi@0: if [ $RUN_TEST != "false" ]; then aoqi@0: test; aoqi@0: fi aoqi@0: aoqi@0: function test262() { aoqi@0: aoqi@0: echo "Running 'ant test262parallel' on nashorn from ${ABSOLUTE_NASHORN_HOME}/nashorn..." aoqi@0: TEST262_OUTPUT=$ABSOLUTE_NASHORN_HOME/$(mktemp tmp.XXXXX) aoqi@0: aoqi@0: echo "Looking for ${ABSOLUTE_NASHORN_HOME}/test/test262..." aoqi@0: aoqi@0: if [ ! -e $ABSOLUTE_NASHORN_HOME/nashorn/test/test262 ]; then aoqi@0: echo "test262 is missing... looking in $COMMON_ROOT..." aoqi@0: if [ ! -e $COMMON_ROOT/test262 ]; then aoqi@0: echo "... not there either... cloning from repo..." aoqi@0: hg clone http://hg.ecmascript.org/tests/test262 $COMMON_ROOT/test262 >/dev/null 2>/dev/null aoqi@0: echo "Done." aoqi@0: fi aoqi@0: echo "Adding soft link ${COMMON_ROOT}/test262 -> ${ABSOLUTE_NASHORN_HOME}/test/test262..." aoqi@0: ln -s $COMMON_ROOT/test262 $ABSOLUTE_NASHORN_HOME/nashorn/test/test262 aoqi@0: echo "Done." aoqi@0: fi aoqi@0: aoqi@0: echo "Ensuring test262 is up to date..." aoqi@0: $(cd $ABSOLUTE_NASHORN_HOME/nashorn/test/test262; hg pull -u >/dev/null 2>/dev/null) aoqi@0: echo "Done." aoqi@0: aoqi@0: echo "Running test262..." aoqi@0: $(cd $ABSOLUTE_NASHORN_HOME/nashorn; ant test262parallel > $TEST262_OUTPUT) aoqi@0: aoqi@0: FAILED=$(cat $TEST262_OUTPUT|grep "Tests run:"| cut -d ' ' -f 15 |tr -cd '"[[:digit:]]') aoqi@0: if [ $FAILED -gt $TEST262_PASS_AT_LEAST ]; then aoqi@0: echo "FAILURE: There are ${FAILED} failures in test262 and can be no more than ${TEST262_PASS_AT_LEAST}" aoqi@0: cp $TEST262_OUTPUT ./checkintest.test262.log aoqi@0: echo "See ./checkintest.test262.log" aoqi@0: echo "Terminating due to error" aoqi@0: exit 1 aoqi@0: elif [ $FAILED -lt $TEST262_PASS_AT_LEAST ]; then aoqi@0: echo "There seem to have been fixes to 262. ${FAILED} < ${TEST262_PASS_AT_LEAST}. Please update limit in bin/checkintest.sh" aoqi@0: fi aoqi@0: aoqi@0: echo "**** SUCCESS: Test262 passed with no more than ${TEST262_PASS_AT_LEAST} failures." aoqi@0: aoqi@0: if [ $KEEP_OUTPUT == "true" ]; then aoqi@0: cp $TEST262_OUTPUT ./checkintest.test262.log aoqi@0: rm -fr $TEST262_OUTPUT aoqi@0: fi aoqi@0: } aoqi@0: aoqi@0: if [ $RUN_TEST262 != "false" ]; then aoqi@0: test262; aoqi@0: fi; aoqi@0: aoqi@0: function testnode() { aoqi@0: TESTNODEJAR_OUTPUT=$ABSOLUTE_NASHORN_HOME/$(mktemp tmp.XXXXX) aoqi@0: aoqi@0: echo "Running node tests..." aoqi@0: #replace node jar properties nashorn with this nashorn aoqi@0: aoqi@0: NODEJAR_PROPERTIES=~/nodejar.properties aoqi@0: aoqi@0: NODE_HOME=$(cat $NODEJAR_PROPERTIES | grep ^node.home | cut -f2 -d=) aoqi@0: NASHORN_HOME=$(cat $NODEJAR_PROPERTIES | grep ^nashorn.home | cut -f2 -d=) aoqi@0: aoqi@0: ABSOLUTE_NODE_HOME=$COMMON_ROOT/$(lastpart $NODE_HOME) aoqi@0: aoqi@0: echo "Writing nodejar.properties..." aoqi@0: aoqi@0: cat > $NODEJAR_PROPERTIES << EOF aoqi@0: node.home=../node aoqi@0: nashorn.home=../$(lastpart $NASHORN_ROOT) aoqi@0: EOF aoqi@0: echo "Done." aoqi@0: echo "Checking node home ${ABSOLUTE_NODE_HOME}..." aoqi@0: aoqi@0: if [ ! -e $ABSOLUTE_NODE_HOME ]; then aoqi@0: echo "Node base dir not found. Cloning node..." aoqi@0: $(cd $COMMON_ROOT; git clone https://github.com/joyent/node.git $(lastpart $NODE_HOME) >/dev/null 2>/dev/null) aoqi@0: echo "Done." aoqi@0: echo "Updating to last stable version ${NODE_LAST_STABLE}..." aoqi@0: $(cd $ABSOLUTE_NODE_HOME; git checkout $NODE_LAST_STABLE >/dev/null 2>/dev/null) aoqi@0: echo "Done." aoqi@0: echo "Running configure..." aoqi@0: $(cd $ABSOLUTE_NODE_HOME; ./configure >/dev/null 2>/dev/null) aoqi@0: echo "Done." aoqi@0: fi aoqi@0: aoqi@0: echo "Ensuring node is built..." aoqi@0: #make sure node is built aoqi@0: $(cd $ABSOLUTE_NODE_HOME; make >/dev/null 2>/dev/null) aoqi@0: echo "Done." aoqi@0: aoqi@0: NODEJAR_HOME=$COMMON_ROOT/nodejar aoqi@0: aoqi@0: if [ ! -e $NODEJAR_HOME ]; then aoqi@0: echo "No node jar home found. cloning from depot..." aoqi@0: $(cd $COMMON_ROOT; hg clone https://hg.kenai.com/hg/nodejs~source nodejar >/dev/null 2>/dev/null) aoqi@0: $(cd $COMMON_ROOT/nodejar; ant >/dev/null) aoqi@0: echo "Done." aoqi@0: echo "Copying node files..." aoqi@0: $(cd $COMMON_ROOT/nodejar; ant copy-node-files >/dev/null 2>/dev/null) aoqi@0: echo "Patching node files..." aoqi@0: $(cd $COMMON_ROOT/nodejar; ant patch-node-files >/dev/null 2>/dev/null) aoqi@0: echo "Done." aoqi@0: fi aoqi@0: aoqi@0: echo "Ensuring node.jar is up to date from source depot..." aoqi@0: $(cd $COMMON_ROOT/nodejar; hg pull -u >/dev/null 2>/dev/null) aoqi@0: echo "Done." aoqi@0: aoqi@0: echo "Installing nashorn..." aoqi@0: $(cd $COMMON_ROOT/nodejar; ant >/dev/null) aoqi@0: echo "Done." aoqi@0: aoqi@0: echo "Running node.jar test..." aoqi@0: $(cd $COMMON_ROOT/nodejar; mvn clean verify >$TESTNODEJAR_OUTPUT) aoqi@0: echo "Done." aoqi@0: aoqi@0: failure_check $TESTNODEJAR_OUTPUT aoqi@0: aoqi@0: echo "**** SUCCESS: Node test successful." aoqi@0: aoqi@0: if [ $KEEP_OUTPUT == "true" ]; then aoqi@0: rm -fr $TESTNODEJAR_OUTPUT aoqi@0: cp $TESTNODEJAR_OUTPUT ./checkintest.nodejar.log aoqi@0: fi aoqi@0: } aoqi@0: aoqi@0: if [ $RUN_NODE != "false" ]; then aoqi@0: testnode; aoqi@0: fi; aoqi@0: aoqi@0: echo "Finished"