Skip to content

Commit

Permalink
Add Swift 5.8 nightly to test matrix (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
ileitch authored Mar 10, 2023
1 parent 28a1fb6 commit 96d01db
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ jobs:
strategy:
fail-fast: false
matrix:
swift: ["5.7"]
swift: ["5.8", "5.7"]
include:
- swift: "5.8"
container: "swiftlang/swift:nightly-5.8-jammy"
cache-version: 1
- swift: "5.7"
container: "swift:5.7"
cache-version: 1
Expand Down Expand Up @@ -84,8 +87,8 @@ jobs:
if: steps.cache-resolved-dependencies.outputs.cache-hit != 'true'
run: ${{ env.swift_package_resolve }}
- name: Build
run: ${{ env.swift_build }} --enable-test-discovery
run: ${{ env.swift_build }}
- name: Test
run: ${{ env.swift_test }} --enable-test-discovery
run: ${{ env.swift_test }}
- name: Scan
run: ${{ env.periphery_scan }} --config .periphery.linux.yml
14 changes: 12 additions & 2 deletions Sources/PeripheryKit/Indexer/SwiftIndexer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ public final class SwiftIndexer: Indexer {
private let configuration: Configuration
private let indexStorePaths: [FilePath]

private lazy var letShorthandWorkaroundEnabled: Bool = {
SwiftVersion.current.version.isVersion(lessThan: "5.8")
}()

public required init(
sourceFiles: [FilePath: Set<String>],
graph: SourceGraph,
Expand Down Expand Up @@ -76,7 +80,8 @@ public final class SwiftIndexer: Indexer {
units: units,
graph: graph,
logger: logger,
configuration: configuration
configuration: configuration,
letShorthandWorkaroundEnabled: letShorthandWorkaroundEnabled
)
}

Expand Down Expand Up @@ -116,19 +121,23 @@ public final class SwiftIndexer: Indexer {
private let graph: SourceGraph
private let logger: ContextualLogger
private let configuration: Configuration
private let letShorthandWorkaroundEnabled: Bool

required init(
file: SourceFile,
units: [(IndexStore, IndexStoreUnit)],
graph: SourceGraph,
logger: ContextualLogger,
configuration: Configuration
configuration: Configuration,
letShorthandWorkaroundEnabled: Bool

) {
self.file = file
self.units = units
self.graph = graph
self.logger = logger
self.configuration = configuration
self.letShorthandWorkaroundEnabled = letShorthandWorkaroundEnabled
}

struct RawRelation {
Expand Down Expand Up @@ -231,6 +240,7 @@ public final class SwiftIndexer: Indexer {
func phaseTwo() throws {
let multiplexingSyntaxVisitor = try MultiplexingSyntaxVisitor(file: file)
let declarationSyntaxVisitor = multiplexingSyntaxVisitor.add(DeclarationSyntaxVisitor.self)
declarationSyntaxVisitor.letShorthandWorkaroundEnabled = letShorthandWorkaroundEnabled
let importSyntaxVisitor = multiplexingSyntaxVisitor.add(ImportSyntaxVisitor.self)

multiplexingSyntaxVisitor.visit()
Expand Down
4 changes: 4 additions & 0 deletions Sources/PeripheryKit/Syntax/DeclarationSyntaxVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ final class DeclarationSyntaxVisitor: PeripherySyntaxVisitor {
hasCapitalSelfFunctionCall: Bool
)

var letShorthandWorkaroundEnabled: Bool = false

private let sourceLocationBuilder: SourceLocationBuilder
private let typeSyntaxInspector: TypeSyntaxInspector
private(set) var results: [Result] = []
Expand Down Expand Up @@ -287,6 +289,8 @@ final class DeclarationSyntaxVisitor: PeripherySyntaxVisitor {
}

func visit(_ node: OptionalBindingConditionSyntax) {
guard letShorthandWorkaroundEnabled else { return }

guard node.initializer == nil,
let identifier = node.pattern.as(IdentifierPatternSyntax.self)?.identifier,
let parentStmt = node.parent?.parent?.parent,
Expand Down
2 changes: 2 additions & 0 deletions Tests/PeripheryTests/ObjcRetentionTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Shared

#if os(macOS)
final class ObjcRetentionTest: FixtureSourceGraphTestCase {
let performKnownFailures = false

static override func setUp() {
super.setUp()

Expand Down
6 changes: 6 additions & 0 deletions Tests/PeripheryTests/RetentionTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Shared
@testable import PeripheryKit

final class RetentionTest: FixtureSourceGraphTestCase {
let performKnownFailures = false

static override func setUp() {
super.setUp()

Expand Down Expand Up @@ -980,10 +982,14 @@ final class RetentionTest: FixtureSourceGraphTestCase {
self.assertNotAssignOnlyProperty(.varInstance("propertyReferencedFromDeepChain"))
}

#if swift(>=5.8)
self.assertReferenced(.varGlobal("fixtureClass117StaticProperty"))
#else
// This property should be referenced, but the let shorthand workaround doesn't
// handle properties at global (file) scope. This will remain broken until the
// issue is resolved in Swift: https://github.com/apple/swift/issues/61509.
self.assertNotReferenced(.varGlobal("fixtureClass117StaticProperty"))
#endif
}
}

Expand Down
1 change: 0 additions & 1 deletion Tests/Shared/SourceGraphTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ open class SourceGraphTestCase: XCTestCase {

private static var allIndexedDeclarations: Set<Declaration> = []

let performKnownFailures = false
var configuration: Configuration { Self.configuration }

private var scopeStack: [DeclarationScope] = []
Expand Down

0 comments on commit 96d01db

Please sign in to comment.