Skip to content

Commit dfa4986

Browse files
vmorozmarco-ippolito
authored andcommitted
test,doc: enable running embedtest for Windows
PR-URL: #52646 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 5e76c25 commit dfa4986

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

doc/api/embedding.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ to as `node::Environment`. Each `node::Environment` is associated with:
9090
* A number of `v8::Context`s, but exactly one main `v8::Context`.
9191
* One `node::IsolateData` instance that contains information that could be
9292
shared by multiple `node::Environment`s that use the same `v8::Isolate`.
93-
Currently, no testing if performed for this scenario.
93+
Currently, no testing is performed for this scenario.
9494
9595
In order to set up a `v8::Isolate`, an `v8::ArrayBuffer::Allocator` needs
9696
to be provided. One possible choice is the default Node.js allocator, which

node.gyp

+1
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,7 @@
12341234

12351235
'include_dirs': [
12361236
'src',
1237+
'tools',
12371238
'tools/msvs/genfiles',
12381239
'deps/v8/include',
12391240
'deps/cares/include',

test/embedding/embedtest.cc

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifdef NDEBUG
22
#undef NDEBUG
33
#endif
4-
#include "node.h"
5-
#include "uv.h"
64
#include <assert.h>
5+
#include "executable_wrapper.h"
6+
#include "node.h"
77

88
#include <algorithm>
99

@@ -27,8 +27,10 @@ static int RunNodeInstance(MultiIsolatePlatform* platform,
2727
const std::vector<std::string>& args,
2828
const std::vector<std::string>& exec_args);
2929

30-
int main(int argc, char** argv) {
31-
argv = uv_setup_args(argc, argv);
30+
NODE_MAIN(int argc, node::argv_type raw_argv[]) {
31+
char** argv = nullptr;
32+
node::FixupMain(argc, raw_argv, &argv);
33+
3234
std::vector<std::string> args(argv, argv + argc);
3335
std::unique_ptr<node::InitializationResult> result =
3436
node::InitializeOncePerProcess(
@@ -106,7 +108,7 @@ int RunNodeInstance(MultiIsolatePlatform* platform,
106108
}
107109

108110
if (!snapshot_blob_path.empty() && !is_building_snapshot) {
109-
FILE* fp = fopen(snapshot_blob_path.c_str(), "r");
111+
FILE* fp = fopen(snapshot_blob_path.c_str(), "rb");
110112
assert(fp != nullptr);
111113
if (snapshot_as_file) {
112114
snapshot = node::EmbedderSnapshotData::FromFile(fp);
@@ -204,7 +206,7 @@ int RunNodeInstance(MultiIsolatePlatform* platform,
204206
snapshot = setup->CreateSnapshot();
205207
assert(snapshot);
206208

207-
FILE* fp = fopen(snapshot_blob_path.c_str(), "w");
209+
FILE* fp = fopen(snapshot_blob_path.c_str(), "wb");
208210
assert(fp != nullptr);
209211
if (snapshot_as_file) {
210212
snapshot->ToFile(fp);

vcbuild.bat

+4
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ if "%target%"=="Build" (
353353
if defined cctest set target="Build"
354354
)
355355
if "%target%"=="node" if exist "%config%\cctest.exe" del "%config%\cctest.exe"
356+
if "%target%"=="node" if exist "%config%\embedtest.exe" del "%config%\embedtest.exe"
356357
if defined msbuild_args set "extra_msbuild_args=%extra_msbuild_args% %msbuild_args%"
357358
@rem Setup env variables to use multiprocessor build
358359
set UseMultiToolTask=True
@@ -691,6 +692,9 @@ if not exist "%config%\cctest.exe" echo cctest.exe not found. Run "vcbuild test"
691692
echo running 'cctest %cctest_args%'
692693
"%config%\cctest" %cctest_args%
693694
if %errorlevel% neq 0 set exit_code=%errorlevel%
695+
echo running '%node_exe% test\embedding\test-embedding.js'
696+
"%node_exe%" test\embedding\test-embedding.js
697+
if %errorlevel% neq 0 set exit_code=%errorlevel%
694698
:run-test-py
695699
echo running 'python tools\test.py %test_args%'
696700
python tools\test.py %test_args%

0 commit comments

Comments
 (0)