Merge branch 'master' into node_electron_build
diff --git a/binding.gyp b/binding.gyp
index 516cbdc..9849401 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -37,18 +37,64 @@
# Some of this file is built with the help of
# https://n8.io/converting-a-c-library-to-gyp/
{
+ 'variables': {
+ 'runtime%': 'node'
+ },
'target_defaults': {
'include_dirs': [
'.',
'include'
],
'defines': [
- 'GRPC_UV'
+ 'GPR_BACKWARDS_COMPATIBILITY_MODE'
],
'conditions': [
+ ['runtime=="node"', {
+ 'defines': [
+ 'GRPC_UV'
+ ]
+ }],
+ # This is the condition for using boringssl
+ ['OS=="win" or runtime=="electron"', {
+ "include_dirs": [
+ "third_party/boringssl/include"
+ ],
+ "defines": [
+ 'OPENSSL_NO_ASM',
+ 'OPENSSL_NO_THREADS'
+ ]
+ }, {
+ # Based on logic above, we know that this must be a non-Windows system
+ 'variables': {
+ # The output of "node --version" is "v[version]". We use cut to
+ # remove the first character.
+ 'target%': '<!(node --version | cut -c2-)'
+ },
+ # Empirically, Node only exports ALPN symbols if its major version is >0.
+ # io.js always reports versions >0 and always exports ALPN symbols.
+ # Therefore, Node's major version will be truthy if and only if it
+ # supports ALPN. The target is "[major].[minor].[patch]". We split by
+ # periods and take the first field to get the major version.
+ 'defines': [
+ 'TSI_OPENSSL_ALPN_SUPPORT=<!(echo <(target) | cut -d. -f1)'
+ ],
+ 'include_dirs': [
+ '<(node_root_dir)/deps/openssl/openssl/include',
+ ],
+ 'conditions': [
+ ["target_arch=='ia32'", {
+ "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
+ }],
+ ["target_arch=='x64'", {
+ "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
+ }],
+ ["target_arch=='arm'", {
+ "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
+ }]
+ ]
+ }],
['OS == "win"', {
"include_dirs": [
- "third_party/boringssl/include",
"third_party/zlib"
],
"defines": [
@@ -58,8 +104,6 @@
'UNICODE',
'_UNICODE',
'NOMINMAX',
- 'OPENSSL_NO_ASM',
- 'GPR_BACKWARDS_COMPATIBILITY_MODE'
],
"msvs_settings": {
'VCCLCompilerTool': {
@@ -72,21 +116,8 @@
}, { # OS != "win"
'variables': {
'config': '<!(echo $CONFIG)',
- # The output of "node --version" is "v[version]". We use cut to
- # remove the first character.
- 'target%': '<!(node --version | cut -c2-)'
},
- # Empirically, Node only exports ALPN symbols if its major version is >0.
- # io.js always reports versions >0 and always exports ALPN symbols.
- # Therefore, Node's major version will be truthy if and only if it
- # supports ALPN. The target is "[major].[minor].[patch]". We split by
- # periods and take the first field to get the major version.
- 'defines': [
- 'TSI_OPENSSL_ALPN_SUPPORT=<!(echo <(target) | cut -d. -f1)',
- 'GPR_BACKWARDS_COMPATIBILITY_MODE'
- ],
'include_dirs': [
- '<(node_root_dir)/deps/openssl/openssl/include',
'<(node_root_dir)/deps/zlib'
],
'conditions': [
@@ -101,48 +132,15 @@
'-fprofile-arcs'
]
}
- ],
- ["target_arch=='ia32'", {
- "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
- }],
- ["target_arch=='x64'", {
- "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
- }],
- ["target_arch=='arm'", {
- "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
- }]
+ ]
]
}]
]
},
'conditions': [
- ['OS == "win"', {
+ ['OS=="win" or runtime=="electron"', {
'targets': [
{
- # IMPORTANT WINDOWS BUILD INFORMATION
- # This library does not build on Windows without modifying the Node
- # development packages that node-gyp downloads in order to build.
- # Due to https://github.com/nodejs/node/issues/4932, the headers for
- # BoringSSL conflict with the OpenSSL headers included by default
- # when including the Node headers. The remedy for this is to remove
- # the OpenSSL headers, from the downloaded Node development package,
- # which is typically located in `.node-gyp` in your home directory.
- 'target_name': 'WINDOWS_BUILD_WARNING',
- 'actions': [
- {
- 'action_name': 'WINDOWS_BUILD_WARNING',
- 'inputs': [
- 'package.json'
- ],
- 'outputs': [
- 'ignore_this_part'
- ],
- 'action': ['echo', 'IMPORTANT: Due to https://github.com/nodejs/node/issues/4932, to build this library on Windows, you must first remove <(node_root_dir)/include/node/openssl/']
- }
- ]
- },
- # Only want to compile BoringSSL and zlib under Windows
- {
'cflags': [
'-std=c99',
'-Wall',
@@ -453,6 +451,34 @@
'third_party/boringssl/ssl/tls_record.c',
]
},
+ ]
+ }],
+ ['OS == "win"', {
+ 'targets': [
+ {
+ # IMPORTANT WINDOWS BUILD INFORMATION
+ # This library does not build on Windows without modifying the Node
+ # development packages that node-gyp downloads in order to build.
+ # Due to https://github.com/nodejs/node/issues/4932, the headers for
+ # BoringSSL conflict with the OpenSSL headers included by default
+ # when including the Node headers. The remedy for this is to remove
+ # the OpenSSL headers, from the downloaded Node development package,
+ # which is typically located in `.node-gyp` in your home directory.
+ 'target_name': 'WINDOWS_BUILD_WARNING',
+ 'actions': [
+ {
+ 'action_name': 'WINDOWS_BUILD_WARNING',
+ 'inputs': [
+ 'package.json'
+ ],
+ 'outputs': [
+ 'ignore_this_part'
+ ],
+ 'action': ['echo', 'IMPORTANT: Due to https://github.com/nodejs/node/issues/4932, to build this library on Windows, you must first remove <(node_root_dir)/include/node/openssl/']
+ }
+ ]
+ },
+ # Only want to compile zlib under Windows
{
'cflags': [
'-std=c99',
@@ -805,6 +831,11 @@
'-g'
],
"conditions": [
+ ['OS=="win" or runtime=="electron"', {
+ 'dependencies': [
+ "boringssl",
+ ]
+ }],
['OS=="mac"', {
'xcode_settings': {
'MACOSX_DEPLOYMENT_TARGET': '10.9',
@@ -816,7 +847,6 @@
}],
['OS=="win"', {
'dependencies': [
- "boringssl",
"z",
]
}],
@@ -833,8 +863,8 @@
"src/node/ext/call_credentials.cc",
"src/node/ext/channel.cc",
"src/node/ext/channel_credentials.cc",
- "src/node/ext/completion_queue.cc",
- "src/node/ext/completion_queue_async_worker.cc",
+ "src/node/ext/completion_queue_threadpool.cc",
+ "src/node/ext/completion_queue_uv.cc",
"src/node/ext/node_grpc.cc",
"src/node/ext/server.cc",
"src/node/ext/server_credentials.cc",
diff --git a/build.yaml b/build.yaml
index de9d253..330f5ed 100644
--- a/build.yaml
+++ b/build.yaml
@@ -3812,7 +3812,6 @@
- src/node/ext/channel.h
- src/node/ext/channel_credentials.h
- src/node/ext/completion_queue.h
- - src/node/ext/completion_queue_async_worker.h
- src/node/ext/server.h
- src/node/ext/server_credentials.h
- src/node/ext/timeval.h
@@ -3831,8 +3830,8 @@
- src/node/ext/call_credentials.cc
- src/node/ext/channel.cc
- src/node/ext/channel_credentials.cc
- - src/node/ext/completion_queue.cc
- - src/node/ext/completion_queue_async_worker.cc
+ - src/node/ext/completion_queue_threadpool.cc
+ - src/node/ext/completion_queue_uv.cc
- src/node/ext/node_grpc.cc
- src/node/ext/server.cc
- src/node/ext/server_credentials.cc
diff --git a/package.json b/package.json
index 5506e9b..8567844 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"
@@ -38,6 +39,7 @@
"devDependencies": {
"async": "^2.0.1",
"body-parser": "^1.15.2",
+ "electron-mocha": "^3.1.1",
"express": "^4.14.0",
"google-auth-library": "^0.9.2",
"google-protobuf": "^3.0.0",
diff --git a/src/node/ext/completion_queue.h b/src/node/ext/completion_queue.h
index bf280f7..9b01028 100644
--- a/src/node/ext/completion_queue.h
+++ b/src/node/ext/completion_queue.h
@@ -32,6 +32,7 @@
*/
#include <v8.h>
+#include <grpc/grpc.h>
namespace grpc {
namespace node {
diff --git a/src/node/ext/completion_queue_async_worker.cc b/src/node/ext/completion_queue_threadpool.cc
similarity index 72%
rename from src/node/ext/completion_queue_async_worker.cc
rename to src/node/ext/completion_queue_threadpool.cc
index f5e03b2..6302e7a 100644
--- a/src/node/ext/completion_queue_async_worker.cc
+++ b/src/node/ext/completion_queue_threadpool.cc
@@ -31,18 +31,63 @@
*
*/
+/* I don't like using #ifndef, but I don't see a better way to do this */
+#ifndef GRPC_UV
+
#include <node.h>
#include <nan.h>
#include "grpc/grpc.h"
#include "grpc/support/log.h"
#include "grpc/support/time.h"
-#include "completion_queue_async_worker.h"
+#include "completion_queue.h"
#include "call.h"
namespace grpc {
namespace node {
+namespace {
+
+/* A worker that asynchronously calls completion_queue_next, and queues onto the
+ node event loop a call to the function stored in the event's tag. */
+class CompletionQueueAsyncWorker : public Nan::AsyncWorker {
+ public:
+ CompletionQueueAsyncWorker();
+
+ ~CompletionQueueAsyncWorker();
+ /* Calls completion_queue_next with the provided deadline, and stores the
+ event if there was one or sets an error message if there was not */
+ void Execute();
+
+ /* Returns the completion queue attached to this class */
+ static grpc_completion_queue *GetQueue();
+
+ /* Convenience function to create a worker with the given arguments and queue
+ it to run asynchronously */
+ static void Next();
+
+ /* Initialize the CompletionQueueAsyncWorker class */
+ static void Init(v8::Local<v8::Object> exports);
+
+ protected:
+ /* Called when Execute has succeeded (completed without setting an error
+ message). Calls the saved callback with the event that came from
+ completion_queue_next */
+ void HandleOKCallback();
+
+ void HandleErrorCallback();
+
+ private:
+ grpc_event result;
+
+ static grpc_completion_queue *queue;
+
+ // Number of grpc_completion_queue_next calls in the thread pool
+ static int current_threads;
+ // Number of grpc_completion_queue_next calls waiting to enter the thread pool
+ static int waiting_next_calls;
+};
+
const int max_queue_threads = 2;
using v8::Function;
@@ -137,5 +182,21 @@
DestroyTag(result.tag);
}
+} // namespace
+
+grpc_completion_queue *GetCompletionQueue() {
+ return CompletionQueueAsyncWorker::GetQueue();
+}
+
+void CompletionQueueNext() {
+ CompletionQueueAsyncWorker::Next();
+}
+
+void CompletionQueueInit(Local<Object> exports) {
+ CompletionQueueAsyncWorker::Init(exports);
+}
+
} // namespace node
} // namespace grpc
+
+#endif /* GRPC_UV */
diff --git a/src/node/ext/completion_queue.cc b/src/node/ext/completion_queue_uv.cc
similarity index 92%
rename from src/node/ext/completion_queue.cc
rename to src/node/ext/completion_queue_uv.cc
index fcfa77b..615973a 100644
--- a/src/node/ext/completion_queue.cc
+++ b/src/node/ext/completion_queue_uv.cc
@@ -31,6 +31,8 @@
*
*/
+#ifdef GRPC_UV
+
#include <uv.h>
#include <node.h>
#include <v8.h>
@@ -38,7 +40,6 @@
#include "call.h"
#include "completion_queue.h"
-#include "completion_queue_async_worker.h"
namespace grpc {
namespace node {
@@ -81,34 +82,24 @@
}
grpc_completion_queue *GetCompletionQueue() {
-#ifdef GRPC_UV
return queue;
-#else
- return CompletionQueueAsyncWorker::GetQueue();
-#endif
}
void CompletionQueueNext() {
-#ifdef GRPC_UV
if (pending_batches == 0) {
GPR_ASSERT(!uv_is_active((uv_handle_t *)&prepare));
uv_prepare_start(&prepare, drain_completion_queue);
}
pending_batches++;
-#else
- CompletionQueueAsyncWorker::Next();
-#endif
}
void CompletionQueueInit(Local<Object> exports) {
-#ifdef GRPC_UV
queue = grpc_completion_queue_create(NULL);
uv_prepare_init(uv_default_loop(), &prepare);
pending_batches = 0;
-#else
- CompletionQueueAsyncWorker::Init(exports);
-#endif
}
} // namespace node
} // namespace grpc
+
+#endif /* GRPC_UV */
diff --git a/src/node/test/surface_test.js b/src/node/test/surface_test.js
index 2a42dd5..e429a36 100644
--- a/src/node/test/surface_test.js
+++ b/src/node/test/surface_test.js
@@ -183,6 +183,7 @@
assert.strictEqual(err.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 @@
assert.strictEqual(err.code, grpc.status.UNIMPLEMENTED);
done();
});
+ call.on('error', function(status) { /* Do nothing */ });
call.end();
});
});
diff --git a/templates/binding.gyp.template b/templates/binding.gyp.template
index e6592ac..9b9e4e1 100644
--- a/templates/binding.gyp.template
+++ b/templates/binding.gyp.template
@@ -39,18 +39,64 @@
# Some of this file is built with the help of
# https://n8.io/converting-a-c-library-to-gyp/
{
+ 'variables': {
+ 'runtime%': 'node'
+ },
'target_defaults': {
'include_dirs': [
'.',
'include'
],
'defines': [
- 'GRPC_UV'
+ 'GPR_BACKWARDS_COMPATIBILITY_MODE'
],
'conditions': [
+ ['runtime=="node"', {
+ 'defines': [
+ 'GRPC_UV'
+ ]
+ }],
+ # This is the condition for using boringssl
+ ['OS=="win" or runtime=="electron"', {
+ "include_dirs": [
+ "third_party/boringssl/include"
+ ],
+ "defines": [
+ 'OPENSSL_NO_ASM',
+ 'OPENSSL_NO_THREADS'
+ ]
+ }, {
+ # Based on logic above, we know that this must be a non-Windows system
+ 'variables': {
+ # The output of "node --version" is "v[version]". We use cut to
+ # remove the first character.
+ 'target%': '<!(node --version | cut -c2-)'
+ },
+ # Empirically, Node only exports ALPN symbols if its major version is >0.
+ # io.js always reports versions >0 and always exports ALPN symbols.
+ # Therefore, Node's major version will be truthy if and only if it
+ # supports ALPN. The target is "[major].[minor].[patch]". We split by
+ # periods and take the first field to get the major version.
+ 'defines': [
+ 'TSI_OPENSSL_ALPN_SUPPORT=<!(echo <(target) | cut -d. -f1)'
+ ],
+ 'include_dirs': [
+ '<(node_root_dir)/deps/openssl/openssl/include',
+ ],
+ 'conditions': [
+ ["target_arch=='ia32'", {
+ "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
+ }],
+ ["target_arch=='x64'", {
+ "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
+ }],
+ ["target_arch=='arm'", {
+ "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
+ }]
+ ]
+ }],
['OS == "win"', {
"include_dirs": [
- "third_party/boringssl/include",
"third_party/zlib"
],
"defines": [
@@ -60,8 +106,6 @@
'UNICODE',
'_UNICODE',
'NOMINMAX',
- 'OPENSSL_NO_ASM',
- 'GPR_BACKWARDS_COMPATIBILITY_MODE'
],
"msvs_settings": {
'VCCLCompilerTool': {
@@ -74,21 +118,8 @@
}, { # OS != "win"
'variables': {
'config': '<!(echo $CONFIG)',
- # The output of "node --version" is "v[version]". We use cut to
- # remove the first character.
- 'target%': '<!(node --version | cut -c2-)'
},
- # Empirically, Node only exports ALPN symbols if its major version is >0.
- # io.js always reports versions >0 and always exports ALPN symbols.
- # Therefore, Node's major version will be truthy if and only if it
- # supports ALPN. The target is "[major].[minor].[patch]". We split by
- # periods and take the first field to get the major version.
- 'defines': [
- 'TSI_OPENSSL_ALPN_SUPPORT=<!(echo <(target) | cut -d. -f1)',
- 'GPR_BACKWARDS_COMPATIBILITY_MODE'
- ],
'include_dirs': [
- '<(node_root_dir)/deps/openssl/openssl/include',
'<(node_root_dir)/deps/zlib'
],
'conditions': [
@@ -103,21 +134,42 @@
'-fprofile-arcs'
]
}
- ],
- ["target_arch=='ia32'", {
- "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
- }],
- ["target_arch=='x64'", {
- "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
- }],
- ["target_arch=='arm'", {
- "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
- }]
+ ]
]
}]
]
},
'conditions': [
+ ['OS=="win" or runtime=="electron"', {
+ 'targets': [
+ % for module in node_modules:
+ % for lib in libs:
+ % if lib.name in module.transitive_deps and lib.name == 'boringssl':
+ {
+ 'cflags': [
+ '-std=c99',
+ '-Wall',
+ '-Werror'
+ ],
+ 'target_name': '${lib.name}',
+ 'product_prefix': 'lib',
+ 'type': 'static_library',
+ 'dependencies': [
+ % for dep in getattr(lib, 'deps', []):
+ '${dep}',
+ % endfor
+ ],
+ 'sources': [
+ % for source in lib.src:
+ '${source}',
+ % endfor
+ ]
+ },
+ % endif
+ % endfor
+ % endfor
+ ]
+ }],
['OS == "win"', {
'targets': [
{
@@ -143,10 +195,10 @@
}
]
},
- # Only want to compile BoringSSL and zlib under Windows
+ # Only want to compile zlib under Windows
% for module in node_modules:
% for lib in libs:
- % if lib.name in module.transitive_deps and lib.name in ('boringssl', 'z'):
+ % if lib.name in module.transitive_deps and lib.name == 'z':
{
'cflags': [
'-std=c99',
@@ -223,6 +275,15 @@
'-g'
],
"conditions": [
+ ['OS=="win" or runtime=="electron"', {
+ 'dependencies': [
+ % for dep in getattr(module, 'deps', []):
+ % if dep == 'boringssl':
+ "${dep}",
+ % endif
+ % endfor
+ ]
+ }],
['OS=="mac"', {
'xcode_settings': {
'MACOSX_DEPLOYMENT_TARGET': '10.9',
@@ -235,7 +296,7 @@
['OS=="win"', {
'dependencies': [
% for dep in getattr(module, 'deps', []):
- % if dep in ('boringssl', 'z'):
+ % if dep == 'z':
"${dep}",
% endif
% endfor
diff --git a/templates/package.json.template b/templates/package.json.template
index 81f39d2..a4eb620 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"
@@ -40,6 +41,7 @@
"devDependencies": {
"async": "^2.0.1",
"body-parser": "^1.15.2",
+ "electron-mocha": "^3.1.1",
"express": "^4.14.0",
"google-auth-library": "^0.9.2",
"google-protobuf": "^3.0.0",
diff --git a/tools/dockerfile/test/node_jessie_x64/Dockerfile b/tools/dockerfile/test/node_jessie_x64/Dockerfile
index d9a7501..120ea59 100644
--- a/tools/dockerfile/test/node_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/node_jessie_x64/Dockerfile
@@ -42,12 +42,18 @@
git \
golang \
gyp \
+ libasound2 \
lcov \
libc6 \
libc6-dbg \
libc6-dev \
+ libgconf-2-4 \
libgtest-dev \
+ libgtk2.0-0 \
+ libnss3 \
libtool \
+ libxss1\
+ libxtst6 \
make \
perl \
strace \
@@ -57,6 +63,7 @@
telnet \
unzip \
wget \
+ xvfb \
zip && apt-get clean
#================
diff --git a/tools/run_tests/artifacts/build_artifact_node.bat b/tools/run_tests/artifacts/build_artifact_node.bat
index 2e0ecd2..7439b76 100644
--- a/tools/run_tests/artifacts/build_artifact_node.bat
+++ b/tools/run_tests/artifacts/build_artifact_node.bat
@@ -29,6 +29,8 @@
set node_versions=0.12.0 1.0.0 1.1.0 2.0.0 3.0.0 4.0.0 5.0.0 6.0.0 7.0.0
+set electron_versions=1.0.0 1.1.0 1.2.0 1.3.0 1.4.0
+
set PATH=%PATH%;C:\Program Files\nodejs\;%APPDATA%\npm
del /f /q BUILD || rmdir build /s /q
@@ -47,6 +49,12 @@
xcopy /Y /I /S build\stage\* artifacts\ || goto :error
)
+
+for %%v in (%electron_versions%) do (
+ call .\node_modules\.bin\node-pre-gyp.cmd configure rebuild package testpackage --runtime=electron --target=%%v --target_arch=%1 || goto :error
+
+ xcopy /Y /I /S build\stage\* artifacts\ || goto :error
+)
if %errorlevel% neq 0 exit /b %errorlevel%
goto :EOF
diff --git a/tools/run_tests/artifacts/build_artifact_node.sh b/tools/run_tests/artifacts/build_artifact_node.sh
index 1066ebd..02497a4 100755
--- a/tools/run_tests/artifacts/build_artifact_node.sh
+++ b/tools/run_tests/artifacts/build_artifact_node.sh
@@ -44,8 +44,16 @@
node_versions=( 0.12.0 1.0.0 1.1.0 2.0.0 3.0.0 4.0.0 5.0.0 6.0.0 7.0.0 )
+electron_versions=( 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 )
+
for version in ${node_versions[@]}
do
./node_modules/.bin/node-pre-gyp configure rebuild package testpackage --target=$version --target_arch=$NODE_TARGET_ARCH
cp -r build/stage/* artifacts/
done
+
+for version in ${node_versions[@]}
+do
+ HOME=~/.electron-gyp ./node_modules/.bin/node-pre-gyp configure rebuild package testpackage --runtime=electron --target=$version --target_arch=$NODE_TARGET_ARCH
+ cp -r build/stage/* artifacts/
+done
diff --git a/tools/run_tests/helper_scripts/build_node_electron.sh b/tools/run_tests/helper_scripts/build_node_electron.sh
new file mode 100755
index 0000000..1c95c51
--- /dev/null
+++ b/tools/run_tests/helper_scripts/build_node_electron.sh
@@ -0,0 +1,46 @@
+#!/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
+mkdir -p ~/.electron-gyp
+HOME=~/.electron-gyp npm install --unsafe-perm
diff --git a/tools/run_tests/helper_scripts/pre_build_node_electron.sh b/tools/run_tests/helper_scripts/pre_build_node_electron.sh
new file mode 100755
index 0000000..95c56aa
--- /dev/null
+++ b/tools/run_tests/helper_scripts/pre_build_node_electron.sh
@@ -0,0 +1,39 @@
+#!/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 xvfb-maybe
+
+npm install electron@$ELECTRON_VERSION
diff --git a/tools/run_tests/helper_scripts/run_node_electron.sh b/tools/run_tests/helper_scripts/run_node_electron.sh
new file mode 100755
index 0000000..1999ffb
--- /dev/null
+++ b/tools/run_tests/helper_scripts/run_node_electron.sh
@@ -0,0 +1,45 @@
+#!/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/xvfb-maybe \
+ ./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 9242741..ab719a6 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -371,27 +371,42 @@
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',
- 'node7'])
+ 'node7', '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\\helper_scripts\\run_node.bat'])]
else:
- return [self.config.job_spec(['tools/run_tests/helper_scripts/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/helper_scripts/{}.sh'.format(run_script),
+ self.node_version],
+ None,
environ=_FORCE_ENVIRON_FOR_WRAPPERS)]
def pre_build_steps(self):
if self.platform == 'windows':
return [['tools\\run_tests\\helper_scripts\\pre_build_node.bat']]
else:
- return [['tools/run_tests/helper_scripts/pre_build_node.sh', self.node_version]]
+ build_script = 'pre_build_node'
+ if self.runtime == 'electron':
+ build_script += '_electron'
+ return [['tools/run_tests/helper_scripts/{}.sh'.format(build_script), self.node_version]]
def make_targets(self):
return []
@@ -403,7 +418,12 @@
if self.platform == 'windows':
return [['tools\\run_tests\\helper_scripts\\build_node.bat']]
else:
- return [['tools/run_tests/helper_scripts/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/helper_scripts/{}.sh'.format(build_script), self.node_version]]
def post_tests_steps(self):
return []
@@ -1076,6 +1096,7 @@
'vs2010', 'vs2013', 'vs2015',
'python2.7', 'python3.4', 'python3.5', 'python3.6', 'pypy', 'pypy3',
'node0.12', 'node4', 'node5', 'node6', 'node7',
+ 'electron1.3',
'coreclr'],
default='default',
help='Selects compiler to use. Allowed values depend on the platform and language.')
diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py
index 6e83180..8f70a6d 100755
--- a/tools/run_tests/run_tests_matrix.py
+++ b/tools/run_tests/run_tests_matrix.py
@@ -231,6 +231,15 @@
labels=['portability'],
extra_args=extra_args,
inner_jobs=inner_jobs)
+
+ test_jobs += _generate_jobs(languages=['node'],
+ configs=['dbg'],
+ platforms=['linux'],
+ arch='default',
+ compiler='electron1.3',
+ labels=['portability'],
+ extra_args=extra_args,
+ inner_jobs=inner_jobs)
return test_jobs