Skip to content

Commit

Permalink
test,doc: enable running embedtest for Windows
Browse files Browse the repository at this point in the history
PR-URL: #52646
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
vmoroz authored and targos committed Jun 1, 2024
1 parent 838fe59 commit c61f909
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion doc/api/embedding.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ to as `node::Environment`. Each `node::Environment` is associated with:
* A number of `v8::Context`s, but exactly one main `v8::Context`.
* One `node::IsolateData` instance that contains information that could be
shared by multiple `node::Environment`s that use the same `v8::Isolate`.
Currently, no testing if performed for this scenario.
Currently, no testing is performed for this scenario.
In order to set up a `v8::Isolate`, an `v8::ArrayBuffer::Allocator` needs
to be provided. One possible choice is the default Node.js allocator, which
Expand Down
1 change: 1 addition & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,7 @@

'include_dirs': [
'src',
'tools',
'tools/msvs/genfiles',
'deps/v8/include',
'deps/cares/include',
Expand Down
14 changes: 8 additions & 6 deletions test/embedding/embedtest.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifdef NDEBUG
#undef NDEBUG
#endif
#include "node.h"
#include "uv.h"
#include <assert.h>
#include "executable_wrapper.h"
#include "node.h"

#include <algorithm>

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

int main(int argc, char** argv) {
argv = uv_setup_args(argc, argv);
NODE_MAIN(int argc, node::argv_type raw_argv[]) {
char** argv = nullptr;
node::FixupMain(argc, raw_argv, &argv);

std::vector<std::string> args(argv, argv + argc);
std::shared_ptr<node::InitializationResult> result =
node::InitializeOncePerProcess(
Expand Down Expand Up @@ -106,7 +108,7 @@ int RunNodeInstance(MultiIsolatePlatform* platform,
}

if (!snapshot_blob_path.empty() && !is_building_snapshot) {
FILE* fp = fopen(snapshot_blob_path.c_str(), "r");
FILE* fp = fopen(snapshot_blob_path.c_str(), "rb");
assert(fp != nullptr);
if (snapshot_as_file) {
snapshot = node::EmbedderSnapshotData::FromFile(fp);
Expand Down Expand Up @@ -204,7 +206,7 @@ int RunNodeInstance(MultiIsolatePlatform* platform,
snapshot = setup->CreateSnapshot();
assert(snapshot);

FILE* fp = fopen(snapshot_blob_path.c_str(), "w");
FILE* fp = fopen(snapshot_blob_path.c_str(), "wb");
assert(fp != nullptr);
if (snapshot_as_file) {
snapshot->ToFile(fp);
Expand Down
4 changes: 4 additions & 0 deletions vcbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ if "%target%"=="Build" (
if defined cctest set target="Build"
)
if "%target%"=="node" if exist "%config%\cctest.exe" del "%config%\cctest.exe"
if "%target%"=="node" if exist "%config%\embedtest.exe" del "%config%\embedtest.exe"
if defined msbuild_args set "extra_msbuild_args=%extra_msbuild_args% %msbuild_args%"
@rem Setup env variables to use multiprocessor build
set UseMultiToolTask=True
Expand Down Expand Up @@ -675,6 +676,9 @@ if not exist "%config%\cctest.exe" echo cctest.exe not found. Run "vcbuild test"
echo running 'cctest %cctest_args%'
"%config%\cctest" %cctest_args%
if %errorlevel% neq 0 set exit_code=%errorlevel%
echo running '%node_exe% test\embedding\test-embedding.js'
"%node_exe%" test\embedding\test-embedding.js
if %errorlevel% neq 0 set exit_code=%errorlevel%
:run-test-py
echo running 'python tools\test.py %test_args%'
python tools\test.py %test_args%
Expand Down

0 comments on commit c61f909

Please sign in to comment.