Skip to content

Commit f756378

Browse files
cjihrigRafaelGSS
authored andcommitted
test: update compiled sqlite tests to match other tests
This commit updates the sqlite compiled tests to be structured like other compiled tests. Refs: #56347 PR-URL: #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>
1 parent 8feb273 commit f756378

File tree

8 files changed

+73
-40
lines changed

8 files changed

+73
-40
lines changed

Makefile

+40-7
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ coverage-report-js: ## Report JavaScript coverage results.
294294
cctest: all ## Run the C++ tests using the built `cctest` executable.
295295
@out/$(BUILDTYPE)/$@ --gtest_filter=$(GTEST_FILTER)
296296
$(NODE) ./test/embedding/test-embedding.js
297-
$(NODE) ./test/sqlite/test-sqlite-extensions.mjs
298297

299298
.PHONY: list-gtests
300299
list-gtests: ## List all available C++ gtests.
@@ -312,7 +311,7 @@ v8: ## Build deps/v8.
312311
tools/make-v8.sh $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS)
313312

314313
.PHONY: jstest
315-
jstest: build-addons build-js-native-api-tests build-node-api-tests ## Run addon tests and JS tests.
314+
jstest: build-addons build-js-native-api-tests build-node-api-tests build-sqlite-tests ## Run addon tests and JS tests.
316315
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) \
317316
$(TEST_CI_ARGS) \
318317
--skip-tests=$(CI_SKIP_TESTS) \
@@ -338,6 +337,7 @@ test: all ## Run default tests, linters, and build docs.
338337
$(MAKE) -s build-addons
339338
$(MAKE) -s build-js-native-api-tests
340339
$(MAKE) -s build-node-api-tests
340+
$(MAKE) -s build-sqlite-tests
341341
$(MAKE) -s cctest
342342
$(MAKE) -s jstest
343343

@@ -346,6 +346,7 @@ test-only: all ## Run default tests, without linters or building the docs.
346346
$(MAKE) build-addons
347347
$(MAKE) build-js-native-api-tests
348348
$(MAKE) build-node-api-tests
349+
$(MAKE) build-sqlite-tests
349350
$(MAKE) cctest
350351
$(MAKE) jstest
351352
$(MAKE) tooltest
@@ -356,6 +357,7 @@ test-cov: all ## Run coverage tests.
356357
$(MAKE) build-addons
357358
$(MAKE) build-js-native-api-tests
358359
$(MAKE) build-node-api-tests
360+
$(MAKE) build-sqlite-tests
359361
$(MAKE) cctest
360362
CI_SKIP_TESTS=$(COV_SKIP_TESTS) $(MAKE) jstest
361363

@@ -501,6 +503,23 @@ benchmark/napi/.buildstamp: $(ADDONS_PREREQS) \
501503
$(BENCHMARK_NAPI_BINDING_GYPS) $(BENCHMARK_NAPI_BINDING_SOURCES)
502504
@$(call run_build_addons,"$$PWD/benchmark/napi",$@)
503505

506+
SQLITE_BINDING_GYPS := $(wildcard test/sqlite/*/binding.gyp)
507+
508+
SQLITE_BINDING_SOURCES := \
509+
$(wildcard test/sqlite/*/*.c)
510+
511+
# Implicitly depends on $(NODE_EXE), see the build-sqlite-tests rule for rationale.
512+
test/sqlite/.buildstamp: $(ADDONS_PREREQS) \
513+
$(SQLITE_BINDING_GYPS) $(SQLITE_BINDING_SOURCES)
514+
@$(call run_build_addons,"$$PWD/test/sqlite",$@)
515+
516+
.PHONY: build-sqlite-tests
517+
# .buildstamp needs $(NODE_EXE) but cannot depend on it
518+
# directly because it calls make recursively. The parent make cannot know
519+
# if the subprocess touched anything so it pessimistically assumes that
520+
# .buildstamp is out of date and need a rebuild.
521+
build-sqlite-tests: | $(NODE_EXE) test/sqlite/.buildstamp ## Build SQLite tests.
522+
504523
.PHONY: clear-stalled
505524
clear-stalled: ## Clear any stalled processes.
506525
$(info Clean up any leftover processes but don't error if found.)
@@ -511,14 +530,18 @@ clear-stalled: ## Clear any stalled processes.
511530
fi
512531

513532
.PHONY: test-build
514-
test-build: | all build-addons build-js-native-api-tests build-node-api-tests ## Build all tests.
533+
test-build: | all build-addons build-js-native-api-tests build-node-api-tests build-sqlite-tests ## Build all tests.
515534

516535
.PHONY: test-build-js-native-api
517536
test-build-js-native-api: all build-js-native-api-tests ## Build JS Native-API tests.
518537

519538
.PHONY: test-build-node-api
520539
test-build-node-api: all build-node-api-tests ## Build Node-API tests.
521540

541+
.PHONY: test-build-sqlite
542+
test-build-sqlite: all build-sqlite-tests ## Build SQLite tests.
543+
544+
522545
.PHONY: test-all
523546
test-all: test-build ## Run default tests with both Debug and Release builds.
524547
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=debug,release
@@ -546,7 +569,7 @@ endif
546569

547570
# Related CI job: node-test-commit-arm-fanned
548571
test-ci-native: LOGLEVEL := info ## Build and test addons without building anything else.
549-
test-ci-native: | benchmark/napi/.buildstamp test/addons/.buildstamp test/js-native-api/.buildstamp test/node-api/.buildstamp
572+
test-ci-native: | benchmark/napi/.buildstamp test/addons/.buildstamp test/js-native-api/.buildstamp test/node-api/.buildstamp test/sqlite/.buildstamp
550573
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
551574
--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
552575
$(TEST_CI_ARGS) $(CI_NATIVE_SUITES)
@@ -569,13 +592,12 @@ test-ci-js: | clear-stalled ## Build and test JavaScript with building anything
569592
.PHONY: test-ci
570593
# Related CI jobs: most CI tests, excluding node-test-commit-arm-fanned
571594
test-ci: LOGLEVEL := info ## Build and test everything (CI).
572-
test-ci: | clear-stalled bench-addons-build build-addons build-js-native-api-tests build-node-api-tests doc-only
595+
test-ci: | clear-stalled bench-addons-build build-addons build-js-native-api-tests build-node-api-tests build-sqlite-tests doc-only
573596
out/Release/cctest --gtest_output=xml:out/junit/cctest.xml
574597
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
575598
--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
576599
$(TEST_CI_ARGS) $(CI_JS_SUITES) $(CI_NATIVE_SUITES) $(CI_DOC)
577600
$(NODE) ./test/embedding/test-embedding.js
578-
$(NODE) ./test/sqlite/test-sqlite-extensions.mjs
579601
$(info Clean up any leftover processes, error if found.)
580602
ps awwx | grep Release/node | grep -v grep | cat
581603
@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.
681703
$(RM) -r test/node-api/*/build
682704
$(RM) test/node-api/.buildstamp
683705

706+
.PHONY: test-sqlite
707+
test-sqlite: test-build-sqlite ## Run SQLite tests.
708+
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) sqlite
709+
710+
.PHONY: test-sqlite-clean
711+
.NOTPARALLEL: test-sqlite-clean
712+
test-sqlite-clean: ## Remove SQLite testing artifacts.
713+
$(RM) -r test/sqlite/*/build
714+
$(RM) test/sqlite/.buildstamp
715+
684716
.PHONY: test-addons
685717
test-addons: test-build test-js-native-api test-node-api ## Run addon tests.
686718
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) addons
@@ -1446,7 +1478,7 @@ LINT_CPP_FILES = $(filter-out $(LINT_CPP_EXCLUDE), $(wildcard \
14461478
test/cctest/*.h \
14471479
test/embedding/*.cc \
14481480
test/embedding/*.h \
1449-
test/sqlite/*.c \
1481+
test/sqlite/*/*.c \
14501482
test/fixtures/*.c \
14511483
test/js-native-api/*/*.cc \
14521484
test/node-api/*/*.cc \
@@ -1470,6 +1502,7 @@ FORMAT_CPP_FILES += $(wildcard \
14701502
test/js-native-api/*/*.h \
14711503
test/node-api/*/*.c \
14721504
test/node-api/*/*.h \
1505+
test/sqlite/*/*.c \
14731506
)
14741507

14751508
# Code blocks don't have newline at the end,

node.gyp

-20
Original file line numberDiff line numberDiff line change
@@ -1296,26 +1296,6 @@
12961296
],
12971297
}, # embedtest
12981298

1299-
{
1300-
'target_name': 'sqlite_extension',
1301-
'type': 'shared_library',
1302-
'sources': [
1303-
'test/sqlite/extension.c'
1304-
],
1305-
1306-
'include_dirs': [
1307-
'test/sqlite',
1308-
'deps/sqlite',
1309-
],
1310-
1311-
'cflags': [
1312-
'-fPIC',
1313-
'-Wall',
1314-
'-Wextra',
1315-
'-O3',
1316-
],
1317-
}, # sqlitetest
1318-
13191299
{
13201300
'target_name': 'overlapped-checker',
13211301
'type': 'executable',

test/sqlite/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

test/sqlite/sqlite.status

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
prefix sqlite
2+
3+
# To mark a test as flaky, list the test name in the appropriate section
4+
# below, without ".js", followed by ": PASS,FLAKY". Example:
5+
# sample-test : PASS,FLAKY
6+
7+
[true] # This section applies to all platforms
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"targets": [
3+
{
4+
"target_name": "sqlite_extension",
5+
"type": "shared_library",
6+
"sources": [ "extension.c" ],
7+
"include_dirs": [ "../../../deps/sqlite" ]
8+
}
9+
]
10+
}
File renamed without changes.

test/sqlite/test-sqlite-extensions.mjs test/sqlite/test_sqlite_extensions/test.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
import * as common from '../common/index.mjs';
2-
3-
import assert from 'node:assert';
4-
import path from 'node:path';
5-
import sqlite from 'node:sqlite';
6-
import test from 'node:test';
7-
import fs from 'node:fs';
8-
import childProcess from 'child_process';
1+
'use strict';
2+
const common = require('../../common');
3+
const assert = require('node:assert');
4+
const path = require('node:path');
5+
const sqlite = require('node:sqlite');
6+
const test = require('node:test');
7+
const fs = require('node:fs');
8+
const childProcess = require('node:child_process');
99

1010
if (process.config.variables.node_shared_sqlite) {
1111
common.skip('Missing libsqlite_extension binary');
1212
}
1313

1414
// Lib extension binary is named differently on different platforms
15-
function resolveBuiltBinary(binary) {
16-
const targetFile = fs.readdirSync(path.dirname(process.execPath)).find((file) => file.startsWith(binary));
17-
return path.join(path.dirname(process.execPath), targetFile);
15+
function resolveBuiltBinary() {
16+
const buildDir = `${__dirname}/build/${common.buildType}`;
17+
const lib = 'sqlite_extension';
18+
const targetFile = fs.readdirSync(buildDir).find((file) => file.startsWith(lib));
19+
return path.join(buildDir, targetFile);
1820
}
1921

20-
const binary = resolveBuiltBinary('libsqlite_extension');
22+
const binary = resolveBuiltBinary();
2123

2224
test('should load extension successfully', () => {
2325
const db = new sqlite.DatabaseSync(':memory:', {

test/sqlite/testcfg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
import testpy
44

55
def GetConfiguration(context, root):
6-
return testpy.SimpleTestConfiguration(context, root, 'sqlite')
6+
return testpy.AddonTestConfiguration(context, root, 'sqlite')

0 commit comments

Comments
 (0)