From 49887191bb49f1338b3dd95a6a2856cafbf51b47 Mon Sep 17 00:00:00 2001 From: Sorin Cioban Date: Sun, 31 May 2026 23:10:33 +0100 Subject: [PATCH 1/2] Run heap node tests in release --- Sources/HeapModule/CMakeLists.txt | 1 + Sources/HeapModule/Heap+Testing.swift | 19 +++++++++++++++++++ Tests/HeapTests/HeapNodeTests.swift | 9 +++------ 3 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 Sources/HeapModule/Heap+Testing.swift diff --git a/Sources/HeapModule/CMakeLists.txt b/Sources/HeapModule/CMakeLists.txt index 52fef5dc..a09b4340 100644 --- a/Sources/HeapModule/CMakeLists.txt +++ b/Sources/HeapModule/CMakeLists.txt @@ -29,5 +29,6 @@ target_sources(${module_name} PRIVATE "Heap.swift" "Heap+Descriptions.swift" "Heap+ExpressibleByArrayLiteral.swift" + "Heap+Testing.swift" "Heap+Invariants.swift" "Heap+UnsafeHandle.swift") diff --git a/Sources/HeapModule/Heap+Testing.swift b/Sources/HeapModule/Heap+Testing.swift new file mode 100644 index 00000000..a5812d88 --- /dev/null +++ b/Sources/HeapModule/Heap+Testing.swift @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift Collections open source project +// +// Copyright (c) 2021 - 2026 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 WITH Swift-exception +// +//===----------------------------------------------------------------------===// + +@_spi(Testing) +public enum _HeapTestSupport { + public static func isMinLevel(offset: Int) -> Bool { + _HeapNode(offset: offset).isMinLevel + } +} diff --git a/Tests/HeapTests/HeapNodeTests.swift b/Tests/HeapTests/HeapNodeTests.swift index 863fa393..e76738f1 100644 --- a/Tests/HeapTests/HeapNodeTests.swift +++ b/Tests/HeapTests/HeapNodeTests.swift @@ -11,12 +11,11 @@ // //===----------------------------------------------------------------------===// -#if DEBUG // These unit tests need access to HeapModule internals import XCTest #if COLLECTIONS_SINGLE_MODULE -@testable import Collections +@_spi(Testing) import Collections #else -@testable import HeapModule +@_spi(Testing) import HeapModule #endif class HeapNodeTests: XCTestCase { @@ -26,11 +25,9 @@ class HeapNodeTests: XCTestCase { for exp in 0...12 { // Check [2^exp, 2^(exp + 1)) for offset in Int(pow(2, Double(exp)) - 1).. Date: Thu, 4 Jun 2026 10:18:09 +0100 Subject: [PATCH 2/2] Use package access for heap test helper --- Sources/HeapModule/Heap+Testing.swift | 5 ++--- Tests/HeapTests/HeapNodeTests.swift | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Sources/HeapModule/Heap+Testing.swift b/Sources/HeapModule/Heap+Testing.swift index a5812d88..2920bf9b 100644 --- a/Sources/HeapModule/Heap+Testing.swift +++ b/Sources/HeapModule/Heap+Testing.swift @@ -11,9 +11,8 @@ // //===----------------------------------------------------------------------===// -@_spi(Testing) -public enum _HeapTestSupport { - public static func isMinLevel(offset: Int) -> Bool { +extension Heap { + package static func _isMinLevel(offset: Int) -> Bool { _HeapNode(offset: offset).isMinLevel } } diff --git a/Tests/HeapTests/HeapNodeTests.swift b/Tests/HeapTests/HeapNodeTests.swift index e76738f1..303c7455 100644 --- a/Tests/HeapTests/HeapNodeTests.swift +++ b/Tests/HeapTests/HeapNodeTests.swift @@ -13,9 +13,9 @@ import XCTest #if COLLECTIONS_SINGLE_MODULE -@_spi(Testing) import Collections +import Collections #else -@_spi(Testing) import HeapModule +import HeapModule #endif class HeapNodeTests: XCTestCase { @@ -25,7 +25,7 @@ class HeapNodeTests: XCTestCase { for exp in 0...12 { // Check [2^exp, 2^(exp + 1)) for offset in Int(pow(2, Double(exp)) - 1)..._isMinLevel(offset: offset), isMin) } isMin.toggle() }