Skip to content

Commit ab5bca3

Browse files
addaleaxMylesBorins
authored andcommitted
test: remove AtExit() addon test
Move the one bit of the addon test that was not covered by the cctest into the latter and delete the former. Refs: #30227 (comment) PR-URL: #30275 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent b744070 commit ab5bca3

File tree

4 files changed

+22
-71
lines changed

4 files changed

+22
-71
lines changed

test/addons/at-exit/binding.cc

-59
This file was deleted.

test/addons/at-exit/binding.gyp

-9
This file was deleted.

test/addons/at-exit/test.js

-3
This file was deleted.

test/cctest/test_environment.cc

+22
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ static bool called_cb_1 = false;
1212
static bool called_cb_2 = false;
1313
static bool called_cb_ordered_1 = false;
1414
static bool called_cb_ordered_2 = false;
15+
static bool called_at_exit_js = false;
1516
static void at_exit_callback1(void* arg);
1617
static void at_exit_callback2(void* arg);
1718
static void at_exit_callback_ordered1(void* arg);
1819
static void at_exit_callback_ordered2(void* arg);
20+
static void at_exit_js(void* arg);
1921
static std::string cb_1_arg; // NOLINT(runtime/string)
2022

2123
class EnvironmentTest : public EnvironmentTestFixture {
@@ -91,6 +93,17 @@ TEST_F(EnvironmentTest, AtExitWithArgument) {
9193
EXPECT_EQ(arg, cb_1_arg);
9294
}
9395

96+
TEST_F(EnvironmentTest, AtExitRunsJS) {
97+
const v8::HandleScope handle_scope(isolate_);
98+
const Argv argv;
99+
Env env {handle_scope, argv};
100+
101+
AtExit(*env, at_exit_js, static_cast<void*>(isolate_));
102+
EXPECT_FALSE(called_at_exit_js);
103+
RunAtExit(*env);
104+
EXPECT_TRUE(called_at_exit_js);
105+
}
106+
94107
TEST_F(EnvironmentTest, MultipleEnvironmentsPerIsolate) {
95108
const v8::HandleScope handle_scope(isolate_);
96109
const Argv argv;
@@ -163,3 +176,12 @@ static void at_exit_callback_ordered2(void* arg) {
163176
EXPECT_FALSE(called_cb_ordered_1);
164177
called_cb_ordered_2 = true;
165178
}
179+
180+
static void at_exit_js(void* arg) {
181+
v8::Isolate* isolate = static_cast<v8::Isolate*>(arg);
182+
v8::HandleScope handle_scope(isolate);
183+
v8::Local<v8::Object> obj = v8::Object::New(isolate);
184+
assert(!obj.IsEmpty()); // Assert VM is still alive.
185+
assert(obj->IsObject());
186+
called_at_exit_js = true;
187+
}

0 commit comments

Comments
 (0)