Skip to content

Commit

Permalink
test: remove AtExit() addon test
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
addaleax authored and MylesBorins committed Jan 12, 2020
1 parent 3117ea6 commit de719fc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 71 deletions.
59 changes: 0 additions & 59 deletions test/addons/at-exit/binding.cc

This file was deleted.

9 changes: 0 additions & 9 deletions test/addons/at-exit/binding.gyp

This file was deleted.

3 changes: 0 additions & 3 deletions test/addons/at-exit/test.js

This file was deleted.

22 changes: 22 additions & 0 deletions test/cctest/test_environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ static bool called_cb_1 = false;
static bool called_cb_2 = false;
static bool called_cb_ordered_1 = false;
static bool called_cb_ordered_2 = false;
static bool called_at_exit_js = false;
static void at_exit_callback1(void* arg);
static void at_exit_callback2(void* arg);
static void at_exit_callback_ordered1(void* arg);
static void at_exit_callback_ordered2(void* arg);
static void at_exit_js(void* arg);
static std::string cb_1_arg; // NOLINT(runtime/string)

class EnvironmentTest : public EnvironmentTestFixture {
Expand Down Expand Up @@ -91,6 +93,17 @@ TEST_F(EnvironmentTest, AtExitWithArgument) {
EXPECT_EQ(arg, cb_1_arg);
}

TEST_F(EnvironmentTest, AtExitRunsJS) {
const v8::HandleScope handle_scope(isolate_);
const Argv argv;
Env env {handle_scope, argv};

AtExit(*env, at_exit_js, static_cast<void*>(isolate_));
EXPECT_FALSE(called_at_exit_js);
RunAtExit(*env);
EXPECT_TRUE(called_at_exit_js);
}

TEST_F(EnvironmentTest, MultipleEnvironmentsPerIsolate) {
const v8::HandleScope handle_scope(isolate_);
const Argv argv;
Expand Down Expand Up @@ -163,3 +176,12 @@ static void at_exit_callback_ordered2(void* arg) {
EXPECT_FALSE(called_cb_ordered_1);
called_cb_ordered_2 = true;
}

static void at_exit_js(void* arg) {
v8::Isolate* isolate = static_cast<v8::Isolate*>(arg);
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Object> obj = v8::Object::New(isolate);
assert(!obj.IsEmpty()); // Assert VM is still alive.
assert(obj->IsObject());
called_at_exit_js = true;
}

0 comments on commit de719fc

Please sign in to comment.