Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ jobs:
--arg ccache '(import <nixpkgs> {}).sccache' \
--arg devTools '[]' \
--arg benchmarkTools '[]' \
${{ endsWith(matrix.system, '-darwin') && '--arg extraConfigFlags ''["--without-amaro" "--without-inspector" "--without-node-options"]'' \' || '\' }}
${{ endsWith(matrix.system, '-darwin') && '--arg withAmaro false --arg withSQLite false --arg extraConfigFlags ''["--without-inspector" "--without-node-options"]'' \' || '\' }}
--run '
make -C "$TAR_DIR" run-ci -j4 V=1 TEST_CI_ARGS="-p actions --measure-flakiness 9 --skip-tests=$CI_SKIP_TESTS"
'
2 changes: 0 additions & 2 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,6 @@
'sources': [
'<@(node_sqlite_sources)',
],
'defines': [ 'HAVE_SQLITE=1' ],
}],
[ 'node_shared=="true" and node_module_version!="" and OS!="win"', {
'product_extension': '<(shlib_suffix)',
Expand Down Expand Up @@ -982,7 +981,6 @@
'sources': [
'<@(node_sqlite_sources)',
],
'defines': [ 'HAVE_SQLITE=1' ],
}],
[ 'OS in "linux freebsd mac solaris openharmony" and '
'target_arch=="x64" and '
Expand Down
5 changes: 5 additions & 0 deletions node.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -436,5 +436,10 @@
}, {
'defines': [ 'HAVE_AMARO=0' ]
}],
[ 'node_use_sqlite=="true"', {
'defines': [ 'HAVE_SQLITE=1' ],
}, {
'defines': [ 'HAVE_SQLITE=0' ]
}],
],
}
2 changes: 1 addition & 1 deletion src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
"experimental Web Storage API",
&EnvironmentOptions::webstorage,
kAllowedInEnvvar,
true);
HAVE_SQLITE);
AddAlias("--webstorage", "--experimental-webstorage");
AddOption("--localstorage-file",
"file used to persist localStorage data",
Expand Down
2 changes: 1 addition & 1 deletion src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class EnvironmentOptions : public Options {
bool experimental_fetch = true;
bool experimental_websocket = true;
bool experimental_sqlite = true;
bool webstorage = true;
bool webstorage = HAVE_SQLITE;
#ifndef OPENSSL_NO_QUIC
bool experimental_quic = false;
#endif
Expand Down
4 changes: 3 additions & 1 deletion test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ const knownGlobals = new Set([
'CompressionStream',
'DecompressionStream',
'Storage',
'sessionStorage',
].forEach((i) => {
if (globalThis[i] !== undefined) {
knownGlobals.add(globalThis[i]);
Expand All @@ -387,6 +386,9 @@ if (hasCrypto) {
if (hasLocalStorage) {
knownGlobals.add(globalThis.localStorage);
}
if (hasSQLite) {
knownGlobals.add(globalThis.sessionStorage);
}

const { Worker } = require('node:worker_threads');
knownGlobals.add(Worker);
Expand Down
5 changes: 4 additions & 1 deletion test/module-hooks/test-module-hooks-builtin-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ const { registerHooks } = require('module');

const schemelessBlockList = new Set([
'sea',
'sqlite',
'test',
'test/reporters',
]);

if (common.hasSQLite) {
schemelessBlockList.add('sqlite');
}

const testModules = [];
for (const mod of schemelessBlockList) {
testModules.push(`node:${mod}`);
Expand Down
5 changes: 4 additions & 1 deletion test/module-hooks/test-module-hooks-load-builtin-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ hook.deregister();
// stripped for internal lookups should not get passed into the hooks.
const schemelessBlockList = new Set([
'sea',
'sqlite',
'test',
'test/reporters',
]);

if (common.hasSQLite) {
schemelessBlockList.add('sqlite');
}

const testModules = [];
for (const mod of schemelessBlockList) {
testModules.push(`node:${mod}`);
Expand Down
62 changes: 19 additions & 43 deletions test/parallel/test-cli-node-options-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,10 @@ for (const [, envVar] of manPageText.matchAll(/\.It Fl (-[a-zA-Z0-9._-]+)/g)) {
}

for (const [, envVar, config] of nodeOptionsCC.matchAll(addOptionRE)) {
let hasTrueAsDefaultValue = false;
let isInNodeOption = false;
let isV8Option = false;
let isNoOp = false;

if (config.includes('NoOp{}')) {
isNoOp = true;
}

if (config.includes('kAllowedInEnvvar')) {
isInNodeOption = true;
}
if (config.includes('kDisallowedInEnvvar')) {
isInNodeOption = false;
}

if (config.includes('V8Option{}')) {
isV8Option = true;
}

if (/^\s*true\s*$/.test(config.split(',').pop())) {
hasTrueAsDefaultValue = true;
}

// Exception for HAVE_AMARO conditional default (defaults to true when Amaro is available)
if (config.includes('HAVE_AMARO')) {
hasTrueAsDefaultValue = true;
}
const hasTrueAsDefaultValue = /,\s*(?:true|HAVE_[A-Z_]+)\s*$/.test(config);
const isInNodeOption = config.includes('kAllowedInEnvvar') && !config.includes('kDisallowedInEnvvar');
const isV8Option = config.includes('V8Option{}');
const isNoOp = config.includes('NoOp{}');

if (
envVar.startsWith('[') ||
Expand All @@ -79,50 +55,50 @@ for (const [, envVar, config] of nodeOptionsCC.matchAll(addOptionRE)) {
}

// Internal API options are documented in /doc/contributing/internal-api.md
if (new RegExp(`####.*\`${envVar}[[=\\s\\b\`]`).test(internalApiText) === true) {
if (new RegExp(`####.*\`${RegExp.escape(envVar)}[[=\\s\\b\`]`).test(internalApiText)) {
manPagesOptions.delete(envVar.slice(1));
continue;
}

// CLI options
if (!isV8Option && !hasTrueAsDefaultValue) {
if (new RegExp(`###.*\`${envVar}[[=\\s\\b\`]`).test(cliText) === false) {
assert(false, `Should have option ${envVar} documented`);
if (!new RegExp(`###.*\`${RegExp.escape(envVar)}[[=\\s\\b\`]`).test(cliText)) {
assert.fail(`Should have option ${envVar} documented`);
} else {
manPagesOptions.delete(envVar.slice(1));
}
}

if (!hasTrueAsDefaultValue && new RegExp(`###.*\`--no${envVar.slice(1)}[[=\\s\\b\`]`).test(cliText) === true) {
assert(false, `Should not have option --no${envVar.slice(1)} documented`);
if (!hasTrueAsDefaultValue && new RegExp(`###.*\`--no${RegExp.escape(envVar.slice(1))}[[=\\s\\b\`]`).test(cliText)) {
assert.fail(`Should not have option --no${envVar.slice(1)} documented`);
}

if (!isV8Option && hasTrueAsDefaultValue) {
if (new RegExp(`###.*\`--no${envVar.slice(1)}[[=\\s\\b\`]`).test(cliText) === false) {
assert(false, `Should have option --no${envVar.slice(1)} documented`);
if (!new RegExp(`###.*\`--no${RegExp.escape(envVar.slice(1))}[[=\\s\\b\`]`).test(cliText)) {
assert.fail(`Should have option --no${envVar.slice(1)} documented`);
} else {
manPagesOptions.delete(`-no${envVar.slice(1)}`);
}
}

// NODE_OPTIONS
if (isInNodeOption && !hasTrueAsDefaultValue &&
new RegExp(`\`${envVar}\``).test(nodeOptionsText) === false) {
assert(false, `Should have option ${envVar} in NODE_OPTIONS documented`);
!new RegExp(`\`${RegExp.escape(envVar)}\``).test(nodeOptionsText)) {
assert.fail(`Should have option ${envVar} in NODE_OPTIONS documented`);
}

if (isInNodeOption && hasTrueAsDefaultValue && new RegExp(`\`--no${envVar.slice(1)}\``).test(cliText) === false) {
assert(false, `Should have option --no${envVar.slice(1)} in NODE_OPTIONS documented`);
if (isInNodeOption && hasTrueAsDefaultValue && !new RegExp(`\`--no${RegExp.escape(envVar.slice(1))}\``).test(cliText)) {
assert.fail(`Should have option --no${envVar.slice(1)} in NODE_OPTIONS documented`);
}

if (!hasTrueAsDefaultValue && new RegExp(`\`--no${envVar.slice(1)}\``).test(cliText) === true) {
assert(false, `Should not have option --no${envVar.slice(1)} in NODE_OPTIONS documented`);
if (!hasTrueAsDefaultValue && new RegExp(`\`--no${RegExp.escape(envVar.slice(1))}\``).test(cliText)) {
assert.fail(`Should not have option --no${envVar.slice(1)} in NODE_OPTIONS documented`);
}

// V8 options
if (isV8Option) {
if (new RegExp(`###.*\`${envVar}[[=\\s\\b\`]`).test(v8OptionsText) === false) {
assert(false, `Should have option ${envVar} in V8 options documented`);
if (!new RegExp(`###.*\`${RegExp.escape(envVar)}[[=\\s\\b\`]`).test(v8OptionsText)) {
assert.fail(`Should have option ${envVar} in V8 options documented`);
} else {
manPagesOptions.delete(envVar.slice(1));
}
Expand Down
5 changes: 3 additions & 2 deletions test/parallel/test-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ for (const moduleName of builtinModules) {
'fetch',
'crypto',
'navigator',
'localStorage',
'sessionStorage',
];
if (common.hasSQLite) {
expected.push('localStorage', 'sessionStorage');
}
assert.deepStrictEqual(new Set(Object.keys(globalThis)), new Set(expected));
expected.forEach((value) => {
const desc = Object.getOwnPropertyDescriptor(globalThis, value);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-sqlite-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
const { skipIfSQLiteMissing } = require('../common/index.mjs');
const { test } = require('node:test');
const assert = require('node:assert');
const { DatabaseSync } = require('node:sqlite');
skipIfSQLiteMissing();
const { DatabaseSync } = require('node:sqlite');

function checkDefensiveMode(db) {
function journalMode() {
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-sqlite-template-tag.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';
require('../common');
const { skipIfSQLiteMissing } = require('../common');
skipIfSQLiteMissing();

const assert = require('assert');
const { DatabaseSync } = require('node:sqlite');
const { test, beforeEach } = require('node:test');
Expand Down
8 changes: 8 additions & 0 deletions test/parallel/test-webstorage-without-sqlite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

const { hasSQLite } = require('../common');
const assert = require('node:assert');

// Ensuring that `sessionStorage` is not a getter that throws when built without SQLite.
assert.strictEqual(typeof sessionStorage, hasSQLite ? 'object' : 'undefined');
assert.strictEqual(Object.hasOwn(globalThis, 'sessionStorage'), hasSQLite);
1 change: 1 addition & 0 deletions typings/internalBinding/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface ConfigBinding {
hasTracing: boolean;
hasNodeOptions: boolean;
hasInspector: boolean;
hasSQLite: boolean;
noBrowserGlobals: boolean;
bits: number;
getDefaultLocale(): string;
Expand Down
Loading