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