Skip to content

fix(test): split JPEG fixture byte chains so macOS can type-check them - #665

Merged
prakashUXtech merged 2 commits into
devfrom
fix/core-dev-build
Oct 19, 2026
Merged

prakashUXtech merged 2 commits into
devfrom
fix/core-dev-build

Conversation

@prakashUXtech

Copy link
Copy Markdown
Contributor

dev fails to compile its tests on macOS (Swift 6.1.2): JPEGReadTests.swift:211, added in #651, is a seven-term + chain of byte arrays and literals that the macOS type checker gives up on. Linux (Swift 6.3.3) compiles it fine, so the lane never saw it.

This splits it into a typed [[UInt8]] list joined once, the same fix #607 used. The bytes are unchanged. #663 added two more chains of the same shape in JPEGReadGuardTests.shortScanNamed, so those are split too before they hit the macOS job.

Tests: JPEGReadTests and JPEGReadGuardTests pass (28 tests), and swift build --build-tests is clean locally.

The FillFromSurroundings build break was already fixed on dev by #661.

@prakashUXtech
prakashUXtech merged commit fd1e553 into dev Oct 19, 2026
7 checks passed
github-actions Bot pushed a commit that referenced this pull request Oct 19, 2026
…ented, guards pinned (#681)

Anatomy round 3, IC-jpeg, batch b1. This PR fixes the eight findings from the JPEG review. It is part of #562.

## What and why

1. **Orientation calls documented.** The doc on `JPEGInfo.orientation` now lists the `PixelBuffer` calls for each EXIF value 1...8: `flipped(.horizontal)`, `rotated(.degrees180)`, `flipped(.vertical)`, transpose = `rotated(.degrees90)` then `flipped(.horizontal)`, `rotated(.degrees90)`, transverse = `rotated(.degrees270)` then `flipped(.horizontal)`, and `rotated(.degrees270)`. Proved by `JPEGReadTests.orientationCallsTurnUpright`: it applies each documented call to a 2x3 frame and compares the result with the EXIF definition.
2. **What `CodecError.unsupported` covers.** Its doc now says it covers both a file feature the codec does not read or write and an encoder option the caller asked for. `JPEG.write` says that a quality outside 1...100 is a caller argument. This change is docs only.
3. **Refusals print the values they read.** The SOF component refusal prints H, V and Tq. The n-component refusal names the count, and says CMYK/YCCK when it is 4. The missing-DQT refusals print the component id and the table. The block-bound refusal prints how many bytes come after the scan header. `pixels()` now splits "no SOF" from the sRGB transfer failure. Proved by `JPEGReadGuardTests.sofRefusalsPrintValues`, `blockBoundNamed` and `JPEGReadTests.damagedThrows`.
4. **Width 0.** Proved by `JPEGReadGuardTests.widthZero`: both info and read throw `damaged` containing "width 0". Mutation entry: CoreRaster.JPEG "SOF width 0".
5. **SOS missing-DQT refusal is observable.** It now reads "scan component 2 uses DQT 1, not defined before its scan". Exact text is asserted in `JPEGReadTests.damagedThrows`. Mutation entry: "SOS no longer refuses a component without its DQT".
6. **EXIF wrong type.** Proved by `JPEGReadGuardTests.exifOrientationWrongType`: an Orientation entry typed ASCII or LONG reads as 1, and a SHORT control reads as 6. The fixture `exif` gains a `type:` argument. Mutation entry: "EXIF Orientation type check is dropped".
7. **DHT with more than 256 values.** This case now has its own guard and message, "DHT 0x00 has 300 values (256 at most)". Proved by a new case in `JPEGReadGuardTests.badTableNamesItInHex`. Mutation entry: "DHT of over 256 values".
8. **Remaining guards pinned.** New mutation entries cover the maxSide limit, segment length under 2 (`segmentLengthUnderTwo`), SOF Tq over 3, 4-component SOF, progressive AC-before-DC, and a progressive band past 63. The band case also gets a message assertion in `JPEGReadTests.progressiveScanChecks`. `seededSOFFieldsThrow` randomises SOF fields with seeded SplitMix64 and checks that every read throws a `CodecError` or decodes.

New byte fixtures are built as lists of parts, as in #665, so the macOS type checker can handle them.

No platform or library API is new here: only Swift stdlib basics already used in these files. The docs MCP tools were not needed for that.

## Gate

`scripts/ci` printed `CI: PASS` on the head below, after rebasing on dev. `scripts/mutate --run --changed-since origin/dev` caught 33/33.

Belt-Lead: act-1a15227fc25-tkce
Feature: image-codecs
Slice: IC-jpeg
Mutate: 33/33 CoreRaster.JPEG, CoreRaster.JPEGDecode, CoreRaster.JPEGProgressive, CoreRaster.JPEGWrite, CoreRaster.StackXML
Fast-Check: pass
Head: 468358b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant