blob: 24f1f2ea13bd314d7675e73151af425bc17b422c [file] [log] [blame]
Roger Meier8909cbd2014-01-26 11:44:27 +01001#! /bin/sh
2
Roger Meier8909cbd2014-01-26 11:44:27 +01003# Licensed to the Apache Software Foundation (ASF) under one
4# or more contributor license agreements. See the NOTICE file
5# distributed with this work for additional information
6# regarding copyright ownership. The ASF licenses this file
7# to you under the Apache License, Version 2.0 (the
8# "License"); you may not use this file except in compliance
9# with the License. You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing,
14# software distributed under the License is distributed on an
15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16# KIND, either express or implied. See the License for the
17# specific language governing permissions and limitations
18# under the License.
Roger Meier8909cbd2014-01-26 11:44:27 +010019
Randy Abernethy8e731372015-02-03 00:04:40 -080020if [ -n "${1}" ]; then
21 COVER=${1};
22fi
23
Roger Meier8909cbd2014-01-26 11:44:27 +010024DIR="$( cd "$( dirname "$0" )" && pwd )"
25
Randy Abernethy8e731372015-02-03 00:04:40 -080026ISTANBUL="$DIR/../../../node_modules/istanbul/lib/cli.js"
Randy Abernethy8e731372015-02-03 00:04:40 -080027
28REPORT_PREFIX="${DIR}/../coverage/report"
29
30COUNT=0
31
Roger Meier8909cbd2014-01-26 11:44:27 +010032export NODE_PATH="${DIR}:${DIR}/../lib:${NODE_PATH}"
33
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080034testServer()
Roger Meier8909cbd2014-01-26 11:44:27 +010035{
bforbisda1169d2018-10-28 11:27:38 -040036 echo " [ECMA $1] Testing $2 Client/Server with protocol $3 and transport $4 $5";
Roger Meier8909cbd2014-01-26 11:44:27 +010037 RET=0
Randy Abernethy8e731372015-02-03 00:04:40 -080038 if [ -n "${COVER}" ]; then
bforbisda1169d2018-10-28 11:27:38 -040039 ${ISTANBUL} cover ${DIR}/server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- --type $2 -p $3 -t $4 $5 &
Randy Abernethy8e731372015-02-03 00:04:40 -080040 COUNT=$((COUNT+1))
41 else
bforbisda1169d2018-10-28 11:27:38 -040042 node ${DIR}/server.js --${1} --type $2 -p $3 -t $4 $5 &
Randy Abernethy8e731372015-02-03 00:04:40 -080043 fi
Roger Meier8909cbd2014-01-26 11:44:27 +010044 SERVERPID=$!
James E. King, III699b5bc2017-09-14 08:07:08 -070045 sleep 0.1
Randy Abernethy8e731372015-02-03 00:04:40 -080046 if [ -n "${COVER}" ]; then
bforbisda1169d2018-10-28 11:27:38 -040047 ${ISTANBUL} cover ${DIR}/client.js --dir ${REPORT_PREFIX}${COUNT} -- --${1} --type $2 -p $3 -t $4 $5 || RET=1
Randy Abernethy8e731372015-02-03 00:04:40 -080048 COUNT=$((COUNT+1))
49 else
bforbisda1169d2018-10-28 11:27:38 -040050 node ${DIR}/client.js --${1} --type $2 -p $3 -t $4 $5 || RET=1
Randy Abernethy8e731372015-02-03 00:04:40 -080051 fi
52 kill -2 $SERVERPID || RET=1
James E. King, III699b5bc2017-09-14 08:07:08 -070053 wait $SERVERPID
Roger Meier8909cbd2014-01-26 11:44:27 +010054 return $RET
55}
56
Randy Abernethyd8187c52015-02-16 01:25:53 -080057
Roger Meier8909cbd2014-01-26 11:44:27 +010058TESTOK=0
59
60#generating thrift code
61
62${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node ${DIR}/../../../test/ThriftTest.thrift
Henrique Mendonça15d90422015-06-25 22:31:41 +100063${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node ${DIR}/../../../test/JsDeepConstructorTest.thrift
bforbisda1169d2018-10-28 11:27:38 -040064mkdir ${DIR}/gen-nodejs-es6
65${DIR}/../../../compiler/cpp/thrift -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${DIR}/../../../test/ThriftTest.thrift
66${DIR}/../../../compiler/cpp/thrift -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${DIR}/../../../test/JsDeepConstructorTest.thrift
Roger Meier8909cbd2014-01-26 11:44:27 +010067
68#unit tests
69
Randy Abernethyd8187c52015-02-16 01:25:53 -080070node ${DIR}/binary.test.js || TESTOK=1
Henrique Mendonça15d90422015-06-25 22:31:41 +100071node ${DIR}/deep-constructor.test.js || TESTOK=1
Roger Meier8909cbd2014-01-26 11:44:27 +010072
73#integration tests
74
Randy Abernethyd8187c52015-02-16 01:25:53 -080075for type in tcp multiplex websocket http
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080076do
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080077 for protocol in compact binary json
78 do
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080079 for transport in buffered framed
80 do
bforbisda1169d2018-10-28 11:27:38 -040081 for ecma_version in es5 es6
82 do
83 testServer $ecma_version $type $protocol $transport || TESTOK=1
84 testServer $ecma_version $type $protocol $transport --ssl || TESTOK=1
85 testServer $ecma_version $type $protocol $transport --callback || TESTOK=1
86 done
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080087 done
88 done
89done
Randy Abernethy2e091f62014-11-15 23:05:22 -080090
Randy Abernethyd8187c52015-02-16 01:25:53 -080091
Randy Abernethy8e731372015-02-03 00:04:40 -080092if [ -n "${COVER}" ]; then
Randy Abernethy8e731372015-02-03 00:04:40 -080093 ${ISTANBUL} report --dir "${DIR}/../coverage" --include "${DIR}/../coverage/report*/coverage.json" lcov cobertura html
94 rm -r ${DIR}/../coverage/report*/*
95 rmdir ${DIR}/../coverage/report*
96fi
97
Roger Meier8909cbd2014-01-26 11:44:27 +010098exit $TESTOK