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: nodejs#30227 (comment)
  • Loading branch information
addaleax committed Nov 5, 2019
1 parent 5b2067c commit adccf30
Show file tree
Hide file tree
Showing 4 changed files with 18 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.

18 changes: 18 additions & 0 deletions test/cctest/test_environment.cc
Expand Up @@ -16,6 +16,7 @@ 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 +92,15 @@ 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_));
RunAtExit(*env);
}

TEST_F(EnvironmentTest, MultipleEnvironmentsPerIsolate) {
const v8::HandleScope handle_scope(isolate_);
const Argv argv;
Expand Down Expand Up @@ -163,3 +173,11 @@ 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());
}

0 comments on commit adccf30

Please sign in to comment.