Ampify
English

Testing

Unit tests cover the portable code (commands in building.md). What happens inside Apple Music needs the Windows bench, which runs unattended in CI, and a pass on a real PC for sound and looks.

CI

.github/workflows/ci.yml runs on each push to dev that touches code, schemas, knowledge, docs, scripts or the bench (not bench/windows/live/), and by hand from the Actions tab. A new push cancels the run in progress; the compiler caches are saved anyway, so the next run starts from them.

Job What it does
What changed Compares the push with the previous dev. Only docs/, knowledge/, tools/ or top-level .md files: the Windows jobs and the bench are skipped, the Linux job still runs
Unit tests (Linux) ampify_tests, then the Python and Node tests and the linter against the Linux ampify
Unit tests (Windows, MSVC) ampify_tests
Build the release kit, Build the bench kit The two MSVC kits with XAML, in parallel
Split the bench cases, Bench (group 1 to 6) bench/windows/shards.sh reads the case ids from the case files and deals them over six runners, each with its own Apple Music. A new case needs no edit in ci.yml

The release build injects only on tested versions. The bench build (AMPIFY_BENCH=ON) accepts the version installed on the runner. Results are in the job summary and an artifact: report.md, results.json, winget.log, preparation.txt, and per case the Ampify logs and screenshots. The report records the runner image (ImageOS, ImageVersion).

The pre-push hook runs python -m unittest test_validate test_pack in tools/ (install jsonschema so the reference comparison runs) and node --test test_examples.mjs. The full list of commands is in building.md.

Writing a unit test

tests/test.hpp is the harness: TEST_CASE, CHECK, CHECK_NEAR, REQUIRE (reports and ends the case, for a precondition) and SKIP(reason) (ends the case as not run; the summary counts skips apart). Shared helpers are in tests/support.hpp:

Piece Use
ScratchDir An empty folder under a per-run root (%TEMP%\ampify-tests-<pid>), removed with the object
ManifestSpec, ElementFolder, WriteElement An element folder with a manifest.json written from named fields
ElementFixture<H> Elements running against a host H, with the journal on a string
KernelFixture, KitFixture The loader with its host, hosts, settings and journal, over a kit folder
LanguageScope Sets the interface language and puts the previous one back
Sine, Stereo, Clicks, ToneWithClicks Test signals

Other shared headers: fake_host.hpp, service_host.hpp, pump.hpp, replay_support.hpp. A new required manifest field is one edit in ManifestJson, not one per test file. Windows-only tests are in tests/win/. Test data is in tests/data/.

The bench

The runner installs Apple Music with winget, then runs bench/windows/run-bench.ps1. Cases are bench/windows/cases/NN-name.ps1, run in name order: launch and version gate (10 to 31), safe mode (40), CLI tools, installer, hello extension and Atmos leveler (50, 51), then the interface cases (60 to 66).

Status Meaning
PASS Verified
FAIL Does not work; the job fails
INFO A finding with no verdict
SKIP Impossible on this runner, with the reason. Does not fail the job

A case lists its needs with -Requires: apple-music, apple-account (needs AMPIFY_SIGNED_IN=true), and kit parts kit:release, kit:bench, kit:ui, kit:cli, laid out by scripts/bench-kit.ps1. If Apple Music does not install on the runner, the app cases are skipped and the job stays green, so read the summary and winget.log. A missing kit part fails the case, since that is a broken build. -Only with an unknown id stops the bench and lists the known ids.

On a PC, not one where you use Apple Music: the bench kills it and empties %USERPROFILE%\Ampify\logs and state.txt.

pwsh -File bench\windows\run-bench.ps1 -KitRoot <folder with release\ and bench\> -RepoRoot <repository> -OutputRoot <folder>

Options: -Only <id>,..., -SkipInstall, -CasesDir (another case folder, relative to the script).

Six cases need no Apple Music: in 65-ui-features.ps1 ui-hover-sidebar, ui-bar-position, ui-compact-sidebar, ui-current-lyrics, and in 66-ui-release.ps1 ui-lyrics-window, ui-builtin-layouts. They ask the UI build’s ampify.exe, in a temporary --kit-dir, whether a setting takes its value and whether a snippet or theme is valid, so they run in seconds. Whether the look is right is checked on a PC.

The ui-inspector case reports the stable names it finds in no tree as INFO. It opens no page, so names of the lyrics, the queue or the full-screen player are missing from its tree.

Add a case

# What the case checks, in one sentence.

Register-Case -Id 'my-case' -Title 'Sentence that says what is checked' -Requires 'apple-music', 'kit:bench' -Action {
    param($Ctx)

    Reset-KitState
    $launcher = Join-Path $script:BenchKitRoot 'bench\ampify_launcher.exe'
    $launcherProcess = Start-Launcher -LauncherPath $launcher

    $launched = Wait-Journal -FileName 'launcher.log' -Text 'Apple Music started' -TimeoutSeconds 120
    Add-Check -Ctx $Ctx -Name 'Apple Music started' -Passed $launched

    Close-AppleMusic | Out-Null
    Add-Check -Ctx $Ctx -Name 'launcher stopped' -Passed ($launcherProcess.WaitForExit(15000))
}

Helpers in bench/windows/lib/harness.ps1 include Reset-KitState, Start-Launcher, Start-AppNormally, Wait-Journal, Test-JournalContains, Find-JournalMatch, Get-KernelState, Get-AppCrashEvents, Save-Screenshot, Close-AppleMusic, Set-SafeModeCount, Get-SafeModeCount, Clear-FirstRun, and Set-Settings with Save-Settings and Restore-Settings (the one writer of settings.txt). UI Automation helpers are in bench/windows/lib/ui.ps1 (Find-UiById, Find-UiByName, Invoke-UiElement, Show-UiAppWindow).

Signed-in bench

bench/windows/live/ holds cases that play music with the kernel in a signed-in Apple Music: audio-output, ui-tree and playback-with-kit. They need an Apple account with a subscription and no workflow runs them. Run them with run-bench.ps1 -CasesDir live\cases, or scripts\listen-test.ps1. On a machine without a sound card, audio-output needs a virtual output (VB-CABLE or Scream). Helpers are in bench/windows/live/lib/uia.ps1 (Find-Element, Invoke-Click, Set-Text, Send-Key, Get-TreeDump) and audio.ps1.

scripts\listen-test.ps1 lays out the kit from existing builds (run build-msvc.ps1 with and without -Bench first), sets Apple Music’s Dolby Atmos setting to “Always on”, plays “Take Five” (stereo) and “bad guy” (Dolby Atmos) for about 45 s each with the leveler, and writes results\report.md. -Storefront sets the account’s country (fr by default).

Lessons from these scripts:

Coverage

Visual Studio’s code coverage console measures ampify_tests.exe (no admin; the path depends on your Visual Studio version):

& "C:\Program Files\Microsoft Visual Studio\18\Community\Common7\IDE\Extensions\Microsoft\CodeCoverage.Console\Microsoft.CodeCoverage.Console.exe" collect --output coverage.cobertura.xml --output-format cobertura --nologo build-msvc\release\ampify_tests.exe

The Cobertura file lists every line of src/ with its hits. A line that runs is not a line that is checked.

Test pass on a PC

You need Apple Music signed in, headphones or speakers, and a few Dolby Atmos songs.

  1. Close Apple Music and install Ampify (install line or ampify_setup.exe).
  2. Open Apple Music from its icon. The sidebar ends with an “Ampify” entry, and Settings has an “Ampify” row that opens Ampify’s settings page. Take a screenshot of the page.
  3. In the Marketplace, use Glass, then Artwork with a song playing, then “Restore Apple Music’s look”.
  4. Switch on the Atmos leveler under Sound (Sound and extensions tab) in Ampify’s settings, then play a stereo song and three Atmos songs for 30 seconds each at a fixed volume. The loudness should stay about the same.
  5. ampify restore, restart Apple Music: no Ampify entry. ampify apply, restart: it is back.
  6. Uninstall from Settings > Apps, keep the settings, and check that Apple Music opens and plays as before.

Send back the %USERPROFILE%\Ampify\logs\ folder (read it first: it holds Windows paths with the user name), the screenshots, and what looked wrong. ampify report packs it all, masked.

What the logs should show:

Debugging tips

& "${env:ProgramFiles(x86)}\Windows Kits\10\Debuggers\x64\cdb.exe" -z build-msvc\bench\ampify_kernel.dll `
    -y build-msvc\bench -c "ln ampify_kernel+0x13a1d; q"

Crash dumps, when Windows keeps them, are in %LOCALAPPDATA%\CrashDumps. A later build moves the code, so keep the build that crashed.