Skip to content

Test that reusing or cancelling an image view interrupts the request - #429

Merged
o-nnerb merged 3 commits into
mainfrom
image-cancel-tests
Oct 18, 2026
Merged

o-nnerb merged 3 commits into
mainfrom
image-cancel-tests

Conversation

@o-nnerb

@o-nnerb o-nnerb commented Oct 18, 2026

Copy link
Copy Markdown
Member

What

Tests that a reused or cancelled image view interrupts its request. (Audit E18, the "UIKit, AppKit and WatchKit integrations were not read" part.) Tests only, no source change.

The tests that existed show that the completion does not fire once a load is superseded or cancelled. That does not show the request stopped: the stub was a sleep that finished on its own. The new ones use a task that sleeps for 60 s and records that it was cancelled, and wait for that with eventually (bounded):

  • reusingTheImageViewInterruptsTheRequestOfThePreviousLoad: a second setImage on the same view interrupts the first request.
  • cancelInterruptsTheRequestOfThePendingLoad: cancel() does.

For UIImageView and NSImageView.

What reading the three integrations showed

UIImageView, NSImageView and WKInterfaceImage are the same code apart from the types:

  • every setImage cancels the load in flight on that view first, and cancel() is public;
  • there is no automatic cancellation when a view goes away or a cell is reused without calling setImage: the caller has to call cancel() (in prepareForReuse, say). The task holds the view strongly, and the view holds the task, so a deinit could not do it either, and the view lives until its load ends;
  • WKInterfaceImage has no test target here; its code is identical to the other two.

None of that is changed here.

Checked

  • Stopped cancel() from cancelling the task: both new tests fail after the 10 s limit, with the two old ones.
  • NSImageViewRequestDLTests passes on macOS; UIImageViewRequestDLTests passes on the iPad Air 11-inch (M4) simulator.
  • swift format lint --strict is clean on Tests/RequestDLTests/Image.

🤖 Generated with Claude Code

The tests that exist showed that the completion does not fire once a load is
superseded. These check the request itself is interrupted, for the UIKit and
AppKit integrations.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@o-nnerb o-nnerb added the breaking-changes This PR is a new major version release label Oct 18, 2026
o-nnerb and others added 2 commits October 18, 2026 11:17
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A caller that waited for a busy client to free up would wait for a 60 s
request or for ever; a loaded Linux runner takes over a second (1.33 s and
1.02 s seen) on a call that only does bookkeeping.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.63%. Comparing base (ac9c315) to head (21fdef2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #429      +/-   ##
==========================================
+ Coverage   94.61%   94.63%   +0.01%     
==========================================
  Files         464      464              
  Lines       19367    19367              
==========================================
+ Hits        18324    18327       +3     
+ Misses       1043     1040       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@o-nnerb
o-nnerb merged commit 6fcd41d into main Oct 18, 2026
20 checks passed
@o-nnerb
o-nnerb deleted the image-cancel-tests branch October 18, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-changes This PR is a new major version release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant