From d465f500e3b452d9d3d01c03063af71ee7bff8cf Mon Sep 17 00:00:00 2001 From: Mihaela Mihaljevic Date: Sat, 18 Jul 2026 23:43:59 +0200 Subject: [PATCH] fix(tests): normalize lastPathComponent for Linux Foundation Darwin's Foundation returns String from URL.lastPathComponent; swift-corelibs-foundation on this toolchain returns String?. The three uses in TaggedNodeCorpusRoundTripTests (a sort comparator and two Testing.Comment interpolations) compiled on Darwin but failed the Linux build outright, an unrelated pre-existing gap surfaced while verifying the anchor-expansion-bomb fix on the Linux CI relay. An explicit `(url.lastPathComponent as String?) ?? ""` coercion makes both platforms produce a uniform String? before the `??`, rather than picking one platform's non-optional type and breaking the other. Verified via a full clean macOS build and test run (674 tests, all passing) and swiftformat/swiftlint --strict clean. --- CHANGELOG.md | 6 ++++++ Tests/TaggedNodeCorpusRoundTripTests.swift | 13 ++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e721e0..061ef8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -446,6 +446,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 produce. A document with genuinely wide but non-exponential alias reuse (the same anchor referenced thousands of times at one level, no nesting) still parses normally. +- `TaggedNodeCorpusRoundTripTests` now normalizes `URL.lastPathComponent` + through an explicit `as String?` coercion before use: this toolchain's + swift-corelibs-foundation returns `String?` where Darwin's Foundation + returns `String`, and the mismatch failed the Linux build outright + (an unrelated pre-existing gap surfaced while verifying the + anchor-expansion fix above on the Linux CI relay). ## [0.2.0] - 2026-07-05 diff --git a/Tests/TaggedNodeCorpusRoundTripTests.swift b/Tests/TaggedNodeCorpusRoundTripTests.swift index 9f94e8e..3fdcef5 100644 --- a/Tests/TaggedNodeCorpusRoundTripTests.swift +++ b/Tests/TaggedNodeCorpusRoundTripTests.swift @@ -19,7 +19,14 @@ struct TaggedNodeCorpusRoundTripTests { )) var accepted = 0 var rejected = 0 - for url in urls.sorted(by: { $0.lastPathComponent < $1.lastPathComponent }) { + /// `URL.lastPathComponent` is `String` on Darwin's Foundation but `String?` on this + /// toolchain's swift-corelibs-foundation; the explicit `as String?` upcast/coercion makes + /// both platforms produce a uniform `String?` here so `?? ""` compiles identically either + /// way, rather than picking one platform's non-optional type and breaking the other. + func name(_ url: URL) -> String { + (url.lastPathComponent as String?) ?? "" + } + for url in urls.sorted(by: { name($0) < name($1) }) { let source = try String(contentsOf: url, encoding: .utf8) let parsed: PureYAML.Tagged.Node do { @@ -34,11 +41,11 @@ struct TaggedNodeCorpusRoundTripTests { do { reparsed = try PureYAML.parseTagged(dumped) } catch { - Issue.record("\(url.lastPathComponent): dump produced unparseable YAML: \(error)") + Issue.record("\(name(url)): dump produced unparseable YAML: \(error)") continue } if let detail = firstDivergence(parsed, reparsed, path: "$") { - Issue.record("\(url.lastPathComponent): \(detail)") + Issue.record("\(name(url)): \(detail)") } } #expect(accepted > 0)