Skip to content

Commit 14f02fc

Browse files
authored
lib,src,test: fix tests without SQLite
PR-URL: #60906 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 4db307a commit 14f02fc

File tree

13 files changed

+35
-12
lines changed

13 files changed

+35
-12
lines changed

.github/workflows/test-shared.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ jobs:
192192
--arg ccache '(import <nixpkgs> {}).sccache' \
193193
--arg devTools '[]' \
194194
--arg benchmarkTools '[]' \
195-
${{ endsWith(matrix.system, '-darwin') && '--arg extraConfigFlags ''["--without-amaro" "--without-inspector" "--without-node-options"]'' \' || '\' }}
195+
${{ endsWith(matrix.system, '-darwin') && '--arg withAmaro false --arg withSQLite false --arg extraConfigFlags ''["--without-inspector" "--without-node-options"]'' \' || '\' }}
196196
--run '
197197
make -C "$TAR_DIR" run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
198198
'

node.gyp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,6 @@
933933
'sources': [
934934
'<@(node_sqlite_sources)',
935935
],
936-
'defines': [ 'HAVE_SQLITE=1' ],
937936
}],
938937
[ 'node_shared=="true" and node_module_version!="" and OS!="win"', {
939938
'product_extension': '<(shlib_suffix)',
@@ -982,7 +981,6 @@
982981
'sources': [
983982
'<@(node_sqlite_sources)',
984983
],
985-
'defines': [ 'HAVE_SQLITE=1' ],
986984
}],
987985
[ 'OS in "linux freebsd mac solaris openharmony" and '
988986
'target_arch=="x64" and '

node.gypi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,5 +436,10 @@
436436
}, {
437437
'defines': [ 'HAVE_AMARO=0' ]
438438
}],
439+
[ 'node_use_sqlite=="true"', {
440+
'defines': [ 'HAVE_SQLITE=1' ],
441+
}, {
442+
'defines': [ 'HAVE_SQLITE=0' ]
443+
}],
439444
],
440445
}

src/node_options.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
577577
"experimental Web Storage API",
578578
&EnvironmentOptions::webstorage,
579579
kAllowedInEnvvar,
580-
true);
580+
HAVE_SQLITE);
581581
AddAlias("--webstorage", "--experimental-webstorage");
582582
AddOption("--localstorage-file",
583583
"file used to persist localStorage data",

src/node_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class EnvironmentOptions : public Options {
127127
bool experimental_fetch = true;
128128
bool experimental_websocket = true;
129129
bool experimental_sqlite = true;
130-
bool webstorage = true;
130+
bool webstorage = HAVE_SQLITE;
131131
#ifndef OPENSSL_NO_QUIC
132132
bool experimental_quic = false;
133133
#endif

test/common/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ const knownGlobals = new Set([
370370
'CompressionStream',
371371
'DecompressionStream',
372372
'Storage',
373-
'sessionStorage',
374373
].forEach((i) => {
375374
if (globalThis[i] !== undefined) {
376375
knownGlobals.add(globalThis[i]);
@@ -387,6 +386,9 @@ if (hasCrypto) {
387386
if (hasLocalStorage) {
388387
knownGlobals.add(globalThis.localStorage);
389388
}
389+
if (hasSQLite) {
390+
knownGlobals.add(globalThis.sessionStorage);
391+
}
390392

391393
const { Worker } = require('node:worker_threads');
392394
knownGlobals.add(Worker);

test/module-hooks/test-module-hooks-builtin-require.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ const { registerHooks } = require('module');
1212

1313
const schemelessBlockList = new Set([
1414
'sea',
15-
'sqlite',
1615
'test',
1716
'test/reporters',
1817
]);
1918

19+
if (common.hasSQLite) {
20+
schemelessBlockList.add('sqlite');
21+
}
22+
2023
const testModules = [];
2124
for (const mod of schemelessBlockList) {
2225
testModules.push(`node:${mod}`);

test/module-hooks/test-module-hooks-load-builtin-require.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@ hook.deregister();
3636
// stripped for internal lookups should not get passed into the hooks.
3737
const schemelessBlockList = new Set([
3838
'sea',
39-
'sqlite',
4039
'test',
4140
'test/reporters',
4241
]);
4342

43+
if (common.hasSQLite) {
44+
schemelessBlockList.add('sqlite');
45+
}
46+
4447
const testModules = [];
4548
for (const mod of schemelessBlockList) {
4649
testModules.push(`node:${mod}`);

test/parallel/test-global.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ for (const moduleName of builtinModules) {
5959
'fetch',
6060
'crypto',
6161
'navigator',
62-
'localStorage',
63-
'sessionStorage',
6462
];
63+
if (common.hasSQLite) {
64+
expected.push('localStorage', 'sessionStorage');
65+
}
6566
assert.deepStrictEqual(new Set(Object.keys(globalThis)), new Set(expected));
6667
expected.forEach((value) => {
6768
const desc = Object.getOwnPropertyDescriptor(globalThis, value);

test/parallel/test-sqlite-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
const { skipIfSQLiteMissing } = require('../common/index.mjs');
33
const { test } = require('node:test');
44
const assert = require('node:assert');
5-
const { DatabaseSync } = require('node:sqlite');
65
skipIfSQLiteMissing();
6+
const { DatabaseSync } = require('node:sqlite');
77

88
function checkDefensiveMode(db) {
99
function journalMode() {

0 commit comments

Comments
 (0)