Skip to content

Commit 76b74cc

Browse files
author
David Ungar
authored
Merge pull request #394 from davidungar/no-testables
Comment out `@testable` and `@_spi`
2 parents 7766798 + 25d5573 commit 76b74cc

15 files changed

+43
-45
lines changed

Sources/SwiftDriver/Incremental Compilation/BuildRecord.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ extension BuildRecord {
161161
)
162162
}
163163

164-
func encode() throws -> String {
164+
/*@_spi(Testing)*/ public func encode() throws -> String {
165165
let pathsAndInfos = inputInfos.map {
166166
input, inputInfo -> (String, InputInfo) in
167167
return (input.name, inputInfo)

Sources/SwiftDriver/Incremental Compilation/DependencyKey.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import Foundation
33

44
/// A filename from another module
5-
struct ExternalDependency: Hashable, Comparable, CustomStringConvertible {
5+
/*@_spi(Testing)*/ public struct ExternalDependency: Hashable, Comparable, CustomStringConvertible {
66
let fileName: String
77

88
var file: VirtualPath? {
99
try? VirtualPath(path: fileName)
1010
}
11-
init(_ path: String) {
11+
/*@_spi(Testing)*/ public init(_ path: String) {
1212
self.fileName = path
1313
}
1414
public var description: String {
@@ -35,15 +35,15 @@ public struct DependencyKey: Hashable, CustomStringConvertible {
3535
/// implementations white. Each node holds an instance variable describing which
3636
/// aspect of the entity it represents.
3737

38-
enum DeclAspect: Comparable {
38+
/*@_spi(Testing)*/ public enum DeclAspect: Comparable {
3939
case interface, implementation
4040
}
4141

4242
/// Encode the current sorts of dependencies as kinds of nodes in the dependency
4343
/// graph, splitting the current *member* into \ref member and \ref
4444
/// potentialMember and adding \ref sourceFileProvide.
4545
///
46-
enum Designator: Hashable, CustomStringConvertible {
46+
/*@_spi(Testing)*/ public enum Designator: Hashable, CustomStringConvertible {
4747
case
4848
topLevel(name: String),
4949
dynamicLookup(name: String),
@@ -85,11 +85,11 @@ public struct DependencyKey: Hashable, CustomStringConvertible {
8585
}
8686
}
8787

88-
let aspect: DeclAspect
89-
let designator: Designator
88+
/*@_spi(Testing)*/ public let aspect: DeclAspect
89+
/*@_spi(Testing)*/ public let designator: Designator
9090

9191

92-
init(
92+
/*@_spi(Testing)*/ public init(
9393
aspect: DeclAspect,
9494
designator: Designator)
9595
{
@@ -98,7 +98,7 @@ public struct DependencyKey: Hashable, CustomStringConvertible {
9898
}
9999

100100

101-
var correspondingImplementation: Self? {
101+
/*@_spi(Testing)*/ public var correspondingImplementation: Self? {
102102
guard aspect == .interface else {
103103
return nil
104104
}

Sources/SwiftDriver/Incremental Compilation/DictionaryOfDictionaries.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/// It supports iterating over all 2nd-level pairs. See `subscript(key: OuterKey)`
1515

1616
import Foundation
17-
struct DictionaryOfDictionaries<OuterKey: Hashable, InnerKey: Hashable, Value>: Collection {
17+
public struct DictionaryOfDictionaries<OuterKey: Hashable, InnerKey: Hashable, Value>: Collection {
1818
public typealias InnerDict = [InnerKey: Value]
1919
public typealias OuterDict = [OuterKey: InnerDict]
2020

Sources/SwiftDriver/Incremental Compilation/InputInfo.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
import Foundation
1313
import TSCBasic
1414

15-
public struct InputInfo: Equatable {
15+
/*@_spi(Testing)*/ public struct InputInfo: Equatable {
1616

17-
let status: Status
18-
let previousModTime: Date
17+
/*@_spi(Testing)*/ public let status: Status
18+
/*@_spi(Testing)*/ public let previousModTime: Date
1919

20-
public init(status: Status, previousModTime: Date) {
20+
/*@_spi(Testing)*/ public init(status: Status, previousModTime: Date) {
2121
self.status = status
2222
self.previousModTime = previousModTime
2323
}
2424
}
2525

26-
public extension InputInfo {
26+
/*@_spi(Testing)*/ public extension InputInfo {
2727
enum Status: Equatable {
2828
case upToDate,
2929
needsCascadingBuild,

Sources/SwiftDriver/Incremental Compilation/ModuleDependencyGraph Parts/Integrator.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ extension ModuleDependencyGraph {
1717
// MARK: Integrator - state & creation
1818

1919
/// Integrates a \c SourceFileDependencyGraph into a \c ModuleDependencyGraph
20-
struct Integrator {
20+
/*@_spi(Testing)*/ public struct Integrator {
2121

2222
// Shorthands
23-
typealias Graph = ModuleDependencyGraph
23+
/*@_spi(Testing)*/ public typealias Graph = ModuleDependencyGraph
2424

25-
typealias Changes = Set<Node>
25+
/*@_spi(Testing)*/ public typealias Changes = Set<Node>
2626

2727
let source: SourceFileDependencyGraph
2828
let swiftDeps: SwiftDeps
@@ -79,7 +79,7 @@ extension ModuleDependencyGraph.Integrator {
7979
/// Integrate a SourceFileDepGraph into the receiver.
8080
/// Integration happens when the driver needs to read SourceFileDepGraph.
8181
/// Returns changed nodes
82-
static func integrate(
82+
/*@_spi(Testing)*/ public static func integrate(
8383
from g: SourceFileDependencyGraph,
8484
swiftDeps: Graph.SwiftDeps,
8585
into destination: Graph

Sources/SwiftDriver/Incremental Compilation/ModuleDependencyGraph Parts/Node.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ extension ModuleDependencyGraph {
2424
///
2525
/// Use a class, not a struct because otherwise it would be duplicated for each thing it uses
2626

27-
final class Node {
27+
/*@_spi(Testing)*/ public final class Node {
2828

29-
typealias Graph = ModuleDependencyGraph
29+
/*@_spi(Testing)*/ public typealias Graph = ModuleDependencyGraph
3030

3131
/// Def->use arcs go by DependencyKey. There may be >1 node for a given key.
3232
let dependencyKey: DependencyKey
@@ -81,7 +81,7 @@ extension ModuleDependencyGraph.Node: Equatable, Hashable {
8181
}
8282

8383
extension ModuleDependencyGraph.Node: Comparable {
84-
static func < (lhs: ModuleDependencyGraph.Node, rhs: ModuleDependencyGraph.Node) -> Bool {
84+
public static func < (lhs: ModuleDependencyGraph.Node, rhs: ModuleDependencyGraph.Node) -> Bool {
8585
func lt<T: Comparable> (_ a: T?, _ b: T?) -> Bool {
8686
switch (a, b) {
8787
case let (x?, y?): return x < y

Sources/SwiftDriver/Incremental Compilation/ModuleDependencyGraph Parts/SwiftDeps.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import TSCBasic
1414

1515
// MARK: - SwiftDeps
1616
extension ModuleDependencyGraph {
17-
struct SwiftDeps: Hashable, CustomStringConvertible {
17+
/*@_spi(Testing)*/ public struct SwiftDeps: Hashable, CustomStringConvertible {
1818

1919
let file: VirtualPath
2020

@@ -25,10 +25,10 @@ extension ModuleDependencyGraph {
2525
init(_ file: VirtualPath) {
2626
self.file = file
2727
}
28-
init(mock i: Int) {
28+
/*@_spi(Testing)*/ public init(mock i: Int) {
2929
self.file = try! VirtualPath(path: String(i))
3030
}
31-
var mockID: Int {
31+
/*@_spi(Testing)*/ public var mockID: Int {
3232
Int(file.name)!
3333
}
3434
public var description: String {
@@ -39,16 +39,16 @@ extension ModuleDependencyGraph {
3939

4040
// MARK: - testing
4141
extension ModuleDependencyGraph.SwiftDeps {
42-
var sourceFileProvideNameForMockSwiftDeps: String {
42+
/*@_spi(Testing)*/ public var sourceFileProvideNameForMockSwiftDeps: String {
4343
file.name
4444
}
45-
var interfaceHashForMockSwiftDeps: String {
45+
/*@_spi(Testing)*/ public var interfaceHashForMockSwiftDeps: String {
4646
file.name
4747
}
4848
}
4949
// MARK: - comparing
5050
extension ModuleDependencyGraph.SwiftDeps: Comparable {
51-
static func < (lhs: Self, rhs: Self) -> Bool {
51+
public static func < (lhs: Self, rhs: Self) -> Bool {
5252
lhs.file.name < rhs.file.name
5353
}
5454
}

Sources/SwiftDriver/Incremental Compilation/ModuleDependencyGraph.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import SwiftOptions
1616

1717
// MARK: - ModuleDependencyGraph
1818

19-
final class ModuleDependencyGraph {
19+
/*@_spi(Testing)*/ public final class ModuleDependencyGraph {
2020

2121
var nodeFinder = NodeFinder()
2222

@@ -127,7 +127,7 @@ extension ModuleDependencyGraph {
127127

128128
/// Find all the swiftDeps files that depend on `swiftDeps`.
129129
/// Really private, except for testing.
130-
func findSwiftDepsToRecompileWhenWholeSwiftDepsChanges(
130+
/*@_spi(Testing)*/ public func findSwiftDepsToRecompileWhenWholeSwiftDepsChanges(
131131
_ swiftDeps: SwiftDeps
132132
) -> Set<SwiftDeps> {
133133
let nodes = nodeFinder.findNodes(for: swiftDeps) ?? [:]
@@ -174,7 +174,7 @@ extension ModuleDependencyGraph {
174174
// MARK: - Scheduling either wave
175175
extension ModuleDependencyGraph {
176176
/// Find all the swiftDeps affected when the nodes change.
177-
func findSwiftDepsToRecompileWhenNodesChange<Nodes: Sequence>(
177+
/*@_spi(Testing)*/ public func findSwiftDepsToRecompileWhenNodesChange<Nodes: Sequence>(
178178
_ nodes: Nodes
179179
) -> Set<SwiftDeps>
180180
where Nodes.Element == Node
@@ -187,7 +187,7 @@ extension ModuleDependencyGraph {
187187
return Set(affectedNodes.compactMap {$0.swiftDeps})
188188
}
189189

190-
func forEachUntracedSwiftDepsDirectlyDependent(
190+
/*@_spi(Testing)*/ public func forEachUntracedSwiftDepsDirectlyDependent(
191191
on externalSwiftDeps: ExternalDependency,
192192
_ fn: (SwiftDeps) -> Void
193193
) {
@@ -228,7 +228,7 @@ extension ModuleDependencyGraph {
228228
// MARK: - utilities for unit testing
229229
extension ModuleDependencyGraph {
230230
/// Testing only
231-
func haveAnyNodesBeenTraversed(inMock i: Int) -> Bool {
231+
/*@_spi(Testing)*/ public func haveAnyNodesBeenTraversed(inMock i: Int) -> Bool {
232232
let swiftDeps = SwiftDeps(mock: i)
233233
// optimization
234234
if let fileNode = nodeFinder.findFileInterfaceNode(forMock: swiftDeps),

Sources/SwiftDriver/Incremental Compilation/SourceFileDependencyGraph.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import Foundation
1313
import TSCUtility
1414

15-
struct SourceFileDependencyGraph {
15+
/*@_spi(Testing)*/ public struct SourceFileDependencyGraph {
1616
public static let sourceFileProvidesInterfaceSequenceNumber: Int = 0
1717
public static let sourceFileProvidesImplementationSequenceNumber: Int = 1
1818

@@ -62,7 +62,7 @@ extension SourceFileDependencyGraph {
6262
public var defsIDependUpon: [Int]
6363
public var isProvides: Bool
6464

65-
init(
65+
/*@_spi(Testing)*/ public init(
6666
key: DependencyKey,
6767
fingerprint: String?,
6868
sequenceNumber: Int,
@@ -121,20 +121,20 @@ extension SourceFileDependencyGraph {
121121
try self.init(pathString: swiftDeps.file.name)
122122
}
123123

124-
init(nodesForTesting: [Node]) {
124+
/*@_spi(Testing)*/ public init(nodesForTesting: [Node]) {
125125
majorVersion = 0
126126
minorVersion = 0
127127
compilerVersionString = ""
128128
allNodes = nodesForTesting
129129
}
130130

131131
// FIXME: This should accept a FileSystem parameter.
132-
init(pathString: String) throws {
132+
/*@_spi(Testing)*/ public init(pathString: String) throws {
133133
let data = try Data(contentsOf: URL(fileURLWithPath: pathString))
134134
try self.init(data: data)
135135
}
136136

137-
init(data: Data,
137+
/*@_spi(Testing)*/ public init(data: Data,
138138
fromSwiftModule extractFromSwiftModule: Bool = false) throws {
139139
struct Visitor: BitstreamVisitor {
140140
let extractFromSwiftModule: Bool

Sources/SwiftDriver/Incremental Compilation/TwoDMap.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
/// A map with 2 keys that can iterate in a number of ways
15-
struct TwoDMap<Key1: Hashable, Key2: Hashable, Value: Equatable>: MutableCollection {
15+
public struct TwoDMap<Key1: Hashable, Key2: Hashable, Value: Equatable>: MutableCollection {
1616

1717
private var map1 = DictionaryOfDictionaries<Key1, Key2, Value>()
1818
private var map2 = DictionaryOfDictionaries<Key2, Key1, Value>()

Sources/SwiftDriver/Jobs/AutolinkExtractJob.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import TSCBasic
1616
// argument input file to the linker.
1717
// FIXME: Also handle Cygwin and MinGW
1818
extension Driver {
19-
var isAutolinkExtractJobNeeded: Bool {
19+
/*@_spi(Testing)*/ public var isAutolinkExtractJobNeeded: Bool {
2020
[.elf, .wasm].contains(targetTriple.objectFormat) && lto == nil
2121
}
2222

Tests/SwiftDriverTests/IncrementalCompilationTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import XCTest
1313
import TSCBasic
1414

15-
@testable import SwiftDriver
15+
import SwiftDriver
1616

1717
final class NonincrementalCompilationTests: XCTestCase {
1818
func testBuildRecordReading() throws {

Tests/SwiftDriverTests/ModuleDependencyGraphTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import XCTest
14-
@testable import SwiftDriver
14+
import SwiftDriver
1515
import TSCBasic
1616

1717
class ModuleDependencyGraphTests: XCTestCase {

Tests/SwiftDriverTests/TwoDMapTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import XCTest
14-
@testable import SwiftDriver
14+
import SwiftDriver
1515

1616
class TwoDMapTests: XCTestCase {
1717

Utilities/build-script-helper.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,6 @@ def build_swift_driver_using_cmake(args, target, swiftc_exec, build_dir, base_cm
492492
'-DTSC_DIR=' + os.path.join(os.path.join(dependencies_dir, 'swift-tools-support-core'), 'cmake/modules'),
493493
'-DYams_DIR=' + os.path.join(os.path.join(dependencies_dir, 'yams'), 'cmake/modules'),
494494
'-DArgumentParser_DIR=' + os.path.join(os.path.join(dependencies_dir, 'swift-argument-parser'), 'cmake/modules')]
495-
#FIXME: Building with testing enable to allow @testable import of SwiftDriver
496-
driver_swift_flags.append('-enable-testing')
497495
driver_cmake_flags = base_cmake_flags + flags
498496
cmake_build(args, swiftc_exec, driver_cmake_flags, driver_swift_flags,
499497
driver_source_dir, driver_build_dir)

0 commit comments

Comments
 (0)