Skip to content

Commit e72ecf6

Browse files
committed
lib,src,test: fix tests without SQLite
1 parent 7a5e32a commit e72ecf6

File tree

6 files changed

+20
-2
lines changed

6 files changed

+20
-2
lines changed

.github/workflows/test-shared.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ jobs:
164164
--arg ccache '(import <nixpkgs> {}).sccache' \
165165
--arg devTools '[]' \
166166
--arg benchmarkTools '[]' \
167-
${{ endsWith(matrix.system, '-darwin') && '--arg extraConfigFlags ''["--without-inspector"]'' \' || '\' }}
167+
${{ endsWith(matrix.system, '-darwin') && '--arg extraConfigFlags ''["--without-inspector"]'' --arg withSQLite false \' || '\' }}
168168
--run '
169169
make -C "$TAR_DIR" run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
170170
'

lib/internal/process/pre_execution.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ function setupQuic() {
398398

399399
function setupWebStorage() {
400400
if (getEmbedderOptions().noBrowserGlobals ||
401+
!getEmbedderOptions().hasSQLite ||
401402
!getOptionValue('--experimental-webstorage')) {
402403
return;
403404
}

src/node_config.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ static void InitConfig(Local<Object> target,
9090
READONLY_FALSE_PROPERTY(target, "hasInspector");
9191
#endif
9292

93+
#if HAVE_SQLITE
94+
READONLY_TRUE_PROPERTY(target, "hasSQLite");
95+
#else
96+
READONLY_FALSE_PROPERTY(target, "hasSQLite");
97+
#endif
98+
9399
// configure --no-browser-globals
94100
#ifdef NODE_NO_BROWSER_GLOBALS
95101
READONLY_TRUE_PROPERTY(target, "noBrowserGlobals");

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);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
const { hasSQLite } = require('../common');
4+
const assert = require('node:assert');
5+
6+
// Ensuring that `sessionStorage` is not a getter that throws when built without SQLite.
7+
assert.strictEqual(typeof sessionStorage, hasSQLite ? 'object' : 'undefined');
8+
assert.strictEqual(Object.hasOwn(globalThis, 'sessionStorage'), hasSQLite);

typings/internalBinding/config.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface ConfigBinding {
88
hasTracing: boolean;
99
hasNodeOptions: boolean;
1010
hasInspector: boolean;
11+
hasSQLite: boolean;
1112
noBrowserGlobals: boolean;
1213
bits: number;
1314
getDefaultLocale(): string;

0 commit comments

Comments
 (0)