Repository navigation
Move the remaining tests to Swift Testing - #227
Merged
Merged
Conversation
Suites are implicit structs; @suite is kept only where it sets a trait.
Converts the 38 XCTestCase classes in SwiftDraw/Tests (309 test methods) to implicit struct suites with @test, using @test(arguments:) where tests were near-duplicates. Adds FloatingPoint.isApproximately(_:tolerance:) for the former XCTAssertEqual(_:_:accuracy:) checks. AGENTS.md now documents Swift Testing only, implicit struct suites and @suite only for traits.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #227 +/- ##
==========================================
- Coverage 95.49% 95.39% -0.11%
==========================================
Files 296 297 +1
Lines 35029 34541 -488
==========================================
- Hits 33451 32949 -502
- Misses 1578 1592 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves every remaining test to Swift Testing. The repo now has no XCTest.
git grep -l "import XCTest"finds nothing.@Suite(only appears as@Suite(.serialized)onLogTests.@Testsits inside an implicitstructsuite; there are no free-standing tests.Conversions
Converted 38
XCTestCaseclasses inSwiftDraw/Tests: LayerTree (18), Renderer (14), Utilities (4), CommandLine (2) and Formatter (2). Each is now a plainstructwith@Testfunctions named for the behaviour, without thetestprefix.XCTAssertEqual(…, accuracy:)#expect(a.isApproximately(b, tolerance:)), a new shared helper inUtilities/FloatingPoint+Approximately.swiftXCTAssertThrowsError#expect(throws:). The CommandLine argument and configuration tests check forCommandLine.Error.invalid. The SF Symbol tests use the returned error to check its message.XCTUnwraptry #requireXCTFailIssue.recordXCTAssertNoThrowtryin athrowstestsourceLocation: SourceLocation = #_sourceLocationNear-duplicate tests and loops became
@Test(arguments:)in 25 places. Every tuple argument array has an explicit element type for Swift 6.2. Examples:CoordinateFormatterprecision tablesSome tests that are near-duplicates were left as they are, because their argument types aren't
Sendable. These are public CommandLine enums andpackageDOM enums. Making themSendablewould mean changing library sources.Other changes:
MockRenderer.swiftandLayerTree.TextPathTests.swiftno longer import XCTest.13 display-name-only
@Suite("…")attributes were removed fromDOM/Tests.AGENTS.md "Writing tests" now says:
structsuites@Suiteonly for traitsisApproximatelyhelper@MainActorguidanceThe sentence about older XCTest suites is gone.
Parallelism and main thread
@Suite(.serialized): none added. No converted suite touches the shared filter cache, the SVG cache, CoreText font registration, the log sink, temporary files or static mutable state. Thestatic varfixtures are computed properties, and every test builds its own renderer, bitmap and layers.@MainActor:CGPaintFallbackTestsandCGPatternTests. Both draw anNSImageinto a bitmap made current withNSGraphicsContext.current.@MainActorremoved: the one on the oldtestShapeRectinRenderer.CoreGraphicsTypesTests. It only builds aCGPath.The existing
#if canImport(CoreGraphics)/ AppKit / UIKit guards are kept.CGPath+SegmentTestsnow imports CoreText explicitly, since XCTest used to pull it in.Test counts
@Testfunctions)The count drops by 34 because duplicates became argument cases; no coverage was removed.
Verification
swift teston macOS passed 10 times in a row../container-run-tests.sh(Swift 6.4, Linux) passes.SWIFT_VERSION=6.2 ./container-run-tests.shpasses, with 1257 tests. 6.2 rejectedtx: 5 + 10 - 20inside#expectuntil it moved into a typed local.swift format lint --strict --recursive .is clean.🤖 Generated with Claude Code