Skip to content

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

Merged
botandbang merged 6 commits into
mainfrom
bnb/disk-image-tests
Nov 1, 2026
Merged

botandbang merged 6 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

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Rust coverage

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

Tests Lines Functions Regions
All 97.38% (84403/86671) 96.51% (13503/13991) 95.66% (185837/194268)
Hegel property tests alone 95.38% (82665/86671) 94.09% (13164/13991) 93.45% (181553/194268)

bnb
bnb previously approved these changes Oct 31, 2026
# Conflicts:
#	.github/workflows/locallibrary-scheduled.yml
@botandbang

Copy link
Copy Markdown
Contributor Author

Closing and reopening so CI runs against current main (with #353's CodeQL fix). Branch unchanged.

@botandbang botandbang closed this Nov 1, 2026
auto-merge was automatically disabled November 1, 2026 16:49

Pull request was closed

@botandbang botandbang reopened this Nov 1, 2026
@botandbang botandbang closed this Nov 1, 2026
@botandbang botandbang reopened this Nov 1, 2026
@botandbang
botandbang enabled auto-merge November 1, 2026 16:50
@botandbang
botandbang added this pull request to the merge queue Nov 1, 2026
Merged via the queue into main with commit e588131 Nov 1, 2026
67 of 80 checks passed
@botandbang
botandbang deleted the bnb/disk-image-tests branch November 1, 2026 18:14
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