blob: e98b198be25d1a408594950f4baf6f0535313baa [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
Mustafa Senol Cosarf86845e2018-12-05 17:50:18 +030064${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node ${DIR}/../../../test/Int64Test.thrift
bforbisda1169d2018-10-28 11:27:38 -040065mkdir ${DIR}/gen-nodejs-es6
66${DIR}/../../../compiler/cpp/thrift -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${DIR}/../../../test/ThriftTest.thrift
67${DIR}/../../../compiler/cpp/thrift -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${DIR}/../../../test/JsDeepConstructorTest.thrift
Mustafa Senol Cosarf86845e2018-12-05 17:50:18 +030068${DIR}/../../../compiler/cpp/thrift -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${DIR}/../../../test/Int64Test.thrift
Roger Meier8909cbd2014-01-26 11:44:27 +010069
70#unit tests
71
Randy Abernethyd8187c52015-02-16 01:25:53 -080072node ${DIR}/binary.test.js || TESTOK=1
Mustafa Senol Cosarf86845e2018-12-05 17:50:18 +030073node ${DIR}/int64.test.js || TESTOK=1
Henrique Mendonça15d90422015-06-25 22:31:41 +100074node ${DIR}/deep-constructor.test.js || TESTOK=1
Roger Meier8909cbd2014-01-26 11:44:27 +010075
76#integration tests
77
Randy Abernethyd8187c52015-02-16 01:25:53 -080078for type in tcp multiplex websocket http
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080079do
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080080 for protocol in compact binary json
81 do
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080082 for transport in buffered framed
83 do
bforbisda1169d2018-10-28 11:27:38 -040084 for ecma_version in es5 es6
85 do
86 testServer $ecma_version $type $protocol $transport || TESTOK=1
87 testServer $ecma_version $type $protocol $transport --ssl || TESTOK=1
88 testServer $ecma_version $type $protocol $transport --callback || TESTOK=1
89 done
Randy Abernethy3b9ff4d2015-02-16 00:51:24 -080090 done
91 done
92done
Randy Abernethy2e091f62014-11-15 23:05:22 -080093
Randy Abernethyd8187c52015-02-16 01:25:53 -080094
Randy Abernethy8e731372015-02-03 00:04:40 -080095if [ -n "${COVER}" ]; then
Randy Abernethy8e731372015-02-03 00:04:40 -080096 ${ISTANBUL} report --dir "${DIR}/../coverage" --include "${DIR}/../coverage/report*/coverage.json" lcov cobertura html
97 rm -r ${DIR}/../coverage/report*/*
98 rmdir ${DIR}/../coverage/report*
99fi
100
Roger Meier8909cbd2014-01-26 11:44:27 +0100101exit $TESTOK