diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-09-18 11:10:00 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-09-18 11:10:00 +0200 |
| commit | 0d56cd33b975afe7648dd6f6380a30a7b5230c90 (patch) | |
| tree | 1244665a98f34ba4988f5d2c6e25bfb147481ded /packages/meshbay-hub/tests/test_cast_subtitles.py | |
| parent | 063c5f0750b775362e45e21a97e0dc2250c89f77 (diff) | |
| download | meshbay-0d56cd33b975afe7648dd6f6380a30a7b5230c90.tar.gz | |
fix(cast): put the relay's progress log behind the same switch
Most of what the relay says repeats without bound — a line every fiftieth
fragment for the length of a film, one per dropped fragment whenever a client
falls behind — and it lands in the terminal the app was started from. Those go
through `debuglog` now, restored with:
NODE_DEBUG=cast-relay npm start
The loss of fMP4 framing stays on console.warn. It recovers by rescanning, so
nothing throws and no other part of the system hears about it; that line is the
only trace that the picture on the television is missing a piece. Every other
failure here throws, and the renderer already reports the rejection.
The logging guard now covers both cast modules, each with the one line it is
meant to keep audible.
Also corrects the header comment, which still claimed CORS was granted on the
subtitle path only. It has been on both since the stream needed it too.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UGY17EPph5LsLzePPXhUVc
Diffstat (limited to 'packages/meshbay-hub/tests/test_cast_subtitles.py')
| -rw-r--r-- | packages/meshbay-hub/tests/test_cast_subtitles.py | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/packages/meshbay-hub/tests/test_cast_subtitles.py b/packages/meshbay-hub/tests/test_cast_subtitles.py index 3fe627d..fdf7fcc 100644 --- a/packages/meshbay-hub/tests/test_cast_subtitles.py +++ b/packages/meshbay-hub/tests/test_cast_subtitles.py @@ -393,28 +393,47 @@ def test_a_stream_without_subtitles_declares_none(loaded): assert loaded["without"]["options"]["activeTrackIds"] == [] -@chromecast_only -def test_progress_logging_is_off_unless_asked_for(): +# Anything that reaches the terminal whatever the user asked for. `warn` and +# `info` are named alongside `log` because a future line using either would be +# exactly as loud, and a guard that names only `log` would not see it. +LOUD = ("console.log(", "console.warn(", "console.info(") + +# The one line per module that is deliberately audible, and why. Each names a +# fault that nothing else in the system reports: a cast that goes quiet, or a +# television showing a picture with a hole in it. Both are the kind of thing +# somebody has to be told about without knowing in advance to ask. +DELIBERATELY_AUDIBLE = { + "cast-chromecast.js": "console.error(`[cast-chromecast] client error", + "cast-relay.js": "console.warn(`[cast-relay] box sync lost", +} + + +@pytest.mark.parametrize("path", [CHROMECAST, RELAY], ids=lambda p: p.name) +def test_progress_logging_is_off_unless_asked_for(path): """ - The receiver reports its state on a timer, so `player status: PLAYING` - repeats for as long as a film runs. Left on `console.log` it fills the - terminal the app was started from and buries everything else in it. + Casting talks constantly and says almost nothing. The receiver reports its + state on a timer, so `player status: PLAYING` repeats for as long as a film + runs; the relay logs every fiftieth fragment, and one line per dropped + fragment whenever a client falls behind. All of it lands in the terminal the + app was started from, and buries whatever was worth reading there. - Read rather than run because the noisy line only fires with a device on the - network. What is checked is the property that matters: nothing in this - module reaches the terminal unconditionally except a failure. `console.warn` - and `console.info` are named too — a future line using either would be just - as loud, and this guard would not otherwise see it. + Read rather than run because the noisy lines need a device on the network to + fire at all. What is asserted is the property that survives that: the only + thing either module says unbidden is the failure it alone can report. """ - src = CHROMECAST.read_text(encoding="utf-8") + if not path.exists(): + pytest.skip("desktop client sources not present") + src = path.read_text(encoding="utf-8") + audible = DELIBERATELY_AUDIBLE[path.name] + unconditional = [ line.strip() for line in src.splitlines() - if ("console.log(" in line or "console.warn(" in line - or "console.info(" in line) - and not line.lstrip().startswith(("*", "//"))] + if any(token in line for token in LOUD) + and not line.lstrip().startswith(("*", "//")) + and audible not in line] assert unconditional == [], ( "these reach the terminal whatever the user asked for; route them " - f"through `debug` or `console.error`: {unconditional}") - # And the failure path is still audible, or a cast that dies takes its own - # explanation with it. - assert "console.error(`[cast-chromecast] client error" in src + f"through `debug`: {unconditional}") + + assert audible in src, ( + f"{path.name} no longer reports the one fault nothing else does") |