-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. PR-URL: #13958 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <node.h> | ||
#include <v8.h> | ||
|
||
void Method(const v8::FunctionCallbackInfo<v8::Value>& 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<v8::Object> exports) { | ||
NODE_SET_METHOD(exports, "errno", Method); | ||
} | ||
|
||
NODE_MODULE(binding, init) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
'targets': [ | ||
{ | ||
'target_name': 'binding', | ||
'defines': [ 'V8_DEPRECATION_WARNINGS=1' ], | ||
'sources': [ 'binding.cc' ] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'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'); | ||
assert.ok(/^Error:\s\w+, some error msg 'päth'$/.test(err.toString())); |