Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 3 | # 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 Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 19 | |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 20 | if [ -n "${1}" ]; then |
| 21 | COVER=${1}; |
| 22 | fi |
| 23 | |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 24 | DIR="$( cd "$( dirname "$0" )" && pwd )" |
| 25 | |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 26 | ISTANBUL="$DIR/../../../node_modules/istanbul/lib/cli.js" |
Randy Abernethy | d8187c5 | 2015-02-16 01:25:53 -0800 | [diff] [blame] | 27 | RUNBROWSER="$DIR/../../../node_modules/run-browser/bin/cli.js" |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 28 | |
| 29 | REPORT_PREFIX="${DIR}/../coverage/report" |
| 30 | |
| 31 | COUNT=0 |
| 32 | |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 33 | export NODE_PATH="${DIR}:${DIR}/../lib:${NODE_PATH}" |
| 34 | |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 35 | testServer() |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 36 | { |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 37 | echo " Testing $1 Client/Server with protocol $2 and transport $3 $4"; |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 38 | RET=0 |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 39 | if [ -n "${COVER}" ]; then |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 40 | ${ISTANBUL} cover ${DIR}/server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- --type $1 -p $2 -t $3 $4 & |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 41 | COUNT=$((COUNT+1)) |
| 42 | else |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 43 | node ${DIR}/server.js --type $1 -p $2 -t $3 $4 & |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 44 | fi |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 45 | SERVERPID=$! |
| 46 | sleep 1 |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 47 | if [ -n "${COVER}" ]; then |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 48 | ${ISTANBUL} cover ${DIR}/client.js --dir ${REPORT_PREFIX}${COUNT} -- --type $1 -p $2 -t $3 $4 || RET=1 |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 49 | COUNT=$((COUNT+1)) |
| 50 | else |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 51 | node ${DIR}/client.js --type $1 -p $2 -t $3 $4 || RET=1 |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 52 | fi |
| 53 | kill -2 $SERVERPID || RET=1 |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 54 | return $RET |
| 55 | } |
| 56 | |
Randy Abernethy | d8187c5 | 2015-02-16 01:25:53 -0800 | [diff] [blame] | 57 | testBrowser() |
| 58 | { |
| 59 | echo " Testing browser client with http server with json protocol and buffered transport"; |
| 60 | RET=0 |
| 61 | node ${DIR}/server.js --type http -p json -t buffered & |
| 62 | SERVERPID=$! |
| 63 | sleep 1 |
| 64 | ${RUNBROWSER} ${DIR}/browser_client.js --phantom || RET=1 |
| 65 | kill -2 $SERVERPID || RET=1 |
| 66 | return $RET |
| 67 | } |
| 68 | |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 69 | TESTOK=0 |
| 70 | |
| 71 | #generating thrift code |
| 72 | |
| 73 | ${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node ${DIR}/../../../test/ThriftTest.thrift |
Henrique Mendonça | 15d9042 | 2015-06-25 22:31:41 +1000 | [diff] [blame^] | 74 | ${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node ${DIR}/../../../test/JsDeepConstructorTest.thrift |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 75 | |
| 76 | #unit tests |
| 77 | |
Randy Abernethy | d8187c5 | 2015-02-16 01:25:53 -0800 | [diff] [blame] | 78 | node ${DIR}/binary.test.js || TESTOK=1 |
Henrique Mendonça | 15d9042 | 2015-06-25 22:31:41 +1000 | [diff] [blame^] | 79 | node ${DIR}/deep-constructor.test.js || TESTOK=1 |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 80 | |
| 81 | #integration tests |
| 82 | |
Randy Abernethy | d8187c5 | 2015-02-16 01:25:53 -0800 | [diff] [blame] | 83 | for type in tcp multiplex websocket http |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 84 | do |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 85 | |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 86 | for protocol in compact binary json |
| 87 | do |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 88 | |
Randy Abernethy | 3b9ff4d | 2015-02-16 00:51:24 -0800 | [diff] [blame] | 89 | for transport in buffered framed |
| 90 | do |
| 91 | testServer $type $protocol $transport || TESTOK=1 |
| 92 | testServer $type $protocol $transport --ssl || TESTOK=1 |
| 93 | testServer $type $protocol $transport --promise || TESTOK=1 |
| 94 | done |
| 95 | done |
| 96 | done |
Randy Abernethy | 2e091f6 | 2014-11-15 23:05:22 -0800 | [diff] [blame] | 97 | |
Randy Abernethy | d8187c5 | 2015-02-16 01:25:53 -0800 | [diff] [blame] | 98 | # XHR only until phantomjs 2 is released. |
| 99 | testBrowser |
| 100 | |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 101 | if [ -n "${COVER}" ]; then |
Randy Abernethy | 8e73137 | 2015-02-03 00:04:40 -0800 | [diff] [blame] | 102 | ${ISTANBUL} report --dir "${DIR}/../coverage" --include "${DIR}/../coverage/report*/coverage.json" lcov cobertura html |
| 103 | rm -r ${DIR}/../coverage/report*/* |
| 104 | rmdir ${DIR}/../coverage/report* |
| 105 | fi |
| 106 | |
Roger Meier | 8909cbd | 2014-01-26 11:44:27 +0100 | [diff] [blame] | 107 | exit $TESTOK |