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