From b5f2c5109adddb90ada2159f8bc6a428a186b4dc Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 30 Jun 2017 09:25:00 +0200 Subject: [PATCH 1/2] test: add test to verify ErrnoException path This commit adds a test to verify that the path argument to ErrnoException can contain UTF-8 characters. --- test/addons/errno-exception/binding.cc | 18 ++++++++++++++++++ test/addons/errno-exception/binding.gyp | 9 +++++++++ test/addons/errno-exception/test.js | 9 +++++++++ 3 files changed, 36 insertions(+) create mode 100644 test/addons/errno-exception/binding.cc create mode 100644 test/addons/errno-exception/binding.gyp create mode 100644 test/addons/errno-exception/test.js diff --git a/test/addons/errno-exception/binding.cc b/test/addons/errno-exception/binding.cc new file mode 100644 index 00000000000000..1c3147ff7a2172 --- /dev/null +++ b/test/addons/errno-exception/binding.cc @@ -0,0 +1,18 @@ +#include +#include + +void Method(const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = args.GetIsolate(); + v8::HandleScope scope(isolate); + args.GetReturnValue().Set(node::ErrnoException(isolate, + 10, + "syscall", + "some error msg", + "päth")); +} + +void init(v8::Local exports) { + NODE_SET_METHOD(exports, "errno", Method); +} + +NODE_MODULE(binding, init) diff --git a/test/addons/errno-exception/binding.gyp b/test/addons/errno-exception/binding.gyp new file mode 100644 index 00000000000000..7ede63d94a0d77 --- /dev/null +++ b/test/addons/errno-exception/binding.gyp @@ -0,0 +1,9 @@ +{ + 'targets': [ + { + 'target_name': 'binding', + 'defines': [ 'V8_DEPRECATION_WARNINGS=1' ], + 'sources': [ 'binding.cc' ] + } + ] +} diff --git a/test/addons/errno-exception/test.js b/test/addons/errno-exception/test.js new file mode 100644 index 00000000000000..7a8e61b2dbcf0d --- /dev/null +++ b/test/addons/errno-exception/test.js @@ -0,0 +1,9 @@ +'use strict'; +const common = require('../../common'); +const assert = require('assert'); +const binding = require(`./build/${common.buildType}/binding`); +const err = binding.errno(); +assert.strictEqual(err.syscall, 'syscall'); +assert.strictEqual(err.errno, 10); +assert.strictEqual(err.path, 'päth'); +assert.ok(/^Error:\s\w+, some error msg 'päth'$/.test(err.toString())); From 32a3027a9f8cb55ebce893755c7251d5a5a7f20e Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Sun, 13 Aug 2017 08:51:39 +0200 Subject: [PATCH 2/2] squash: make test.js follow test style guidelines --- test/addons/errno-exception/test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/addons/errno-exception/test.js b/test/addons/errno-exception/test.js index 7a8e61b2dbcf0d..ddc13b7ce57ae2 100644 --- a/test/addons/errno-exception/test.js +++ b/test/addons/errno-exception/test.js @@ -1,8 +1,14 @@ 'use strict'; + const common = require('../../common'); + +// Verify that the path argument to node::ErrnoException() can contain UTF-8 +// characters. + const assert = require('assert'); const binding = require(`./build/${common.buildType}/binding`); const err = binding.errno(); + assert.strictEqual(err.syscall, 'syscall'); assert.strictEqual(err.errno, 10); assert.strictEqual(err.path, 'päth');