diff options
Diffstat (limited to 'packages/meshbay-hub')
| -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") |