chore(tests): silence three noisy warnings in deploy-gate output
deploy.sh's vitest + pytest output was polluted with three benign
but loud warnings that buried real signal:
1. AVRSimulator.start() unconditionally read `window.__spiceDebug`.
In node-side vitest runs `window` is undefined → ReferenceError
→ console.warn('[spice] debug dump failed', e). Logged once per
AVR test. Guarded with `typeof window !== 'undefined'`; in
production the browser path is unchanged.
2. pinPositionCalculator.calculatePinPosition() warned every time
document.getElementById returned null. In node-side tests there
is no real DOM and every wire-related test triggers the warning
for every component. Skip the console.warn when
import.meta.env.MODE === 'test' (vitest sets MODE=test); the
function still returns null and production retains the
actionable warning for unmounted components.
3. test_esp32_wifi_args.py::test_start_instance_accepts_wifi_params
mocked asyncio.create_task with no side_effect, so the coroutine
from self._boot(...) leaked and triggered a "coroutine never
awaited" RuntimeWarning. Mock now closes the coroutine.
After fixes:
frontend tests: 0 spice/pinPositionCalculator stderr lines
backend tests: 259 passed, 15 skipped, 1 warning (starlette
third-party python_multipart deprecation —
not ours, fixed when starlette updates).
This commit is contained in:
parent
b189986a57
commit
04ac1bf53b
|
|
@ -508,12 +508,12 @@ export class AVRSimulator {
|
||||||
|
|
||||||
this.running = true;
|
this.running = true;
|
||||||
console.log('Starting AVR simulation...');
|
console.log('Starting AVR simulation...');
|
||||||
try {
|
// Browser-only debug hook. Guarded so node-side vitest runs don't
|
||||||
|
// ReferenceError on `window` and spam stderr.
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
const dbg = (window as unknown as { __spiceDebug?: () => void }).__spiceDebug;
|
const dbg = (window as unknown as { __spiceDebug?: () => void }).__spiceDebug;
|
||||||
if (typeof dbg === 'function') dbg();
|
if (typeof dbg === 'function') dbg();
|
||||||
else console.warn('[spice] __spiceDebug not attached — startSimulation never called');
|
else console.warn('[spice] __spiceDebug not attached — startSimulation never called');
|
||||||
} catch (e) {
|
|
||||||
console.warn('[spice] debug dump failed', e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ATmega328p @ 16MHz
|
// ATmega328p @ 16MHz
|
||||||
|
|
|
||||||
|
|
@ -37,14 +37,23 @@ export function calculatePinPosition(
|
||||||
// Get the DOM element
|
// Get the DOM element
|
||||||
const element = document.getElementById(componentId);
|
const element = document.getElementById(componentId);
|
||||||
if (!element) {
|
if (!element) {
|
||||||
|
// Don't spam the vitest log: in node-side tests there's no real
|
||||||
|
// DOM and this function gets called per-wire on every render
|
||||||
|
// (each one logs "Component foo not found in DOM"). In a browser
|
||||||
|
// the warning is actionable — a wire references a component that
|
||||||
|
// failed to mount.
|
||||||
|
if (import.meta.env.MODE !== 'test') {
|
||||||
console.warn(`[pinPositionCalculator] Component ${componentId} not found in DOM`);
|
console.warn(`[pinPositionCalculator] Component ${componentId} not found in DOM`);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Access the pinInfo property (all wokwi-elements expose this)
|
// Access the pinInfo property (all wokwi-elements expose this)
|
||||||
const pinInfo = (element as any).pinInfo;
|
const pinInfo = (element as any).pinInfo;
|
||||||
if (!pinInfo || !Array.isArray(pinInfo)) {
|
if (!pinInfo || !Array.isArray(pinInfo)) {
|
||||||
|
if (import.meta.env.MODE !== 'test') {
|
||||||
console.warn(`[pinPositionCalculator] Component ${componentId} does not have pinInfo`);
|
console.warn(`[pinPositionCalculator] Component ${componentId} does not have pinInfo`);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,8 +101,18 @@ class TestEspQemuManagerWifiArgs(unittest.TestCase):
|
||||||
"""start_instance should accept wifi_enabled and wifi_hostfwd_port."""
|
"""start_instance should accept wifi_enabled and wifi_hostfwd_port."""
|
||||||
from app.services.esp_qemu_manager import EspQemuManager
|
from app.services.esp_qemu_manager import EspQemuManager
|
||||||
mgr = EspQemuManager()
|
mgr = EspQemuManager()
|
||||||
# Should not raise
|
|
||||||
with patch('asyncio.create_task'):
|
# start_instance calls `asyncio.create_task(self._boot(...))`. The
|
||||||
|
# `_boot(...)` call creates a coroutine BEFORE create_task sees it,
|
||||||
|
# so simply mocking create_task with no side-effect lets the
|
||||||
|
# coroutine leak and trigger a "coroutine never awaited"
|
||||||
|
# RuntimeWarning in the test log. Close the coroutine inside the
|
||||||
|
# mock to consume it cleanly.
|
||||||
|
def consume_coroutine(coro):
|
||||||
|
coro.close()
|
||||||
|
return MagicMock()
|
||||||
|
|
||||||
|
with patch('asyncio.create_task', side_effect=consume_coroutine):
|
||||||
mgr.start_instance(
|
mgr.start_instance(
|
||||||
'test-client', 'esp32', MagicMock(),
|
'test-client', 'esp32', MagicMock(),
|
||||||
firmware_b64=None,
|
firmware_b64=None,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue