Skip to content

test(plugins): move the plugins' test harnesses onto FakeHost - #597

Open
botandbang wants to merge 5 commits into
mainfrom
bnb/loc-443-plugin-tests-fakehost
Open

botandbang wants to merge 5 commits into
mainfrom
bnb/loc-443-plugin-tests-fakehost

Conversation

@botandbang

Copy link
Copy Markdown
Contributor

What and why

Fixes LOC-443.

Every first-party plugin's tests ran its own host over pipes, eleven copies of the same handshake, threads and cancel plumbing. They now use FakeHost, which the interop plugin already moved to. A plugin author outside the repo gets the same harness the first-party plugins use.

Added to FakeHost (behind test-util, no protocol change):

  • on_call(method, respond), where respond returns a Response: Answer, AnswerThenCancel (answer the call, then cancel the hook, as a host does when the user stops it mid-call) or Hold (never answer, until the hook is cancelled). on_read now goes through it.
  • Sent::wait_timeout(limit), for tests that check a hook stops.
  • send keeps a context.scratch the params already give, including null for a host without blobs, instead of always making a folder.

Removed: test_util::Canceller, which only these harnesses used.

Changed, in the plugins' tests (demos, tracklist, sound, coverart, musicbrainz, archive, plyr, soundcloud, mixcloud, youtube, interop's Traktor reader):

  • Every test keeps its name, its assertions and its Hegel generators and case counts. Only the host under it changed.
  • Each plugin's scripted service (the archive, plyr, SoundCloud, Mixcloud and YouTube upload scripts, coverart's routes, musicbrainz's busy replies) answers through on_call.
  • The publishing plugins' harnesses check on every case that the plugin called for nothing but net/fetch, as their per-call asserts did.
  • sound's and coverart's event tests hold the last event's call, so the host doesn't stop while an event handler is still reading. FakeHost's docs describe that pattern.
  • The explicit describe checks are gone: FakeHost::start already checks describe answers the manifest.

The README's "Testing a plugin" section and apps/locallibrary/CONTRIBUTING.md describe the new calls.

How it was tested

  • cargo nextest run on loclib-plugin and the 11 plugin crates: 476 passed.
  • New FakeHost tests: an_answer_then_cancel_reaches_the_plugin_first, a_held_call_waits_until_the_hook_is_cancelled, a_scratch_folder_given_is_kept, and the Hegel property prop_an_answer_reaches_the_plugin_unless_held. Each fails when its part is broken: cancelling before answering, answering a held call, wait_timeout never returning, or ignoring a given scratch folder.
  • cargo clippy --all-targets -- -D warnings on the same crates, --all-features on loclib-plugin, cargo fmt --check, and the doctests.
  • Coverage of the 12 crates (cargo llvm-cov, CI's ignore regex): 99.44% regions, 99.23% functions, 99.55% lines.

Checklist

  • Tests cover the change
  • The READMEs, docs/ and --help still say what the code does (no changelog line: tests only)

Each first-party plugin's tests ran their own host over pipes: a Peer, threads, a hello, and a Canceller to cancel a hook mid-call. They now use loclib-plugin's FakeHost. FakeHost gains on_call, whose Response can answer, answer and then cancel the hook, or hold a call unanswered until the hook is cancelled; Sent::wait_timeout; and send keeps a context.scratch the params already give (null for a host without blobs). Canceller, which only those harnesses used, is removed. The tests keep their names, assertions and Hegel properties; each publishing plugin's harness checks on every case that the plugin called for nothing but net/fetch.
…sts-fakehost

# Conflicts:
#	plugins/coverart/src/tests.rs
#	plugins/musicbrainz/src/tests.rs
#	plugins/youtube/src/tests/publishing.rs
@botandbang
botandbang requested a review from bnb as a code owner November 12, 2026 19:15
@botandbang botandbang added locallibrary: plugins The plugin protocol, its host and the built-in plugins tests Tests, fixtures and test harnesses labels Nov 12, 2026
@linear-code

linear-code Bot commented Nov 12, 2026

Copy link
Copy Markdown

LOC-443

bnb
bnb previously approved these changes Nov 12, 2026
…sts-fakehost

# Conflicts:
#	plugins/sound/Cargo.toml
#	plugins/sound/src/tests.rs
plugins/mixcloud/src/tests/publishing.rs keeps main's new test of Mixcloud's rules for the music, which needs TracklistEntry, and this branch's imports, which drop what FakeHost now does (Cancel, Manifest, method).
@github-actions github-actions Bot added documentation Improvements or additions to documentation locallibrary locallibrary and the loclib-* crates locallibrary: analysis Tempo, key and loudness from tracks' audio locallibrary: tracklists Reading tracklists and finding their tracks locallibrary: interop Libraries for Traktor, Serato and Engine DJ locallibrary: publishing The Atmosphere account, and the sets and profile published to it labels Nov 15, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation locallibrary: analysis Tempo, key and loudness from tracks' audio locallibrary: interop Libraries for Traktor, Serato and Engine DJ locallibrary: plugins The plugin protocol, its host and the built-in plugins locallibrary: publishing The Atmosphere account, and the sets and profile published to it locallibrary: tracklists Reading tracklists and finding their tracks locallibrary locallibrary and the loclib-* crates tests Tests, fixtures and test harnesses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants