Skip to content

test(locallibrary): format and eject disk images in the weekly run - #322

Open
botandbang wants to merge 5 commits into
mainfrom
bnb/disk-image-tests
Open

botandbang wants to merge 5 commits into
mainfrom
bnb/disk-image-tests

Conversation

@botandbang

Copy link
Copy Markdown
Contributor

What and why

The scheduled workflow gets a disk-images job on macOS, Linux and Windows. Each test creates a small disk image, attaches it, runs format::apply or eject against it, and detaches it. The images are hdiutil images on macOS, loop devices on Linux (run as root through sudo as nextest's target runner) and VHDs on Windows. The tests return at once unless LOCALLIBRARY_DISK_IMAGE_TESTS=1, so ordinary cargo test and PR CI never touch a device.

Added: format/disk_image.rs, a test-only guard that attaches an image and detaches it on drop (also when a test panics). It finds the device by the image's file, so it can't detach anything else, and it checks before every destructive call that the disk is the one it attached. The format test checks that an image is refused, then formats FAT32 on MBR and exFAT, checks a stale plan is refused, and checks that a drive keeps its name across a format where the system mounts the volume. The macOS eject test uses a two-partition image: eject is refused while the store is on the other partition, the plan names the other volume, and applying it detaches the image. There are also unit tests for the seam.

Changed: the format code refuses every disk image, loop device and virtual disk. A test build lets through only the one image its test attached, matched by exact identifier on that thread. On Linux this is also the only loop device parsed as a disk.

Removed: LOCALLIBRARY_FORMAT_VIRTUAL, which let format take any disk image and which nothing used.

The Linux and Windows legs, and the macOS format and eject tests, have not run yet. The first weekly or manual run of locallibrary scheduled is their first test.

Refs LOC-67 (the Linux and Windows legs and the macOS format and eject tests are unverified until the scheduled job runs)
Refs #168

How it was tested

  • cargo fmt --check -p locallibrary, and cargo clippy -p locallibrary --all-targets -- -D warnings on macOS (so the Linux and Windows modules of disk_image.rs were not compiled).
  • cargo nextest run -p locallibrary on the format and eject tests: 152 pass.
  • With LOCALLIBRARY_DISK_IMAGE_TESTS=1, an_image_is_detached_when_its_test_ends passes with a real hdiutil attach and detach. Skipping detach while panicking made it fail with "still attached".
  • The two seam unit tests fail when the seam is loosened (the virtual_disk && guard dropped, the Linux loop check forced true).
  • actionlint and zizmor --offline on the scheduled workflow, and tools/policy.sh.
  • Not run: the macOS format and eject tests (partitioning an image needs approval to run here), the Linux and Windows legs, and Windows clippy.

Checklist

  • Tests cover the change
  • For locallibrary: apps/locallibrary/CHANGELOG.md has a line under Unreleased, if people using it will notice
  • The READMEs, docs/ and --help still say what the code does

@botandbang
botandbang requested a review from bnb as a code owner October 30, 2026 16:18
@linear-code

linear-code Bot commented Oct 30, 2026

Copy link
Copy Markdown

LOC-67

bnb
bnb previously approved these changes Oct 30, 2026
@github-actions github-actions Bot added documentation Improvements or additions to documentation github_actions Pull requests that update GitHub Actions code locallibrary locallibrary and the loclib-* crates locallibrary: core The core crate, the data model and rekordbox's formats tests Tests, fixtures and test harnesses labels Oct 30, 2026
bnb
bnb previously approved these changes Oct 31, 2026
@github-actions

Copy link
Copy Markdown

Rust coverage

From run 656. Both are held to the thresholds in .cargo/config.toml.

Tests Lines Functions Regions
All 97.3% (83626/85944) 96.37% (13338/13840) 95.58% (183900/192407)
Hegel property tests alone 95.3% (81907/85944) 93.95% (13002/13840) 93.41% (179736/192407)

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 github_actions Pull requests that update GitHub Actions code locallibrary: core The core crate, the data model and rekordbox's formats 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