Skip to content

Commit 95c8df1

Browse files
committed
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 <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
1 parent e6eb5c0 commit 95c8df1

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <node.h>
2+
#include <v8.h>
3+
4+
void Method(const v8::FunctionCallbackInfo<v8::Value>& args) {
5+
v8::Isolate* isolate = args.GetIsolate();
6+
v8::HandleScope scope(isolate);
7+
args.GetReturnValue().Set(node::ErrnoException(isolate,
8+
10,
9+
"syscall",
10+
"some error msg",
11+
"päth"));
12+
}
13+
14+
void init(v8::Local<v8::Object> exports) {
15+
NODE_SET_METHOD(exports, "errno", Method);
16+
}
17+
18+
NODE_MODULE(binding, init)
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
'targets': [
3+
{
4+
'target_name': 'binding',
5+
'defines': [ 'V8_DEPRECATION_WARNINGS=1' ],
6+
'sources': [ 'binding.cc' ]
7+
}
8+
]
9+
}

test/addons/errno-exception/test.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
const common = require('../../common');
4+
5+
// Verify that the path argument to node::ErrnoException() can contain UTF-8
6+
// characters.
7+
8+
const assert = require('assert');
9+
const binding = require(`./build/${common.buildType}/binding`);
10+
const err = binding.errno();
11+
12+
assert.strictEqual(err.syscall, 'syscall');
13+
assert.strictEqual(err.errno, 10);
14+
assert.strictEqual(err.path, 'päth');
15+
assert.ok(/^Error:\s\w+, some error msg 'päth'$/.test(err.toString()));

0 commit comments

Comments
 (0)