Skip to content

Commit

Permalink
test: partition N-API tests
Browse files Browse the repository at this point in the history
Partition test/addons-napi into test/js-native-api and test/node-api to
isolate the Node.js-agnostic portion of the N-API tests from the
Node.js-specific portion.

PR-URL: #24557
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
  • Loading branch information
Gabriel Schulhof committed Dec 4, 2018
1 parent 83ee137 commit 938e118
Show file tree
Hide file tree
Showing 178 changed files with 654 additions and 436 deletions.
113 changes: 78 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ v8:
tools/make-v8.sh $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS)

.PHONY: jstest
jstest: build-addons build-addons-napi ## Runs addon tests and JS tests
jstest: build-addons build-js-native-api-tests build-node-api-tests ## Runs addon tests and JS tests
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) \
--skip-tests=$(CI_SKIP_TESTS) \
$(CI_JS_SUITES) \
Expand All @@ -281,21 +281,24 @@ jstest: build-addons build-addons-napi ## Runs addon tests and JS tests
test: all ## Runs default tests, linters, and builds docs.
$(MAKE) -s test-doc
$(MAKE) -s build-addons
$(MAKE) -s build-addons-napi
$(MAKE) -s build-js-native-api-tests
$(MAKE) -s build-node-api-tests
$(MAKE) -s cctest
$(MAKE) -s jstest

.PHONY: test-only
test-only: all ## For a quick test, does not run linter or build docs.
$(MAKE) build-addons
$(MAKE) build-addons-napi
$(MAKE) build-js-native-api-tests
$(MAKE) build-node-api-tests
$(MAKE) cctest
$(MAKE) jstest

# Used by `make coverage-test`
test-cov: all
$(MAKE) build-addons
$(MAKE) build-addons-napi
$(MAKE) build-js-native-api-tests
$(MAKE) build-node-api-tests
# $(MAKE) cctest
CI_SKIP_TESTS=core_line_numbers.js $(MAKE) jstest

Expand Down Expand Up @@ -381,30 +384,55 @@ test/addons/.buildstamp: $(ADDONS_PREREQS) \
# TODO(bnoordhuis) Force rebuild after gyp update.
build-addons: | $(NODE_EXE) test/addons/.buildstamp

