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
11 # http://www.apache.org/licenses/LICENSE-2.0
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
20 if [ -n "${1}" ]; then
24 DIR
="$( cd "$
( dirname "$0" )" && pwd )"
26 EPISODIC_DIR
=${DIR}/episodic-code-generation-test
28 THRIFT_FILES_DIR
=${DIR}/..
/..
/..
/test
30 THRIFT_COMPILER
=${DIR}/..
/..
/..
/compiler
/cpp
/thrift
32 ISTANBUL
="$DIR/../../../node_modules/istanbul/lib/cli.js"
34 REPORT_PREFIX
="${DIR}/../coverage/report"
38 export NODE_PATH
="${DIR}:${DIR}/../lib:${NODE_PATH}"
42 echo " [ECMA $1] Testing $2 Client/Server with protocol $3 and transport $4 $5";
44 if [ -n "${COVER}" ]; then
45 ${ISTANBUL} cover ${DIR}/server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint -- --type $2 -p $3 -t $4 $5 &
48 node
${DIR}/server.js
--${1} --type $2 -p $3 -t $4 $5 &
52 if [ -n "${COVER}" ]; then
53 ${ISTANBUL} cover ${DIR}/client.js --dir ${REPORT_PREFIX}${COUNT} -- --${1} --type $2 -p $3 -t $4 $5 || RET
=1
56 node
${DIR}/client.js
--${1} --type $2 -p $3 -t $4 $5 || RET
=1
58 kill -2 $SERVERPID || RET
=1
63 testEpisodicCompilation
()
66 if [ -n "${COVER}" ]; then
67 ${ISTANBUL} cover ${EPISODIC_DIR}/server.js --dir ${REPORT_PREFIX}${COUNT} --handle-sigint &
70 node
${EPISODIC_DIR}/server.js
&
74 if [ -n "${COVER}" ]; then
75 ${ISTANBUL} cover ${EPISODIC_DIR}/client.js --dir ${REPORT_PREFIX}${COUNT} || RET
=1
78 node
${EPISODIC_DIR}/client.js || RET
=1
80 kill -2 $SERVERPID || RET
=1
88 # generating Thrift code
90 ${THRIFT_COMPILER} -o ${DIR} --gen js:node ${THRIFT_FILES_DIR}/ThriftTest.thrift
91 ${THRIFT_COMPILER} -o ${DIR} --gen js:node ${THRIFT_FILES_DIR}/JsDeepConstructorTest.thrift
92 ${THRIFT_COMPILER} -o ${DIR} --gen js:node ${THRIFT_FILES_DIR}/Int64Test.thrift
93 mkdir
${DIR}/gen-nodejs-es6
94 ${THRIFT_COMPILER} -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${THRIFT_FILES_DIR}/ThriftTest.thrift
95 ${THRIFT_COMPILER} -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${THRIFT_FILES_DIR}/JsDeepConstructorTest.thrift
96 ${THRIFT_COMPILER} -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${THRIFT_FILES_DIR}/Int64Test.thrift
98 # generate episodic compilation test code
99 TYPES_PACKAGE
=${EPISODIC_DIR}/node_modules
/types-package
101 # generate the first episode
102 mkdir
--parents ${EPISODIC_DIR}/gen-
1/first-episode
103 ${THRIFT_COMPILER} -o ${EPISODIC_DIR}/gen-1/first-episode --gen js:node,thrift_package_output_directory=first-episode ${THRIFT_FILES_DIR}/Types.thrift
105 # create a "package" from the first episode and "install" it, the episode file must be at the module root
106 mkdir
--parents ${TYPES_PACKAGE}/first-episode
107 cp --force ${EPISODIC_DIR}/episodic_compilation.package.json
${TYPES_PACKAGE}/package.json
108 cp --force ${EPISODIC_DIR}/gen-
1/first-episode
/gen-nodejs
/Types_types.js
${TYPES_PACKAGE}/first-episode
/
109 cp --force ${EPISODIC_DIR}/gen-
1/first-episode
/gen-nodejs
/thrift.js.episode
${TYPES_PACKAGE}
111 # generate the second episode
112 mkdir
--parents ${EPISODIC_DIR}/gen-
2/second-episode
113 ${THRIFT_COMPILER} -o ${EPISODIC_DIR}/gen-2/second-episode --gen js:node,imports=${TYPES_PACKAGE} ${THRIFT_FILES_DIR}/Service.thrift
114 if [ -f ${EPISODIC_DIR}/gen-
2/second-episode
/Types_types.js
]; then
120 node
${DIR}/binary.
test.js || TESTOK
=1
121 node
${DIR}/int64.
test.js || TESTOK
=1
122 node
${DIR}/deep-constructor.
test.js || TESTOK
=1
126 for type in tcp multiplex websocket http
128 for protocol
in compact binary json
130 for transport
in buffered framed
132 for ecma_version
in es5 es6
134 testServer
$ecma_version $type $protocol $transport || TESTOK
=1
135 testServer
$ecma_version $type $protocol $transport --ssl || TESTOK
=1
136 testServer
$ecma_version $type $protocol $transport --callback || TESTOK
=1
142 # episodic compilation test
143 testEpisodicCompilation
145 if [ -n "${COVER}" ]; then
146 ${ISTANBUL} report --dir "${DIR}/../coverage" --include "${DIR}/..
/coverage
/report
*/coverage.json
" lcov cobertura html
147 rm -r ${DIR}/../coverage/report*/*
148 rmdir ${DIR}/../coverage/report*