Skip to content

Basics: remove @testable imports #8821

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Tests/BasicsTests/Archiver/TarArchiverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//

import Basics
@testable import struct Basics.TarArchiver
import struct Basics.TarArchiver
import TSCclibc // for SPM_posix_spawn_file_actions_addchdir_np_supported
import _InternalTestSupport
import XCTest
Expand Down
4 changes: 2 additions & 2 deletions Tests/BasicsTests/Archiver/UniversalArchiverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
//===----------------------------------------------------------------------===//

import Basics
@testable import struct Basics.TarArchiver
@testable import struct Basics.ZipArchiver
import struct Basics.TarArchiver
import struct Basics.ZipArchiver
import TSCclibc // for SPM_posix_spawn_file_actions_addchdir_np_supported
import _InternalTestSupport
import XCTest
Expand Down
2 changes: 1 addition & 1 deletion Tests/BasicsTests/Archiver/ZipArchiverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//

import Basics
@testable import struct Basics.ZipArchiver
import struct Basics.ZipArchiver
import _InternalTestSupport
import XCTest
import TSCclibc // for SPM_posix_spawn_file_actions_addchdir_np_supported
Expand Down
2 changes: 1 addition & 1 deletion Tests/BasicsTests/AuthorizationProviderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

@testable import Basics
import Basics
import _InternalTestSupport
import XCTest

Expand Down
2 changes: 1 addition & 1 deletion Tests/BasicsTests/CancellatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

@testable import Basics
import Basics
import _InternalTestSupport
import XCTest

Expand Down
2 changes: 1 addition & 1 deletion Tests/BasicsTests/ConcurrencyHelpersTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//
import Foundation

@testable import Basics
import Basics
import TSCTestSupport
import Testing

Expand Down
2 changes: 1 addition & 1 deletion Tests/BasicsTests/DictionaryTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

@testable import Basics
import Basics
import Testing

struct DictionaryTests {
Expand Down
2 changes: 1 addition & 1 deletion Tests/BasicsTests/Environment/EnvironmentKeyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//
import Foundation

@testable import Basics
import Basics
import Testing

struct EnvironmentKeyTests {
Expand Down
1 change: 0 additions & 1 deletion Tests/BasicsTests/Environment/EnvironmentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import Foundation

@_spi(SwiftPMInternal)
@testable
import Basics

import Testing
Expand Down
2 changes: 1 addition & 1 deletion Tests/BasicsTests/FileSystem/FileSystemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Foundation
import TSCTestSupport
import Testing

@testable import Basics
import Basics

struct FileSystemTests {
@Test
Expand Down
2 changes: 1 addition & 1 deletion Tests/BasicsTests/Graph/AdjacencyMatrixTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

@testable import Basics
import Basics
import Testing

struct AdjacencyMatrixTests {
Expand Down
2 changes: 1 addition & 1 deletion Tests/BasicsTests/HTTPClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//
import Foundation

@testable import Basics
import Basics
import _Concurrency
import _InternalTestSupport
import Testing
Expand Down
2 changes: 1 addition & 1 deletion Tests/BasicsTests/LegacyHTTPClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

@testable import Basics
import Basics
import _InternalTestSupport
import XCTest

Expand Down
2 changes: 1 addition & 1 deletion Tests/BasicsTests/ObservabilitySystemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//
import Foundation

@testable import Basics
import Basics
import _InternalTestSupport
import Testing

Expand Down
1 change: 0 additions & 1 deletion Tests/BasicsTests/ProgressAnimationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import _Concurrency
import Testing

@_spi(SwiftPMInternal)
@testable
import Basics
import TSCBasic

Expand Down
Loading