-
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: avoid copying test source files
Converting the helper functions to be inlined and making the helper file header only. PR-URL: #49515 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com>
- Loading branch information
1 parent
ae115d6
commit 178dff2
Showing
65 changed files
with
156 additions
and
148 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
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
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
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
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
{ | ||
"target_name": "3_callbacks", | ||
"sources": [ | ||
"../entry_point.c", | ||
"3_callbacks.c" | ||
] | ||
} | ||
|
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
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
{ | ||
"target_name": "4_object_factory", | ||
"sources": [ | ||
"../entry_point.c", | ||
"4_object_factory.c" | ||
] | ||
} | ||
|
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
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
{ | ||
"target_name": "5_function_factory", | ||
"sources": [ | ||
"../entry_point.c", | ||
"5_function_factory.c" | ||
] | ||
} | ||
|
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "../common.h" | ||
#include "../entry_point.h" | ||
#include "assert.h" | ||
#include "myobject.h" | ||
|
||
|
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
{ | ||
"target_name": "6_object_wrap", | ||
"sources": [ | ||
"../entry_point.c", | ||
"6_object_wrap.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
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
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
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
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,56 @@ | ||
#ifndef JS_NATIVE_API_COMMON_INL_H_ | ||
#define JS_NATIVE_API_COMMON_INL_H_ | ||
|
||
#include <js_native_api.h> | ||
#include "common.h" | ||
|
||
#include <stdio.h> | ||
|
||
inline void add_returned_status(napi_env env, | ||
const char* key, | ||
napi_value object, | ||
char* expected_message, | ||
napi_status expected_status, | ||
napi_status actual_status) { | ||
char napi_message_string[100] = ""; | ||
napi_value prop_value; | ||
|
||
if (actual_status != expected_status) { | ||
snprintf(napi_message_string, | ||
sizeof(napi_message_string), | ||
"Invalid status [%d]", | ||
actual_status); | ||
} | ||
|
||
NODE_API_CALL_RETURN_VOID( | ||
env, | ||
napi_create_string_utf8( | ||
env, | ||
(actual_status == expected_status ? expected_message | ||
: napi_message_string), | ||
NAPI_AUTO_LENGTH, | ||
&prop_value)); | ||
NODE_API_CALL_RETURN_VOID( | ||
env, napi_set_named_property(env, object, key, prop_value)); | ||
} | ||
|
||
inline void add_last_status(napi_env env, | ||
const char* key, | ||
napi_value return_value) { | ||
napi_value prop_value; | ||
const napi_extended_error_info* p_last_error; | ||
NODE_API_CALL_RETURN_VOID(env, napi_get_last_error_info(env, &p_last_error)); | ||
|
||
NODE_API_CALL_RETURN_VOID( | ||
env, | ||
napi_create_string_utf8( | ||
env, | ||
(p_last_error->error_message == NULL ? "napi_ok" | ||
: p_last_error->error_message), | ||
NAPI_AUTO_LENGTH, | ||
&prop_value)); | ||
NODE_API_CALL_RETURN_VOID( | ||
env, napi_set_named_property(env, return_value, key, prop_value)); | ||
} | ||
|
||
#endif // JS_NATIVE_API_COMMON_INL_H_ |
This file was deleted.
Oops, something went wrong.
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
5 changes: 5 additions & 0 deletions
5
test/js-native-api/entry_point.c → test/js-native-api/entry_point.h
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 |
---|---|---|
@@ -1,7 +1,12 @@ | ||
#ifndef JS_NATIVE_API_ENTRY_POINT_H_ | ||
#define JS_NATIVE_API_ENTRY_POINT_H_ | ||
|
||
#include <node_api.h> | ||
|
||
EXTERN_C_START | ||
napi_value Init(napi_env env, napi_value exports); | ||
EXTERN_C_END | ||
|
||
NAPI_MODULE(NODE_GYP_MODULE_NAME, Init) | ||
|
||
#endif // JS_NATIVE_API_ENTRY_POINT_H_ |
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
{ | ||
"target_name": "test_array", | ||
"sources": [ | ||
"../entry_point.c", | ||
"test_array.c" | ||
] | ||
} | ||
|
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
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
{ | ||
"target_name": "test_bigint", | ||
"sources": [ | ||
"../entry_point.c", | ||
"test_bigint.c" | ||
] | ||
} | ||
|
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
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 |
---|---|---|
@@ -1,32 +1,18 @@ | ||
{ | ||
"targets": [ | ||
{ | ||
"target_name": "copy_entry_point", | ||
"type": "none", | ||
"copies": [ | ||
{ | ||
"destination": ".", | ||
"files": [ "../entry_point.c" ] | ||
} | ||
] | ||
}, | ||
{ | ||
"target_name": "test_cannot_run_js", | ||
"sources": [ | ||
"entry_point.c", | ||
"test_cannot_run_js.c" | ||
], | ||
"defines": [ "NAPI_EXPERIMENTAL" ], | ||
"dependencies": [ "copy_entry_point" ], | ||
}, | ||
{ | ||
"target_name": "test_pending_exception", | ||
"sources": [ | ||
"entry_point.c", | ||
"test_cannot_run_js.c" | ||
], | ||
"defines": [ "NAPI_VERSION=8" ], | ||
"dependencies": [ "copy_entry_point" ], | ||
} | ||
] | ||
} |
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
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
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
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
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
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
{ | ||
"target_name": "test_dataview", | ||
"sources": [ | ||
"../entry_point.c", | ||
"test_dataview.c" | ||
] | ||
} | ||
|
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
Oops, something went wrong.