Skip to content

@testable cleanup #8826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 45 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0d53522
Basics: make some of the private API more public
compnerd Jun 13, 2025
e7b4e1d
Tests: remove `@testable import Basics`
compnerd Jun 13, 2025
f1afd26
PackageGraph: make some of the private API more public
compnerd Jun 13, 2025
cb1ff80
Tests: remove `@testable import PackageGraph`
compnerd Jun 13, 2025
b12c7bc
Build: make some of the private API more public
compnerd Jun 13, 2025
6ce584c
Tests: remove `@testable import Build`
compnerd Jun 13, 2025
7210759
PackageModel: make some of the private API more public
compnerd Jun 13, 2025
4d7e288
Tests: remove `@testable import PackageModel`
compnerd Jun 13, 2025
b55dfd9
PackageCollections: make some of the private API more public
compnerd Jun 13, 2025
ae0ec08
Tests: remove `@testable import PackageCollections`
compnerd Jun 13, 2025
5dc6593
PackageCollectionsSigning: make some of the private API more public
compnerd Jun 13, 2025
f57617e
Tests: remove `@testable import PackageCollectionsSigning`
compnerd Jun 13, 2025
9aa84dd
Tests: remove `@testable import PackageCollectionsModel`
compnerd Jun 13, 2025
3d23d4d
Workspace: make some of the private API more public
compnerd Jun 13, 2025
c11860d
Tests: remove `@testable import Workspace`
compnerd Jun 13, 2025
22cc919
SPMBuildCore: make some of the private API more public
compnerd Jun 13, 2025
1a0ba32
Tests: remove `@testable import SPMBuildCore`
compnerd Jun 13, 2025
a57fb71
PackagingSigning: make some of the private API more public
compnerd Jun 13, 2025
88da821
Tests: remove `@testable import PackagingSigning`
compnerd Jun 13, 2025
23bb3ed
PackageRegistry: make some of the private API more public
compnerd Jun 13, 2025
74a20f9
Tests: remove `@testable import PackageRegistry`
compnerd Jun 13, 2025
a534768
CoreCommands: make some of the private API more public
compnerd Jun 13, 2025
ca97038
Tests: remove `@testable import CoreCommands`
compnerd Jun 13, 2025
10ba39d
Commands: make some of the private API more public
compnerd Jun 13, 2025
bc60ff0
Tests: remove `@testable import Commands`
compnerd Jun 13, 2025
2d8249b
SourceControl: make some of the private API more public
compnerd Jun 13, 2025
f5548f7
Tests: remove `@testable import SourceControl`
compnerd Jun 13, 2025
4127cb3
PackageLoading: make some of the private API more public
compnerd Jun 13, 2025
acc14c2
Tests: remove `@testable import PackageLoading`
compnerd Jun 13, 2025
a28d181
XCBuildSupport: make some of the private API more public
compnerd Jun 13, 2025
d8e8024
Tests: remove `@testable import XCBuildSupport`
compnerd Jun 13, 2025
4731e7d
Tests: remove `@testable import SwiftFixIt`
compnerd Jun 13, 2025
f745213
SourceKitLSPAPI: make some of the private API more public
compnerd Jun 13, 2025
0e09ab7
Tests: remove `@testable import SourceKitLSPAPI`
compnerd Jun 13, 2025
f36393e
PackageRegistryCommand: make some of the private API more public
compnerd Jun 13, 2025
a879b74
Tests: remove `@testable import PackageRegistryCommand`
compnerd Jun 13, 2025
255e572
PackageFingerprint: make some of the private API more public
compnerd Jun 13, 2025
8bd15c4
Tests: remove `@testable import PackageFingerprint`
compnerd Jun 13, 2025
0b394aa
Tests: remove `@testable import LLBuildManifest`
compnerd Jun 13, 2025
cf86870
DriverSupport: make some of the private API more public
compnerd Jun 13, 2025
7b0ee84
Tests: remove `@testable import DriverSupport`
compnerd Jun 13, 2025
5c8fd36
Tests: remove `@testable import _InternalTestSupport`
compnerd Jun 13, 2025
229ef8e
SwiftFixIt: make some of the private API more public
compnerd Jun 13, 2025
4565e83
QueryEngine: make some of the private API more public
compnerd Jun 13, 2025
4ea6c2c
Tests: remove `@testable import QueryEngine`
compnerd Jun 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Basics/Archiver/TarArchiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public struct TarArchiver: Archiver {
private let cancellator: Cancellator

/// The underlying command
internal let tarCommand: String
package let tarCommand: String

/// Creates a `TarArchiver`.
///
Expand Down
6 changes: 3 additions & 3 deletions Sources/Basics/Archiver/ZipArchiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public struct ZipArchiver: Archiver, Cancellable {

/// Absolute path to the Windows tar in the system folder
#if os(Windows)
internal let windowsTar: String
package let windowsTar: String
#else
internal let unzip = "unzip"
internal let zip = "zip"
package let unzip = "unzip"
package let zip = "zip"
#endif

#if os(FreeBSD)
Expand Down
20 changes: 10 additions & 10 deletions Sources/Basics/AuthorizationProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extension AuthorizationProvider {

public final class NetrcAuthorizationProvider: AuthorizationProvider, AuthorizationWriter {
// marked internal for testing
internal let path: AbsolutePath
package let path: AbsolutePath
private let fileSystem: FileSystem

private let cache = ThreadSafeKeyValueStore<String, (user: String, password: String)>()
Expand Down Expand Up @@ -140,7 +140,7 @@ public final class NetrcAuthorizationProvider: AuthorizationProvider, Authorizat
}

// marked internal for testing
internal var machines: [Basics.Netrc.Machine] {
package var machines: [Basics.Netrc.Machine] {
// this ignores any errors reading the file
// initial validation is done at the time of initializing the provider
// and if the file becomes corrupt at runtime it will handle it gracefully
Expand Down Expand Up @@ -408,16 +408,16 @@ public final class KeychainAuthorizationProvider: AuthorizationProvider, Authori
return item
}

struct ProtocolHostPort: Hashable, CustomStringConvertible {
let `protocol`: String?
let host: String
let port: Int?
package struct ProtocolHostPort: Hashable, CustomStringConvertible {
package let `protocol`: String?
package let host: String
package let port: Int?

var server: String {
self.host
}

var protocolCFString: CFString {
package var protocolCFString: CFString {
// See
// https://developer.apple.com/documentation/security/keychain_services/keychain_items/item_attribute_keys_and_values?language=swift
// for a list of possible values for the `kSecAttrProtocol` attribute.
Expand All @@ -431,7 +431,7 @@ public final class KeychainAuthorizationProvider: AuthorizationProvider, Authori
}
}

init?(from url: URL) {
package init?(from url: URL) {
guard let host = url.host?.lowercased(), !host.isEmpty else {
return nil
}
Expand All @@ -441,7 +441,7 @@ public final class KeychainAuthorizationProvider: AuthorizationProvider, Authori
self.port = url.port
}

var description: String {
package var description: String {
"\(self.protocol.map { "\($0)://" } ?? "")\(self.host)\(self.port.map { ":\($0)" } ?? "")"
}
}
Expand All @@ -452,7 +452,7 @@ public final class KeychainAuthorizationProvider: AuthorizationProvider, Authori

public struct CompositeAuthorizationProvider: AuthorizationProvider {
// marked internal for testing
internal let providers: [AuthorizationProvider]
package let providers: [AuthorizationProvider]
private let observabilityScope: ObservabilityScope

public init(_ providers: AuthorizationProvider..., observabilityScope: ObservabilityScope) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Basics/Cancellator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public final class Cancellator: Cancellable, Sendable {

// marked internal for testing
@discardableResult
internal func _cancel(deadline: DispatchTime? = .none) -> Int {
package func _cancel(deadline: DispatchTime? = .none) -> Int {
self.cancelling.put(true)

self.observabilityScope?
Expand Down
6 changes: 3 additions & 3 deletions Sources/Basics/Concurrency/SendableBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ public actor SendableBox<Value: Sendable> {
}

extension SendableBox where Value == Int {
func increment() {
package func increment() {
self.value = value + 1
}

func decrement() {
package func decrement() {
self.value = value - 1
}
}

extension SendableBox where Value == Date {
func resetDate() {
package func resetDate() {
value = Date()
}
}
8 changes: 4 additions & 4 deletions Sources/Basics/Graph/AdjacencyMatrix.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/// edge exists.
///
/// See https://en.wikipedia.org/wiki/Adjacency_matrix for more details.
struct AdjacencyMatrix {
package struct AdjacencyMatrix {
let columns: Int
let rows: Int
private var bytes: [UInt8]
Expand All @@ -27,15 +27,15 @@ struct AdjacencyMatrix {
/// - Parameters:
/// - rows: Number of rows in the matrix.
/// - columns: Number of columns in the matrix.
init(rows: Int, columns: Int) {
package init(rows: Int, columns: Int) {
self.columns = columns
self.rows = rows

let (quotient, remainder) = (rows * columns).quotientAndRemainder(dividingBy: 8)
self.bytes = .init(repeating: 0, count: quotient + (remainder > 0 ? 1 : 0))
}

var bitCount: Int {
package var bitCount: Int {
bytes.count * 8
}

Expand All @@ -44,7 +44,7 @@ struct AdjacencyMatrix {
return (byteOffset: totalBitOffset / 8, bitOffsetInByte: totalBitOffset % 8)
}

subscript(row: Int, column: Int) -> Bool {
package subscript(row: Int, column: Int) -> Bool {
get {
let (byteOffset, bitOffsetInByte) = calculateOffsets(row: row, column: column)

Expand Down
4 changes: 2 additions & 2 deletions Sources/Basics/HTTPClient/HTTPClientHeaders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public struct HTTPClientHeaders: Sendable {
}

public struct Item: Equatable, Sendable {
let name: String
let value: String
package let name: String
package let value: String

public init(name: String, value: String) {
self.name = name
Expand Down
2 changes: 1 addition & 1 deletion Sources/Basics/HTTPClient/HTTPMethod.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public enum HTTPMethod: Sendable {
case put
case delete

var string: String {
package var string: String {
switch self {
case .head:
return "HEAD"
Expand Down
8 changes: 4 additions & 4 deletions Sources/Basics/HTTPClient/URLSessionHTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import struct TSCUtility.Versioning
import FoundationNetworking
#endif

final class URLSessionHTTPClient: Sendable {
package final class URLSessionHTTPClient: Sendable {
private let dataSession: URLSession
private let downloadSession: URLSession
private let dataTaskManager: DataTaskManager
private let downloadTaskManager: DownloadTaskManager

init(configuration: URLSessionConfiguration = .default) {
package init(configuration: URLSessionConfiguration = .default) {
let dataDelegateQueue = OperationQueue()
dataDelegateQueue.name = "org.swift.swiftpm.urlsession-http-client-data-delegate"
dataDelegateQueue.maxConcurrentOperationCount = 1
Expand Down Expand Up @@ -52,7 +52,7 @@ final class URLSessionHTTPClient: Sendable {
}

@Sendable
func execute(
package func execute(
_ request: HTTPClient.Request,
progress: HTTPClient.ProgressHandler? = nil
) async throws -> LegacyHTTPClient.Response {
Expand Down Expand Up @@ -364,7 +364,7 @@ private final class DownloadTaskManager: NSObject, URLSessionDownloadDelegate {
}

extension URLRequest {
init(_ request: LegacyHTTPClient.Request) {
package init(_ request: LegacyHTTPClient.Request) {
self.init(url: request.url)
self.httpMethod = request.method.string
request.headers.forEach { header in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import _Concurrency
import TSCUtility

/// A progress animation wrapper that throttles updates to a given interval.
final class ThrottledProgressAnimation: ProgressAnimationProtocol {
package final class ThrottledProgressAnimation: ProgressAnimationProtocol {
private let animation: ProgressAnimationProtocol
private let shouldUpdate: () -> Bool
private var pendingUpdate: (Int, Int, String)?

init<C: Clock>(
package init<C: Clock>(
_ animation: ProgressAnimationProtocol,
now: @escaping () -> C.Instant, interval: C.Duration, clock: C.Type = C.self
) {
Expand All @@ -36,7 +36,7 @@ final class ThrottledProgressAnimation: ProgressAnimationProtocol {
}
}

func update(step: Int, total: Int, text: String) {
package func update(step: Int, total: Int, text: String) {
guard shouldUpdate() else {
pendingUpdate = (step, total, text)
return
Expand All @@ -45,14 +45,14 @@ final class ThrottledProgressAnimation: ProgressAnimationProtocol {
animation.update(step: step, total: total, text: text)
}

func complete(success: Bool) {
package func complete(success: Bool) {
if let (step, total, text) = pendingUpdate {
animation.update(step: step, total: total, text: text)
}
animation.complete(success: success)
}

func clear() {
package func clear() {
animation.clear()
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Basics/Serialization/SerializedJSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/// Wrapper type representing serialized escaped JSON strings providing helpers
/// for escaped string interpolations for common types such as `AbsolutePath`.
public struct SerializedJSON {
let underlying: String
package let underlying: String
}

extension SerializedJSON: ExpressibleByStringLiteral {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public final class ClangModuleBuildDescription {
public let buildToolPluginInvocationResults: [BuildToolPluginInvocationResult]

/// Create a new target description with target and build parameters.
init(
package init(
package: ResolvedPackage,
target: ResolvedModule,
toolsVersion: ToolsVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public enum ModuleBuildDescription: SPMBuildCore.ModuleBuildDescription {
}
}

var destination: BuildParameters.Destination {
package var destination: BuildParameters.Destination {
switch self {
case .swift(let buildDescription):
buildDescription.destination
Expand Down Expand Up @@ -162,6 +162,11 @@ extension ModuleBuildDescription: Identifiable {
public struct ID: Hashable {
let moduleID: ResolvedModule.ID
let destination: BuildParameters.Destination

package init(moduleID: ResolvedModule.ID, destination: BuildParameters.Destination) {
self.moduleID = moduleID
self.destination = destination
}
}

public var id: ID {
Expand Down
11 changes: 8 additions & 3 deletions Sources/Build/BuildDescription/ProductBuildDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription

/// The dynamic libraries this product needs to link with.
// Computed during build planning.
var dylibs: [ProductBuildDescription] = []
package var dylibs: [ProductBuildDescription] = []

/// Any additional flags to be added. These flags are expected to be computed during build planning.
var additionalFlags: [String] = []
Expand All @@ -65,7 +65,7 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
var libraryBinaryPaths: Set<AbsolutePath> = []

/// Paths to tools shipped in binary dependencies
var availableTools: [String: AbsolutePath] = [:]
package var availableTools: [String: AbsolutePath] = [:]

/// Path to the temporary directory for this product.
var tempsPath: AbsolutePath {
Expand All @@ -85,7 +85,7 @@ public final class ProductBuildDescription: SPMBuildCore.ProductBuildDescription
private let observabilityScope: ObservabilityScope

/// Create a build description for a product.
init(
package init(
package: ResolvedPackage,
product: ResolvedProduct,
toolsVersion: ToolsVersion,
Expand Down Expand Up @@ -422,6 +422,11 @@ extension ProductBuildDescription: Identifiable {
public struct ID: Hashable {
let productID: ResolvedProduct.ID
let destination: BuildParameters.Destination

package init(productID: ResolvedProduct.ID, destination: BuildParameters.Destination) {
self.productID = productID
self.destination = destination
}
}

public var id: ID {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public final class SwiftModuleBuildDescription {
var libraryBinaryPaths: Set<AbsolutePath> = []

/// Any addition flags to be added. These flags are expected to be computed during build planning.
var additionalFlags: [String] = []
package var additionalFlags: [String] = []

/// Describes the purpose of a test target, including any special roles such as containing a list of discovered
/// tests or serving as the manifest target which contains the main entry point.
Expand Down Expand Up @@ -808,7 +808,7 @@ public final class SwiftModuleBuildDescription {
self.target.type == .library
}

func writeOutputFileMap(to path: AbsolutePath) throws {
package func writeOutputFileMap(to path: AbsolutePath) throws {
let masterDepsPath = self.tempsPath.appending("master.swiftdeps")

var content =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import struct PackageGraph.ResolvedModule
import struct PackageGraph.ResolvedProduct

extension LLBuildManifestBuilder {
func createProductCommand(_ buildProduct: ProductBuildDescription) throws {
package func createProductCommand(_ buildProduct: ProductBuildDescription) throws {
let cmdName = try buildProduct.commandName

// Add dependency on Info.plist generation on Darwin platforms.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Build/BuildManifest/LLBuildManifestBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class LLBuildManifestBuilder {
public internal(set) var manifest: LLBuildManifest = .init()

/// Mapping from Swift compiler path to Swift get version files.
var swiftGetVersionFiles = [AbsolutePath: AbsolutePath]()
package var swiftGetVersionFiles = [AbsolutePath: AbsolutePath]()

/// Create a new builder with a build plan.
public init(
Expand Down
4 changes: 2 additions & 2 deletions Sources/Build/BuildOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
}

/// Compute the llbuild target name using the given subset.
func computeLLBuildTargetName(for subset: BuildSubset) async throws -> String {
package func computeLLBuildTargetName(for subset: BuildSubset) async throws -> String {
func inferTestDestination(
testModule: ResolvedModule,
graph: ModulesGraph
Expand Down Expand Up @@ -1023,7 +1023,7 @@ extension BuildDescription {
}

extension BuildSubset {
func recursiveDependencies(for graph: ModulesGraph, observabilityScope: ObservabilityScope) throws -> [ResolvedModule]? {
package func recursiveDependencies(for graph: ModulesGraph, observabilityScope: ObservabilityScope) throws -> [ResolvedModule]? {
switch self {
case .allIncludingTests:
return Array(graph.reachableModules)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Build/BuildPlan/BuildPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ extension BuildPlan {
///
/// Note that warnings emitted by the the plugin itself will be returned in the `BuildToolPluginInvocationResult`
/// structures for later showing to the user, and not added directly to the diagnostics engine.
static func invokeBuildToolPlugins(
package static func invokeBuildToolPlugins(
for module: ResolvedModule,
destination: BuildParameters.Destination,
configuration: PluginConfiguration,
Expand Down
Loading