mirror of https://github.com/nodejs/node.git
test: update compiled sqlite tests to match other tests
This commit updates the sqlite compiled tests to be structured like other compiled tests. Refs: https://github.com/nodejs/node/issues/56347 PR-URL: https://github.com/nodejs/node/pull/56446 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Stewart X Addison <sxa@redhat.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>pull/53142/merge
parent
f97a7b607b
commit
d0ff34f4b6
47
Makefile
47
Makefile
|
@ -294,7 +294,6 @@ coverage-report-js: ## Report JavaScript coverage results.
|
|||
cctest: all ## Run the C++ tests using the built `cctest` executable.
|
||||
@out/$(BUILDTYPE)/$@ --gtest_filter=$(GTEST_FILTER)
|
||||
$(NODE) ./test/embedding/test-embedding.js
|
||||
$(NODE) ./test/sqlite/test-sqlite-extensions.mjs
|
||||
|
||||
.PHONY: list-gtests
|
||||
list-gtests: ## List all available C++ gtests.
|
||||
|
@ -312,7 +311,7 @@ v8: ## Build deps/v8.
|
|||
tools/make-v8.sh $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS)
|
||||
|
||||
.PHONY: jstest
|
||||
jstest: build-addons build-js-native-api-tests build-node-api-tests ## Run addon tests and JS tests.
|
||||
jstest: build-addons build-js-native-api-tests build-node-api-tests build-sqlite-tests ## Run addon tests and JS tests.
|
||||
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) \
|
||||
$(TEST_CI_ARGS) \
|
||||
--skip-tests=$(CI_SKIP_TESTS) \
|
||||
|
@ -338,6 +337,7 @@ test: all ## Run default tests, linters, and build docs.
|
|||
$(MAKE) -s build-addons
|
||||
$(MAKE) -s build-js-native-api-tests
|
||||
$(MAKE) -s build-node-api-tests
|
||||
$(MAKE) -s build-sqlite-tests
|
||||
$(MAKE) -s cctest
|
||||
$(MAKE) -s jstest
|
||||
|
||||
|
@ -346,6 +346,7 @@ test-only: all ## Run default tests, without linters or building the docs.
|
|||
$(MAKE) build-addons
|
||||
$(MAKE) build-js-native-api-tests
|
||||
$(MAKE) build-node-api-tests
|
||||
$(MAKE) build-sqlite-tests
|
||||
$(MAKE) cctest
|
||||
$(MAKE) jstest
|
||||
$(MAKE) tooltest
|
||||
|
@ -356,6 +357,7 @@ test-cov: all ## Run coverage tests.
|
|||
$(MAKE) build-addons
|
||||
$(MAKE) build-js-native-api-tests
|
||||
$(MAKE) build-node-api-tests
|
||||
$(MAKE) build-sqlite-tests
|
||||
$(MAKE) cctest
|
||||
CI_SKIP_TESTS=$(COV_SKIP_TESTS) $(MAKE) jstest
|
||||
|
||||
|
@ -501,6 +503,23 @@ benchmark/napi/.buildstamp: $(ADDONS_PREREQS) \
|
|||
$(BENCHMARK_NAPI_BINDING_GYPS) $(BENCHMARK_NAPI_BINDING_SOURCES)
|
||||
@$(call run_build_addons,"$$PWD/benchmark/napi",$@)
|
||||
|
||||
SQLITE_BINDING_GYPS := $(wildcard test/sqlite/*/binding.gyp)
|
||||
|
||||
SQLITE_BINDING_SOURCES := \
|
||||
$(wildcard test/sqlite/*/*.c)
|
||||
|
||||
# Implicitly depends on $(NODE_EXE), see the build-sqlite-tests rule for rationale.
|
||||
test/sqlite/.buildstamp: $(ADDONS_PREREQS) \
|
||||
$(SQLITE_BINDING_GYPS) $(SQLITE_BINDING_SOURCES)
|
||||
@$(call run_build_addons,"$$PWD/test/sqlite",$@)
|
||||
|
||||
.PHONY: build-sqlite-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.
|
||||
build-sqlite-tests: | $(NODE_EXE) test/sqlite/.buildstamp ## Build SQLite tests.
|
||||
|
||||
.PHONY: clear-stalled
|
||||
clear-stalled: ## Clear any stalled processes.
|
||||
$(info Clean up any leftover processes but don't error if found.)
|
||||
|
@ -511,7 +530,7 @@ clear-stalled: ## Clear any stalled processes.
|
|||
fi
|
||||
|
||||
.PHONY: test-build
|
||||
test-build: | all build-addons build-js-native-api-tests build-node-api-tests ## Build all tests.
|
||||
test-build: | all build-addons build-js-native-api-tests build-node-api-tests build-sqlite-tests ## Build all tests.
|
||||
|
||||
.PHONY: test-build-js-native-api
|
||||
test-build-js-native-api: all build-js-native-api-tests ## Build JS Native-API tests.
|
||||
|
@ -519,6 +538,10 @@ test-build-js-native-api: all build-js-native-api-tests ## Build JS Native-API t
|
|||
.PHONY: test-build-node-api
|
||||
test-build-node-api: all build-node-api-tests ## Build Node-API tests.
|
||||
|
||||
.PHONY: test-build-sqlite
|
||||
test-build-sqlite: all build-sqlite-tests ## Build SQLite tests.
|
||||
|
||||
|
||||
.PHONY: test-all
|
||||
test-all: test-build ## Run default tests with both Debug and Release builds.
|
||||
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=debug,release
|
||||
|
@ -546,7 +569,7 @@ endif
|
|||
|
||||
# Related CI job: node-test-commit-arm-fanned
|
||||
test-ci-native: LOGLEVEL := info ## Build and test addons without building anything else.
|
||||
test-ci-native: | benchmark/napi/.buildstamp test/addons/.buildstamp test/js-native-api/.buildstamp test/node-api/.buildstamp
|
||||
test-ci-native: | benchmark/napi/.buildstamp test/addons/.buildstamp test/js-native-api/.buildstamp test/node-api/.buildstamp test/sqlite/.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)
|
||||
|
@ -569,13 +592,12 @@ test-ci-js: | clear-stalled ## Build and test JavaScript with building anything
|
|||
.PHONY: test-ci
|
||||
# Related CI jobs: most CI tests, excluding node-test-commit-arm-fanned
|
||||
test-ci: LOGLEVEL := info ## Build and test everything (CI).
|
||||
test-ci: | clear-stalled bench-addons-build build-addons build-js-native-api-tests build-node-api-tests doc-only
|
||||
test-ci: | clear-stalled bench-addons-build build-addons build-js-native-api-tests build-node-api-tests build-sqlite-tests doc-only
|
||||
out/Release/cctest --gtest_output=xml:out/junit/cctest.xml
|
||||
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
|
||||
--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
|
||||
$(TEST_CI_ARGS) $(CI_JS_SUITES) $(CI_NATIVE_SUITES) $(CI_DOC)
|
||||
$(NODE) ./test/embedding/test-embedding.js
|
||||
$(NODE) ./test/sqlite/test-sqlite-extensions.mjs
|
||||
$(info Clean up any leftover processes, error if found.)
|
||||
ps awwx | grep Release/node | grep -v grep | cat
|
||||
@PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
|
||||
|
@ -681,6 +703,16 @@ test-node-api-clean: ## Remove Node-API testing artifacts.
|
|||
$(RM) -r test/node-api/*/build
|
||||
$(RM) test/node-api/.buildstamp
|
||||
|
||||
.PHONY: test-sqlite
|
||||
test-sqlite: test-build-sqlite ## Run SQLite tests.
|
||||
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) sqlite
|
||||
|
||||
.PHONY: test-sqlite-clean
|
||||
.NOTPARALLEL: test-sqlite-clean
|
||||
test-sqlite-clean: ## Remove SQLite testing artifacts.
|
||||
$(RM) -r test/sqlite/*/build
|
||||
$(RM) test/sqlite/.buildstamp
|
||||
|
||||
.PHONY: test-addons
|
||||
test-addons: test-build test-js-native-api test-node-api ## Run addon tests.
|
||||
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) addons
|
||||
|
@ -1446,7 +1478,7 @@ LINT_CPP_FILES = $(filter-out $(LINT_CPP_EXCLUDE), $(wildcard \
|
|||
test/cctest/*.h \
|
||||
test/embedding/*.cc \
|
||||
test/embedding/*.h \
|
||||
test/sqlite/*.c \
|
||||
test/sqlite/*/*.c \
|
||||
test/fixtures/*.c \
|
||||
test/js-native-api/*/*.cc \
|
||||
test/node-api/*/*.cc \
|
||||
|
@ -1470,6 +1502,7 @@ FORMAT_CPP_FILES += $(wildcard \
|
|||
test/js-native-api/*/*.h \
|
||||
test/node-api/*/*.c \
|
||||
test/node-api/*/*.h \
|
||||
test/sqlite/*/*.c \
|
||||
)
|
||||
|
||||
# Code blocks don't have newline at the end,
|
||||
|
|
20
node.gyp
20
node.gyp
|
@ -1296,26 +1296,6 @@
|
|||
],
|
||||
}, # embedtest
|
||||
|
||||
{
|
||||
'target_name': 'sqlite_extension',
|
||||
'type': 'shared_library',
|
||||
'sources': [
|
||||
'test/sqlite/extension.c'
|
||||
],
|
||||
|
||||
'include_dirs': [
|
||||
'test/sqlite',
|
||||
'deps/sqlite',
|
||||
],
|
||||
|
||||
'cflags': [
|
||||
'-fPIC',
|
||||
'-Wall',
|
||||
'-Wextra',
|
||||
'-O3',
|
||||
],
|
||||
}, # sqlitetest
|
||||
|
||||
{
|
||||
'target_name': 'overlapped-checker',
|
||||
'type': 'executable',
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
build
|
|
@ -0,0 +1,7 @@
|
|||
prefix sqlite
|
||||
|
||||
# To mark a test as flaky, list the test name in the appropriate section
|
||||
# below, without ".js", followed by ": PASS,FLAKY". Example:
|
||||
# sample-test : PASS,FLAKY
|
||||
|
||||
[true] # This section applies to all platforms
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"targets": [
|
||||
{
|
||||
"target_name": "sqlite_extension",
|
||||
"type": "shared_library",
|
||||
"sources": [ "extension.c" ],
|
||||
"include_dirs": [ "../../../deps/sqlite" ]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,23 +1,25 @@
|
|||
import * as common from '../common/index.mjs';
|
||||
|
||||
import assert from 'node:assert';
|
||||
import path from 'node:path';
|
||||
import sqlite from 'node:sqlite';
|
||||
import test from 'node:test';
|
||||
import fs from 'node:fs';
|
||||
import childProcess from 'child_process';
|
||||
'use strict';
|
||||
const common = require('../../common');
|
||||
const assert = require('node:assert');
|
||||
const path = require('node:path');
|
||||
const sqlite = require('node:sqlite');
|
||||
const test = require('node:test');
|
||||
const fs = require('node:fs');
|
||||
const childProcess = require('node:child_process');
|
||||
|
||||
if (process.config.variables.node_shared_sqlite) {
|
||||
common.skip('Missing libsqlite_extension binary');
|
||||
}
|
||||
|
||||
// Lib extension binary is named differently on different platforms
|
||||
function resolveBuiltBinary(binary) {
|
||||
const targetFile = fs.readdirSync(path.dirname(process.execPath)).find((file) => file.startsWith(binary));
|
||||
return path.join(path.dirname(process.execPath), targetFile);
|
||||
function resolveBuiltBinary() {
|
||||
const buildDir = `${__dirname}/build/${common.buildType}`;
|
||||
const lib = 'sqlite_extension';
|
||||
const targetFile = fs.readdirSync(buildDir).find((file) => file.startsWith(lib));
|
||||
return path.join(buildDir, targetFile);
|
||||
}
|
||||
|
||||
const binary = resolveBuiltBinary('libsqlite_extension');
|
||||
const binary = resolveBuiltBinary();
|
||||
|
||||
test('should load extension successfully', () => {
|
||||
const db = new sqlite.DatabaseSync(':memory:', {
|
|
@ -3,4 +3,4 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
|||
import testpy
|
||||
|
||||
def GetConfiguration(context, root):
|
||||
return testpy.SimpleTestConfiguration(context, root, 'sqlite')
|
||||
return testpy.AddonTestConfiguration(context, root, 'sqlite')
|
||||
|
|
Loading…
Reference in New Issue