test: remove test/gc, integrate into parallel

There’s no reason to have a separate addon just for
testing GC anymore.

PR-URL: https://github.com/nodejs/node/pull/22001
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
Anna Henningsen 2018-07-27 13:36:35 +02:00
parent dcfbedb365
commit 02badc424f
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9
13 changed files with 23 additions and 152 deletions

View File

@ -314,15 +314,6 @@ benchmark/napi/function_args/build/Release/binding.node: all \
--directory="$(shell pwd)/benchmark/napi/function_args" \
--nodedir="$(shell pwd)"
# Implicitly depends on $(NODE_EXE). We don't depend on it explicitly because
# it always triggers a rebuild due to it being a .PHONY rule. See the comment
# near the build-addons rule for more background.
test/gc/build/Release/binding.node: test/gc/binding.cc test/gc/binding.gyp
$(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
--python="$(PYTHON)" \
--directory="$(shell pwd)/test/gc" \
--nodedir="$(shell pwd)"
DOCBUILDSTAMP_PREREQS = tools/doc/addon-verify.js doc/api/addons.md
ifeq ($(OSTYPE),aix)
@ -405,20 +396,12 @@ clear-stalled:
echo $${PS_OUT} | xargs kill -9; \
fi
.PHONY: test-gc
test-gc: all test/gc/build/Release/binding.node
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) gc
.PHONY: test-gc-clean
test-gc-clean:
$(RM) -r test/gc/build
test-build: | all build-addons build-addons-napi
test-build-addons-napi: all build-addons-napi
.PHONY: test-all
test-all: test-build test/gc/build/Release/binding.node ## Run everything in test/.
test-all: test-build ## Run everything in test/.
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=debug,release
test-all-valgrind: test-build
@ -1178,7 +1161,6 @@ LINT_CPP_FILES = $(filter-out $(LINT_CPP_EXCLUDE), $(wildcard \
test/cctest/*.h \
test/addons-napi/*/*.cc \
test/addons-napi/*/*.h \
test/gc/binding.cc \
tools/icu/*.cc \
tools/icu/*.h \
))

View File

@ -25,7 +25,6 @@ GitHub with the `autocrlf` git config flag set to true.
|doctool |Yes |Tests for the documentation generator.|
|es-module |Yes |Test ESM module loading.|
|fixtures | |Test fixtures used in various tests throughout the test suite.|
|gc |No |Tests for garbage collection related functionality.|
|internet |No |Tests that make real outbound connections (mainly networking related modules). Tests for networking related modules may also be present in other directories, but those tests do not make outbound connections.|
|known_issues |Yes |Tests reproducing known issues within the system. All tests inside of this directory are expected to fail consistently. If a test doesn't fail on certain platforms, those should be skipped via `known_issues.status`.|
|message |Yes |Tests for messages that are output for various conditions (```console.log```, error messages etc.)|

1
test/gc/.gitignore vendored
View File

@ -1 +0,0 @@
build/

View File

@ -1,80 +0,0 @@
#include "node.h"
#include "uv.h"
#include <assert.h>
#include <stdlib.h>
#include <vector>
#ifdef NDEBUG
#define CHECK(x) do { if (!(x)) abort(); } while (false)
#else
#define CHECK assert
#endif
#define CHECK_EQ(a, b) CHECK((a) == (b))
namespace {
struct Callback {
inline Callback(v8::Isolate* isolate,
v8::Local<v8::Object> object,
v8::Local<v8::Function> function)
: object(isolate, object), function(isolate, function) {}
v8::Persistent<v8::Object> object;
v8::Persistent<v8::Function> function;
};
static uv_async_t async_handle;
static std::vector<Callback*> callbacks;
inline void Prime() {
uv_ref(reinterpret_cast<uv_handle_t*>(&async_handle));
CHECK_EQ(0, uv_async_send(&async_handle));
}
inline void AsyncCallback(uv_async_t*) {
auto isolate = v8::Isolate::GetCurrent();
v8::HandleScope handle_scope(isolate);
auto context = isolate->GetCurrentContext();
auto global = context->Global();
while (!callbacks.empty()) {
v8::HandleScope handle_scope(isolate);
auto callback = callbacks.back();
callbacks.pop_back();
auto function = v8::Local<v8::Function>::New(isolate, callback->function);
delete callback;
if (node::MakeCallback(isolate, global, function, 0, nullptr).IsEmpty())
return Prime(); // Have exception, flush remainder on next loop tick.
}
uv_unref(reinterpret_cast<uv_handle_t*>(&async_handle));
}
inline void OnGC(const v8::FunctionCallbackInfo<v8::Value>& info) {
CHECK(info[0]->IsObject());
CHECK(info[1]->IsFunction());
auto object = info[0].As<v8::Object>();
auto function = info[1].As<v8::Function>();
auto callback = new Callback(info.GetIsolate(), object, function);
auto on_callback = [] (const v8::WeakCallbackInfo<Callback>& data) {
auto callback = data.GetParameter();
callbacks.push_back(callback);
callback->object.Reset();
Prime();
};
callback->object.SetWeak(callback, on_callback,
v8::WeakCallbackType::kParameter);
}
inline void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> module,
v8::Local<v8::Context> context) {
NODE_SET_METHOD(module->ToObject(context).ToLocalChecked(), "exports", OnGC);
CHECK_EQ(0, uv_async_init(uv_default_loop(), &async_handle, AsyncCallback));
uv_unref(reinterpret_cast<uv_handle_t*>(&async_handle));
}
} // anonymous namespace
NODE_MODULE_CONTEXT_AWARE(NODE_GYP_MODULE_NAME, Initialize)

View File

@ -1,9 +0,0 @@
{
'targets': [
{
'target_name': 'binding',
'defines': [ 'V8_DEPRECATION_WARNINGS=1' ],
'sources': [ 'binding.cc' ],
},
],
}

View File

@ -1,6 +0,0 @@
import sys, os
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import testpy
def GetConfiguration(context, root):
return testpy.SimpleTestConfiguration(context, root, 'gc', ['--expose-gc'])

View File

@ -1,5 +1,6 @@
'use strict';
// just like test/gc/http-client.js,
// Flags: --expose-gc
// just like test-gc-http-client.js,
// but aborting every connection that comes in.
const common = require('../common');
@ -9,7 +10,6 @@ function serverHandler(req, res) {
}
const http = require('http');
const weak = require(`./build/${common.buildType}/binding`);
const todo = 500;
let done = 0;
let count = 0;
@ -36,7 +36,7 @@ function getall() {
}, cb).on('error', cb);
count++;
weak(req, afterGC);
common.onGC(req, { ongc });
})();
setImmediate(getall);
@ -45,7 +45,7 @@ function getall() {
for (let i = 0; i < 10; i++)
getall();
function afterGC() {
function ongc() {
countGC++;
}

View File

@ -1,5 +1,6 @@
'use strict';
// just like test/gc/http-client.js,
// Flags: --expose-gc
// just like test-gc-http-client.js,
// but with an on('error') handler that does nothing.
const common = require('../common');
@ -11,7 +12,6 @@ function serverHandler(req, res) {
}
const http = require('http');
const weak = require(`./build/${common.buildType}/binding`);
const todo = 500;
let done = 0;
let count = 0;
@ -42,7 +42,7 @@ function getall() {
}, cb).on('error', onerror);
count++;
weak(req, afterGC);
common.onGC(req, { ongc });
})();
setImmediate(getall);
@ -53,7 +53,7 @@ function runTest() {
getall();
}
function afterGC() {
function ongc() {
countGC++;
}

View File

@ -1,5 +1,6 @@
'use strict';
// just like test/gc/http-client.js,
// Flags: --expose-gc
// just like test-gc-http-client.js,
// but with a timeout set
const common = require('../common');
@ -13,7 +14,6 @@ function serverHandler(req, res) {
}
const http = require('http');
const weak = require(`./build/${common.buildType}/binding`);
const todo = 550;
let done = 0;
let count = 0;
@ -45,7 +45,7 @@ function getall() {
});
count++;
weak(req, afterGC);
common.onGC(req, { ongc });
})();
setImmediate(getall);
@ -54,7 +54,7 @@ function getall() {
for (let i = 0; i < 10; i++)
getall();
function afterGC() {
function ongc() {
countGC++;
}

View File

@ -1,4 +1,5 @@
'use strict';
// Flags: --expose-gc
// just a simple http server and client.
const common = require('../common');
@ -9,7 +10,6 @@ function serverHandler(req, res) {
}
const http = require('http');
const weak = require(`./build/${common.buildType}/binding`);
const todo = 500;
let done = 0;
let count = 0;
@ -40,7 +40,7 @@ function getall() {
}, cb);
count++;
weak(req, afterGC);
common.onGC(req, { ongc });
})();
setImmediate(getall);
@ -49,7 +49,7 @@ function getall() {
for (let i = 0; i < 10; i++)
getall();
function afterGC() {
function ongc() {
countGC++;
}

View File

@ -1,5 +1,6 @@
'use strict';
// just like test/gc/http-client-timeout.js,
// Flags: --expose-gc
// just like test-gc-http-client-timeout.js,
// but using a net server/client instead
const common = require('../common');
@ -19,7 +20,6 @@ function serverHandler(sock) {
}
const net = require('net');
const weak = require(`./build/${common.buildType}/binding`);
const assert = require('assert');
const todo = 500;
let done = 0;
@ -44,7 +44,7 @@ function getall() {
});
count++;
weak(req, afterGC);
common.onGC(req, { ongc });
setImmediate(getall);
}
@ -52,7 +52,7 @@ function getall() {
for (let i = 0; i < 10; i++)
getall();
function afterGC() {
function ongc() {
countGC++;
}

View File

@ -1538,7 +1538,6 @@ IGNORED_SUITES = [
'addons-napi',
'code-cache',
'doctool',
'gc',
'internet',
'pummel',
'tick-processor',

View File

@ -33,7 +33,6 @@ set lint_js=
set lint_cpp=
set lint_md=
set lint_md_build=
set build_testgc_addon=
set noetw=
set noetw_msi_arg=
set noperfctr=
@ -88,13 +87,12 @@ if /i "%1"=="test-addons" set test_args=%test_args% addons&set build_addons=1&
if /i "%1"=="test-addons-napi" set test_args=%test_args% addons-napi&set build_addons_napi=1&goto arg-ok
if /i "%1"=="test-simple" set test_args=%test_args% sequential parallel -J&goto arg-ok
if /i "%1"=="test-message" set test_args=%test_args% message&goto arg-ok
if /i "%1"=="test-gc" set test_args=%test_args% gc&set build_testgc_addon=1&goto arg-ok
if /i "%1"=="test-tick-processor" set test_args=%test_args% tick-processor&goto arg-ok
if /i "%1"=="test-internet" set test_args=%test_args% internet&goto arg-ok
if /i "%1"=="test-pummel" set test_args=%test_args% pummel&goto arg-ok
if /i "%1"=="test-known-issues" set test_args=%test_args% known_issues&goto arg-ok
if /i "%1"=="test-async-hooks" set test_args=%test_args% async-hooks&goto arg-ok
if /i "%1"=="test-all" set test_args=%test_args% gc internet pummel %common_test_suites%&set build_testgc_addon=1&set lint_cpp=1&set lint_js=1&goto arg-ok
if /i "%1"=="test-all" set test_args=%test_args% gc internet pummel %common_test_suites%&set lint_cpp=1&set lint_js=1&goto arg-ok
if /i "%1"=="test-node-inspect" set test_node_inspect=1&goto arg-ok
if /i "%1"=="test-check-deopts" set test_check_deopts=1&goto arg-ok
if /i "%1"=="test-npm" set test_npm=1&goto arg-ok
@ -467,17 +465,6 @@ for %%F in (%config%\doc\api\*.md) do (
:run
@rem Run tests if requested.
@rem Build test/gc add-on if required.
if "%build_testgc_addon%"=="" goto build-addons
%node_gyp_exe% rebuild --directory="%~dp0test\gc" --nodedir="%~dp0."
if errorlevel 1 goto build-testgc-addon-failed
goto build-addons
:build-testgc-addon-failed
echo Failed to build test/gc add-on."
goto exit
:build-addons
if not defined build_addons goto build-addons-napi
if not exist "%node_exe%" (
echo Failed to find node.exe
@ -560,7 +547,7 @@ goto lint-cpp
:lint-cpp
if not defined lint_cpp goto lint-js
call :run-lint-cpp src\*.c src\*.cc src\*.h test\addons\*.cc test\addons\*.h test\addons-napi\*.cc test\addons-napi\*.h test\cctest\*.cc test\cctest\*.h test\gc\binding.cc tools\icu\*.cc tools\icu\*.h
call :run-lint-cpp src\*.c src\*.cc src\*.h test\addons\*.cc test\addons\*.h test\addons-napi\*.cc test\addons-napi\*.h test\cctest\*.cc test\cctest\*.h tools\icu\*.cc tools\icu\*.h
python tools/check-imports.py
goto lint-js
@ -672,7 +659,7 @@ del .used_configure_flags
goto exit
:help
echo vcbuild.bat [debug/release] [msi] [doc] [test/test-ci/test-all/test-addons/test-addons-napi/test-internet/test-pummel/test-simple/test-message/test-gc/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-async-hooks/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [projgen] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [noetw] [noperfctr] [ltcg] [nopch] [licensetf] [sign] [ia32/x86/x64] [vs2017] [download-all] [enable-vtune] [lint/lint-ci/lint-js/lint-js-ci/lint-md] [lint-md-build] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [no-cctest] [openssl-no-asm]
echo vcbuild.bat [debug/release] [msi] [doc] [test/test-ci/test-all/test-addons/test-addons-napi/test-internet/test-pummel/test-simple/test-message/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-async-hooks/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [projgen] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [noetw] [noperfctr] [ltcg] [nopch] [licensetf] [sign] [ia32/x86/x64] [vs2017] [download-all] [enable-vtune] [lint/lint-ci/lint-js/lint-js-ci/lint-md] [lint-md-build] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [no-cctest] [openssl-no-asm]
echo Examples:
echo vcbuild.bat : builds release build
echo vcbuild.bat debug : builds debug build