aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/tests/test_platform.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-10-07 09:41:18 +0200
committerChristophe Besson <cbesson@gmail.com>2026-10-07 09:41:18 +0200
commitc1f9b0e324c2c47d832e21e5086f09e000d77eb5 (patch)
tree3191cb484619dc2fb3b030f59069fda8f8a885bc /packages/meshbay-node/tests/test_platform.py
parent0572bbde72514a9584b19fe031a03d4c9b23d74c (diff)
downloadmeshbay-c1f9b0e324c2c47d832e21e5086f09e000d77eb5.tar.gz
fix(node): prefer the bundled ffmpeg over PATH in the frozen build
shutil.which never looks beside meshbay-node.exe, and node-runtime is appended to the user PATH, so any earlier ffmpeg.exe on PATH ran instead of the pinned copy. Log the resolved media tools at startup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/tests/test_platform.py')
-rw-r--r--packages/meshbay-node/tests/test_platform.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/test_platform.py b/packages/meshbay-node/tests/test_platform.py
index 8856962..4805d8a 100644
--- a/packages/meshbay-node/tests/test_platform.py
+++ b/packages/meshbay-node/tests/test_platform.py
@@ -83,6 +83,42 @@ def test_check_media_tools_stores_the_resolved_paths(monkeypatch):
assert plat.ffprobe_cmd() == "/opt/bin/ffprobe.exe"
+
+def _frozen_with_bundled_tools(monkeypatch, tmp_path, platform="win32"):
+ suffix = ".exe" if platform == "win32" else ""
+ for tool in ("ffmpeg", "ffprobe"):
+ (tmp_path / f"{tool}{suffix}").write_bytes(b"")
+ monkeypatch.setattr(sys, "frozen", True, raising=False)
+ monkeypatch.setattr(sys, "executable", str(tmp_path / f"meshbay-node{suffix}"))
+ monkeypatch.setattr(sys, "platform", platform)
+ monkeypatch.setattr(plat.shutil, "which", lambda n: f"/elsewhere/{n}.exe")
+
+
+@pytest.mark.parametrize("platform", ["win32", "linux"])
+def test_a_frozen_node_prefers_the_ffmpeg_shipped_beside_it_over_path(
+ monkeypatch, tmp_path, platform):
+ _frozen_with_bundled_tools(monkeypatch, tmp_path, platform)
+ plat.check_media_tools("ffmpeg", "ffprobe")
+ suffix = ".exe" if platform == "win32" else ""
+ assert plat.ffmpeg_cmd() == str(tmp_path / f"ffmpeg{suffix}")
+ assert plat.ffprobe_cmd() == str(tmp_path / f"ffprobe{suffix}")
+
+
+def test_a_frozen_node_keeps_an_explicit_tool_path(monkeypatch, tmp_path):
+ _frozen_with_bundled_tools(monkeypatch, tmp_path)
+ plat.check_media_tools("C:/tools/ffmpeg.exe", "ffprobe")
+ assert plat.ffmpeg_cmd().startswith("/elsewhere/")
+ assert plat.ffprobe_cmd() == str(tmp_path / "ffprobe.exe")
+
+
+def test_a_frozen_node_without_bundled_tools_falls_back_to_path(monkeypatch, tmp_path):
+ monkeypatch.setattr(sys, "frozen", True, raising=False)
+ monkeypatch.setattr(sys, "executable", str(tmp_path / "meshbay-node.exe"))
+ monkeypatch.setattr(plat.shutil, "which", lambda n: f"/opt/bin/{n}.exe")
+ plat.check_media_tools("ffmpeg", "ffprobe")
+ assert plat.ffmpeg_cmd() == "/opt/bin/ffmpeg.exe"
+
+
# ── Event loop ───────────────────────────────────────────────────────────────
def test_configure_event_loop_is_a_noop_off_windows(monkeypatch):