fix: keep command-line debug session-only
This commit is contained in:
parent
fe912c9659
commit
a00207d86e
|
|
@ -219,7 +219,7 @@
|
||||||
const settings = await App.GetAppSettings();
|
const settings = await App.GetAppSettings();
|
||||||
debug.log('[App] checkVault: GetAppSettings returned', settings);
|
debug.log('[App] checkVault: GetAppSettings returned', settings);
|
||||||
flog('checkVault: GetAppSettings returned');
|
flog('checkVault: GetAppSettings returned');
|
||||||
if (settings?.debug) debug.enable();
|
if (settings?.debug) debug.enable({ persist: false });
|
||||||
|
|
||||||
debug.log('[App] checkVault: calling GetVaultStatus...');
|
debug.log('[App] checkVault: calling GetVaultStatus...');
|
||||||
vaultStatus = await App.GetVaultStatus() || { status: 'unknown', path: '', vaultId: '' };
|
vaultStatus = await App.GetVaultStatus() || { status: 'unknown', path: '', vaultId: '' };
|
||||||
|
|
|
||||||
|
|
@ -127,9 +127,11 @@ export var debug = {
|
||||||
log: log,
|
log: log,
|
||||||
logf: logf,
|
logf: logf,
|
||||||
isEnabled: function () { return ENABLED; },
|
isEnabled: function () { return ENABLED; },
|
||||||
enable: function () {
|
enable: function (options) {
|
||||||
ENABLED = true;
|
ENABLED = true;
|
||||||
try { localStorage.setItem('verstak-debug', 'true'); } catch (e) {}
|
if (!options || options.persist !== false) {
|
||||||
|
try { localStorage.setItem('verstak-debug', 'true'); } catch (e) {}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
disable: function () {
|
disable: function () {
|
||||||
ENABLED = false;
|
ENABLED = false;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import path from 'node:path';
|
||||||
|
import vm from 'node:vm';
|
||||||
|
|
||||||
|
const source = fs.readFileSync(path.resolve('frontend/src/lib/log/debug.js'), 'utf8');
|
||||||
|
const values = new Map();
|
||||||
|
const localStorage = {
|
||||||
|
getItem(key) { return values.has(key) ? values.get(key) : null; },
|
||||||
|
setItem(key, value) { values.set(key, String(value)); },
|
||||||
|
removeItem(key) { values.delete(key); },
|
||||||
|
};
|
||||||
|
const context = vm.createContext({
|
||||||
|
console: { log() {} },
|
||||||
|
localStorage,
|
||||||
|
window: { location: { search: '' } },
|
||||||
|
});
|
||||||
|
const module = new vm.SourceTextModule(source, { context, identifier: 'debug.js' });
|
||||||
|
await module.link(() => { throw new Error('debug.js must not import modules'); });
|
||||||
|
await module.evaluate();
|
||||||
|
|
||||||
|
const { debug } = module.namespace;
|
||||||
|
debug.enable({ persist: false });
|
||||||
|
|
||||||
|
assert.equal(debug.isEnabled(), true, 'session debug should enable diagnostics');
|
||||||
|
assert.equal(
|
||||||
|
localStorage.getItem('verstak-debug'),
|
||||||
|
null,
|
||||||
|
'a --debug session must not make diagnostics persist into ordinary launches',
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log('debug mode smoke passed');
|
||||||
|
|
@ -43,6 +43,10 @@ WAILS_BINDINGS_STATUS=0
|
||||||
(cd "$ROOT" && node frontend/tests/wails-bindings-test.mjs) || WAILS_BINDINGS_STATUS=$?
|
(cd "$ROOT" && node frontend/tests/wails-bindings-test.mjs) || WAILS_BINDINGS_STATUS=$?
|
||||||
report "Wails notification bindings" "$WAILS_BINDINGS_STATUS"
|
report "Wails notification bindings" "$WAILS_BINDINGS_STATUS"
|
||||||
|
|
||||||
|
DEBUG_MODE_STATUS=0
|
||||||
|
(cd "$ROOT" && node --experimental-vm-modules frontend/tests/debug-mode-test.mjs) || DEBUG_MODE_STATUS=$?
|
||||||
|
report "session-only debug mode" "$DEBUG_MODE_STATUS"
|
||||||
|
|
||||||
# ── Frontend tests ──
|
# ── Frontend tests ──
|
||||||
echo "[frontend]"
|
echo "[frontend]"
|
||||||
if ensure_npm_deps "$ROOT/frontend"; then
|
if ensure_npm_deps "$ROOT/frontend"; then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue