diff options
author | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-06-20 09:09:33 +0200 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-06-27 05:19:30 +0200 |
commit | d6f7a32570994b21c628b517b3ddc863a1f059fb (patch) | |
tree | 5f7d29d095f13647ab1657e71a9c8398cac7a787 /test/cctest | |
parent | 4f67c6f667fa98e25ba311d3459fc8e270407250 (diff) | |
download | android-node-v8-d6f7a32570994b21c628b517b3ddc863a1f059fb.tar.gz android-node-v8-d6f7a32570994b21c628b517b3ddc863a1f059fb.tar.bz2 android-node-v8-d6f7a32570994b21c628b517b3ddc863a1f059fb.zip |
test: make cctest fixture use node::NewIsolate
This commit updates the gtest fixture to use node::NewIsolate instead of
creating a new V8 Isolate using v8::Isolate::New.
The motivation for this is that without calling node::NewIsolate the
various callbacks set on the isolate, for example AddMessageListener,
SetFatalErrorHandler etc, would not get set. I don't think this is the
expected behaviour and I ran into this when writing a new cctest.
PR-URL: https://github.com/nodejs/node/pull/21419
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test/cctest')
-rw-r--r-- | test/cctest/node_test_fixture.cc | 3 | ||||
-rw-r--r-- | test/cctest/node_test_fixture.h | 11 |
2 files changed, 7 insertions, 7 deletions
diff --git a/test/cctest/node_test_fixture.cc b/test/cctest/node_test_fixture.cc index 3e5a112240..1fe6ba477b 100644 --- a/test/cctest/node_test_fixture.cc +++ b/test/cctest/node_test_fixture.cc @@ -1,7 +1,6 @@ #include "node_test_fixture.h" +ArrayBufferUniquePtr NodeTestFixture::allocator{nullptr, nullptr}; uv_loop_t NodeTestFixture::current_loop; std::unique_ptr<node::NodePlatform> NodeTestFixture::platform; -std::unique_ptr<v8::ArrayBuffer::Allocator> NodeTestFixture::allocator; std::unique_ptr<v8::TracingController> NodeTestFixture::tracing_controller; -v8::Isolate::CreateParams NodeTestFixture::params; diff --git a/test/cctest/node_test_fixture.h b/test/cctest/node_test_fixture.h index f43cb56cd3..c9193ffffa 100644 --- a/test/cctest/node_test_fixture.h +++ b/test/cctest/node_test_fixture.h @@ -53,13 +53,14 @@ struct Argv { int nr_args_; }; +using ArrayBufferUniquePtr = std::unique_ptr<node::ArrayBufferAllocator, + decltype(&node::FreeArrayBufferAllocator)>; class NodeTestFixture : public ::testing::Test { protected: - static std::unique_ptr<v8::ArrayBuffer::Allocator> allocator; + static ArrayBufferUniquePtr allocator; static std::unique_ptr<v8::TracingController> tracing_controller; static std::unique_ptr<node::NodePlatform> platform; - static v8::Isolate::CreateParams params; static uv_loop_t current_loop; v8::Isolate* isolate_; @@ -68,8 +69,6 @@ class NodeTestFixture : public ::testing::Test { node::tracing::TraceEventHelper::SetTracingController( tracing_controller.get()); platform.reset(new node::NodePlatform(4, nullptr)); - allocator.reset(v8::ArrayBuffer::Allocator::NewDefaultAllocator()); - params.array_buffer_allocator = allocator.get(); CHECK_EQ(0, uv_loop_init(¤t_loop)); v8::V8::InitializePlatform(platform.get()); v8::V8::Initialize(); @@ -85,7 +84,9 @@ class NodeTestFixture : public ::testing::Test { } virtual void SetUp() { - isolate_ = v8::Isolate::New(params); + allocator = ArrayBufferUniquePtr(node::CreateArrayBufferAllocator(), + &node::FreeArrayBufferAllocator); + isolate_ = NewIsolate(allocator.get()); CHECK_NE(isolate_, nullptr); } |