diff --git a/package.json b/package.json index 9afba318162c1b5a9f5dff36e091fba534010a5d..a6081ba4850e837c4f2502fede5aba15362d1958 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "scripts": { "lint": "node ./node_modules/jshint/bin/jshint src/node/src src/node/test src/node/interop src/node/index.js --exclude-path=src/node/.jshintignore", "test": "./node_modules/.bin/mocha src/node/test && npm run-script lint", + "electron-build": "./node_modules/.bin/node-pre-gyp configure build --runtime=electron --disturl=https://atom.io/download/atom-shell", "gen_docs": "./node_modules/.bin/jsdoc -c src/node/jsdoc_conf.json", "coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha src/node/test", "install": "./node_modules/.bin/node-pre-gyp install --fallback-to-build" @@ -34,6 +35,7 @@ }, "devDependencies": { "async": "^1.5.0", + "electron-mocha": "^3.1.1", "google-auth-library": "^0.9.2", "google-protobuf": "^3.0.0", "istanbul": "^0.3.21", diff --git a/src/node/test/surface_test.js b/src/node/test/surface_test.js index d8b36dc55cbaa0ee4b4d11d405b0115104e3ad85..17c62d5635e13baac2554d770aaa43cd33eb6fee 100644 --- a/src/node/test/surface_test.js +++ b/src/node/test/surface_test.js @@ -183,6 +183,7 @@ describe('Server.prototype.addProtoService', function() { assert.strictEqual(status.code, grpc.status.UNIMPLEMENTED); done(); }); + call.on('error', function(status) { /* Do nothing */ }); }); it('should respond to a bidi call with UNIMPLEMENTED', function(done) { var call = client.divMany(); @@ -193,6 +194,7 @@ describe('Server.prototype.addProtoService', function() { assert.strictEqual(status.code, grpc.status.UNIMPLEMENTED); done(); }); + call.on('error', function(status) { /* Do nothing */ }); call.end(); }); }); diff --git a/templates/package.json.template b/templates/package.json.template index e9596d4d4cb2bb3296a1d3d28802515e38c3b543..b8ce92eb7ace2c8ac64519bf2f0abc51f33e2a48 100644 --- a/templates/package.json.template +++ b/templates/package.json.template @@ -23,6 +23,7 @@ "scripts": { "lint": "node ./node_modules/jshint/bin/jshint src/node/src src/node/test src/node/interop src/node/index.js --exclude-path=src/node/.jshintignore", "test": "./node_modules/.bin/mocha src/node/test && npm run-script lint", + "electron-build": "./node_modules/.bin/node-pre-gyp configure build --runtime=electron --disturl=https://atom.io/download/atom-shell", "gen_docs": "./node_modules/.bin/jsdoc -c src/node/jsdoc_conf.json", "coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha src/node/test", "install": "./node_modules/.bin/node-pre-gyp install --fallback-to-build" @@ -36,6 +37,7 @@ }, "devDependencies": { "async": "^1.5.0", + "electron-mocha": "^3.1.1", "google-auth-library": "^0.9.2", "google-protobuf": "^3.0.0", "istanbul": "^0.3.21", diff --git a/tools/run_tests/build_node_electron.sh b/tools/run_tests/build_node_electron.sh new file mode 100755 index 0000000000000000000000000000000000000000..4e7c3e4789a6c8b713b5b5f3fb2d89bf3adb7434 --- /dev/null +++ b/tools/run_tests/build_node_electron.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Copyright 2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +ELECTRON_VERSION=$1 +source ~/.nvm/nvm.sh + +nvm use 6 +set -ex + +# change to grpc repo root +cd $(dirname $0)/../.. + +export npm_config_target=$ELECTRON_VERSION +export npm_config_disturl=https://atom.io/download/atom-shell +export npm_config_runtime=electron +export npm_config_build_from_source=true +HOME=~/.electron-gyp npm install --unsafe-perm diff --git a/tools/run_tests/pre_build_node_electron.sh b/tools/run_tests/pre_build_node_electron.sh new file mode 100755 index 0000000000000000000000000000000000000000..d8d9df4ddbc61f0fac7229687f2d71d0934c6d64 --- /dev/null +++ b/tools/run_tests/pre_build_node_electron.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Copyright 2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +ELECTRON_VERSION=$1 + +nvm install 6 +set -ex + +npm install electron@$ELECTRON_VERSION diff --git a/tools/run_tests/run_node_electron.sh b/tools/run_tests/run_node_electron.sh new file mode 100755 index 0000000000000000000000000000000000000000..7f8a824df27d4487ea51a7eaaf8b2eb220f20e9a --- /dev/null +++ b/tools/run_tests/run_node_electron.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# Copyright 2015, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +source ~/.nvm/nvm.sh + +nvm use 6 +set -ex + +# change to grpc repo root +cd $(dirname $0)/../.. + +test_directory='src/node/test' +timeout=8000 + +JUNIT_REPORT_PATH=src/node/report.xml JUNIT_REPORT_STACK=1 \ + ./node_modules/.bin/electron-mocha --timeout $timeout \ + --reporter mocha-jenkins-reporter $test_directory diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index db261d98c29974660087fb4defd2626b6c0ea225..70da0cc0e327ea4a74222901196d22c8b6fba80f 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -362,19 +362,31 @@ class NodeLanguage(object): def configure(self, config, args): self.config = config self.args = args + # Note: electron ABI only depends on major and minor version, so that's all + # we should specify in the compiler argument _check_compiler(self.args.compiler, ['default', 'node0.12', - 'node4', 'node5', 'node6']) + 'node4', 'node5', 'node6', + 'electron1.3']) if self.args.compiler == 'default': self.node_version = '4' else: - # Take off the word "node" - self.node_version = self.args.compiler[4:] + if self.args.compiler.startswith('electron'): + self.runtime = 'electron' + self.node_version = self.args.compiler[8:] + else: + self.runtime = 'node' + # Take off the word "node" + self.node_version = self.args.compiler[4:] def test_specs(self): if self.platform == 'windows': return [self.config.job_spec(['tools\\run_tests\\run_node.bat'], None)] else: - return [self.config.job_spec(['tools/run_tests/run_node.sh', self.node_version], + run_script = 'run_node' + if self.runtime == 'electron': + run_script += '_electron' + return [self.config.job_spec(['tools/run_tests/{}.sh'.format(run_script), + self.node_version], None, environ=_FORCE_ENVIRON_FOR_WRAPPERS)] @@ -382,7 +394,10 @@ class NodeLanguage(object): if self.platform == 'windows': return [['tools\\run_tests\\pre_build_node.bat']] else: - return [['tools/run_tests/pre_build_node.sh', self.node_version]] + build_script = 'pre_build_node' + if self.runtime == 'electron': + build_script += '_electron' + return [['tools/run_tests/{}.sh'.format(build_script), self.node_version]] def make_targets(self): return [] @@ -394,7 +409,12 @@ class NodeLanguage(object): if self.platform == 'windows': return [['tools\\run_tests\\build_node.bat']] else: - return [['tools/run_tests/build_node.sh', self.node_version]] + build_script = 'build_node' + if self.runtime == 'electron': + build_script += '_electron' + # building for electron requires a patch version + self.node_version += '.0' + return [['tools/run_tests/{}.sh'.format(build_script), self.node_version]] def post_tests_steps(self): return [] @@ -1016,6 +1036,8 @@ argp.add_argument('--compiler', 'clang3.4', 'clang3.5', 'clang3.6', 'clang3.7', 'vs2010', 'vs2013', 'vs2015', 'python2.7', 'python3.4', 'python3.5', 'python3.6', 'pypy', 'pypy3', + 'node0.12', 'node4', 'node5', 'node6', + 'electron1.3', 'coreclr'], default='default', help='Selects compiler to use. Allowed values depend on the platform and language.')