ADDONS_NAPI_BINDING_GYPS := \
$(filter-out test/addons-napi/??_*/binding.gyp, \
$(wildcard test/addons-napi/*/binding.gyp))
JS_NATIVE_API_BINDING_GYPS := \
$(filter-out test/js-native-api/??_*/binding.gyp, \
$(wildcard test/js-native-api/*/binding.gyp))

ADDONS_NAPI_BINDING_SOURCES := \
$(filter-out test/addons-napi/??_*/*.c, $(wildcard test/addons-napi/*/*.c)) \
$(filter-out test/addons-napi/??_*/*.cc, $(wildcard test/addons-napi/*/*.cc)) \
$(filter-out test/addons-napi/??_*/*.h, $(wildcard test/addons-napi/*/*.h))
JS_NATIVE_API_BINDING_SOURCES := \
$(filter-out test/js-native-api/??_*/*.c, $(wildcard test/js-native-api/*/*.c)) \
$(filter-out test/js-native-api/??_*/*.cc, $(wildcard test/js-native-api/*/*.cc)) \
$(filter-out test/js-native-api/??_*/*.h, $(wildcard test/js-native-api/*/*.h))

# Implicitly depends on $(NODE_EXE), see the build-addons-napi rule for rationale.
test/addons-napi/.buildstamp: $(ADDONS_PREREQS) \
$(ADDONS_NAPI_BINDING_GYPS) $(ADDONS_NAPI_BINDING_SOURCES) \
# Implicitly depends on $(NODE_EXE), see the build-js-native-api-tests rule for rationale.
test/js-native-api/.buildstamp: $(ADDONS_PREREQS) \
$(JS_NATIVE_API_BINDING_GYPS) $(JS_NATIVE_API_BINDING_SOURCES) \
src/node_api.h src/node_api_types.h src/js_native_api.h \
src/js_native_api_types.h src/js_native_api_v8.h src/js_native_api_v8_internals.h
@$(call run_build_addons,"$$PWD/test/addons-napi",$@)
@$(call run_build_addons,"$$PWD/test/js-native-api",$@)

.PHONY: build-addons-napi
.PHONY: build-js-native-api-tests
# .buildstamp needs $(NODE_EXE) but cannot depend on it
# directly because it calls make recursively. The parent make cannot know
# if the subprocess touched anything so it pessimistically assumes that
# .buildstamp is out of date and need a rebuild.
# Just goes to show that recursive make really is harmful...
# TODO(bnoordhuis) Force rebuild after gyp or node-gyp update.
build-addons-napi: | $(NODE_EXE) test/addons-napi/.buildstamp
build-js-native-api-tests: | $(NODE_EXE) test/js-native-api/.buildstamp

NODE_API_BINDING_GYPS := \
$(filter-out test/node-api/??_*/binding.gyp, \
$(wildcard test/node-api/*/binding.gyp))

NODE_API_BINDING_SOURCES := \
$(filter-out test/node-api/??_*/*.c, $(wildcard test/node-api/*/*.c)) \
$(filter-out test/node-api/??_*/*.cc, $(wildcard test/node-api/*/*.cc)) \
$(filter-out test/node-api/??_*/*.h, $(wildcard test/node-api/*/*.h))

# Implicitly depends on $(NODE_EXE), see the build-node-api-tests rule for rationale.
test/node-api/.buildstamp: $(ADDONS_PREREQS) \
$(NODE_API_BINDING_GYPS) $(NODE_API_BINDING_SOURCES) \
src/node_api.h src/node_api_types.h src/js_native_api.h \
src/js_native_api_types.h src/js_native_api_v8.h src/js_native_api_v8_internals.h
@$(call run_build_addons,"$$PWD/test/node-api",$@)

.PHONY: build-node-api-tests
# .buildstamp needs $(NODE_EXE) but cannot depend on it
# directly because it calls make recursively. The parent make cannot know
# if the subprocess touched anything so it pessimistically assumes that
# .buildstamp is out of date and need a rebuild.
# Just goes to show that recursive make really is harmful...
# TODO(bnoordhuis) Force rebuild after gyp or node-gyp update.
build-node-api-tests: | $(NODE_EXE) test/node-api/.buildstamp

.PHONY: clear-stalled
clear-stalled:
Expand All @@ -415,9 +443,11 @@ clear-stalled:
echo $${PS_OUT} | xargs kill -9; \
fi

test-build: | all build-addons build-addons-napi
test-build: | all build-addons build-js-native-api-tests build-node-api-tests

test-build-addons-napi: all build-addons-napi
test-build-js-native-api: all build-js-native-api-tests

test-build-node-api: all build-node-api-tests

.PHONY: test-all
test-all: test-build ## Run everything in test/.
Expand All @@ -426,15 +456,15 @@ test-all: test-build ## Run everything in test/.
test-all-valgrind: test-build
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=debug,release --valgrind

CI_NATIVE_SUITES ?= addons addons-napi
CI_NATIVE_SUITES ?= addons js-native-api node-api
CI_JS_SUITES ?= default
CI_DOC := doctool

.PHONY: test-ci-native
# Build and test addons without building anything else
# Related CI job: node-test-commit-arm-fanned
test-ci-native: LOGLEVEL := info
test-ci-native: | test/addons/.buildstamp test/addons-napi/.buildstamp
test-ci-native: | test/addons/.buildstamp test/js-native-api/.buildstamp test/node-api/.buildstamp
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
$(TEST_CI_ARGS) $(CI_NATIVE_SUITES)
Expand All @@ -456,7 +486,7 @@ test-ci-js: | clear-stalled
.PHONY: test-ci
# Related CI jobs: most CI tests, excluding node-test-commit-arm-fanned
test-ci: LOGLEVEL := info
test-ci: | clear-stalled build-addons build-addons-napi doc-only
test-ci: | clear-stalled build-addons build-js-native-api-tests build-node-api-tests doc-only
out/Release/cctest --gtest_output=tap:cctest.tap
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
Expand Down Expand Up @@ -539,32 +569,43 @@ test-npm: $(NODE_EXE) ## Run the npm test suite on deps/npm.
test-npm-publish: $(NODE_EXE)
npm_package_config_publishtest=true $(NODE) deps/npm/test/run.js

.PHONY: test-addons-napi
test-addons-napi: test-build-addons-napi
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) addons-napi
.PHONY: test-js-native-api
test-js-native-api: test-build-js-native-api
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) js-native-api

.PHONY: test-js-native-api-clean
test-js-native-api-clean:
$(RM) -r test/js-native-api/*/build
$(RM) test/js-native-api/.buildstamp

.PHONY: test-node-api
test-node-api: test-build-node-api
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) node-api

.PHONY: test-addons-napi-clean
test-addons-napi-clean:
$(RM) -r test/addons-napi/*/build
$(RM) test/addons-napi/.buildstamp
.PHONY: test-node-api-clean
test-node-api-clean:
$(RM) -r test/node-api/*/build
$(RM) test/node-api/.buildstamp

.PHONY: test-addons
test-addons: test-build test-addons-napi
test-addons: test-build test-js-native-api test-node-api
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) addons

.PHONY: test-addons-clean
test-addons-clean:
$(RM) -r test/addons/??_*/
$(RM) -r test/addons/*/build
$(RM) test/addons/.buildstamp test/addons/.docbuildstamp
$(MAKE) test-addons-napi-clean
$(MAKE) test-js-native-api-clean
$(MAKE) test-node-api-clean

test-async-hooks:
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) async-hooks

test-with-async-hooks:
$(MAKE) build-addons
$(MAKE) build-addons-napi
$(MAKE) build-js-native-api-tests
$(MAKE) build-node-api-tests
$(MAKE) cctest
NODE_TEST_WITH_ASYNC_HOOKS=1 $(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) \
$(CI_JS_SUITES) \
Expand Down Expand Up @@ -1136,7 +1177,7 @@ LINT_CPP_ADDON_DOC_FILES = $(wildcard $(LINT_CPP_ADDON_DOC_FILES_GLOB))
LINT_CPP_EXCLUDE ?=
LINT_CPP_EXCLUDE += src/node_root_certs.h
LINT_CPP_EXCLUDE += $(LINT_CPP_ADDON_DOC_FILES)
LINT_CPP_EXCLUDE += $(wildcard test/addons-napi/??_*/*.cc test/addons-napi/??_*/*.h)
LINT_CPP_EXCLUDE += $(wildcard test/js-native-api/??_*/*.cc test/js-native-api/??_*/*.h test/node-api/??_*/*.cc test/node-api/??_*/*.h)
# These files were copied more or less verbatim from V8.
LINT_CPP_EXCLUDE += src/tracing/trace_event.h src/tracing/trace_event_common.h

Expand All @@ -1152,8 +1193,10 @@ LINT_CPP_FILES = $(filter-out $(LINT_CPP_EXCLUDE), $(wildcard \
test/addons/*/*.h \
test/cctest/*.cc \
test/cctest/*.h \
test/addons-napi/*/*.cc \
test/addons-napi/*/*.h \
test/js-native-api/*/*.cc \
test/js-native-api/*/*.h \
test/node-api/*/*.cc \
test/node-api/*/*.h \
tools/icu/*.cc \
tools/icu/*.h \
))
Expand Down
3 changes: 2 additions & 1 deletion test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ GitHub with the `autocrlf` git config flag set to true.
| ------------------- | --------------- | --------------- |
| `abort` | Yes | Tests for when the ``` --abort-on-uncaught-exception ``` flag is used. |
| `addons` | Yes | Tests for [addon](https://nodejs.org/api/addons.html) functionality along with some tests that require an addon to function properly. |
| `addons-napi` | Yes | Tests for [n-api](https://nodejs.org/api/n-api.html) functionality. |
| `async-hooks` | Yes | Tests for [async_hooks](https://nodejs.org/api/async_hooks.html) functionality. |
| `benchmark` | No | Test minimal functionality of benchmarks. |
| `cctest` | Yes | C++ tests that are run as part of the build process. |
Expand All @@ -27,8 +26,10 @@ GitHub with the `autocrlf` git config flag set to true.
| `es-module` | Yes | Test ESM module loading. |
| `fixtures` | | Test fixtures used in various tests throughout the test suite. |
| `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. |
| `js-native-api` | Yes | Tests for Node.js-agnostic [n-api](https://nodejs.org/api/n-api.html) functionality. |
| `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.) |
| `node-api` | Yes | Tests for Node.js-specific [n-api](https://nodejs.org/api/n-api.html) functionality. |
| `parallel` | Yes | Various tests that are able to be run in parallel. |
| `pseudo-tty` | Yes | Tests that require stdin/stdout/stderr to be a TTY. |
| `pummel` | No | Various tests for various modules / system functionality operating under load. |
Expand Down
8 changes: 0 additions & 8 deletions test/addons-napi/2_function_arguments/binding.gyp

This file was deleted.

8 changes: 0 additions & 8 deletions test/addons-napi/3_callbacks/binding.gyp

This file was deleted.

8 changes: 0 additions & 8 deletions test/addons-napi/4_object_factory/binding.gyp

This file was deleted.

8 changes: 0 additions & 8 deletions test/addons-napi/5_function_factory/binding.gyp

This file was deleted.

10 changes: 0 additions & 10 deletions test/addons-napi/6_object_wrap/binding.cc

This file was deleted.

8 changes: 0 additions & 8 deletions test/addons-napi/6_object_wrap/binding.gyp

This file was deleted.

8 changes: 0 additions & 8 deletions test/addons-napi/7_factory_wrap/binding.gyp

This file was deleted.

8 changes: 0 additions & 8 deletions test/addons-napi/8_passing_wrapped/binding.gyp

This file was deleted.

8 changes: 0 additions & 8 deletions test/addons-napi/test_array/binding.gyp

This file was deleted.

8 changes: 0 additions & 8 deletions test/addons-napi/test_bigint/binding.gyp

This file was deleted.

12 changes: 0 additions & 12 deletions test/addons-napi/test_constructor/binding.gyp

This file was deleted.

18 changes: 0 additions & 18 deletions test/addons-napi/test_constructor/test_constructor_name.c

This file was deleted.

8 changes: 0 additions & 8 deletions test/addons-napi/test_conversions/binding.gyp

This file was deleted.

8 changes: 0 additions & 8 deletions test/addons-napi/test_dataview/binding.gyp

This file was deleted.

8 changes: 0 additions & 8 deletions test/addons-napi/test_error/binding.gyp

This file was deleted.

Loading

0 comments on commit 938e118

Please sign in to comment.