Skip to content

Commit ce1349c

Browse files
committed
Tests: simplify some expectations (NFCI)
These expectations and requirements are unnecessary. The expectations are provably tautological. Simply remove them to reduce clutter and warnings from the compiler.
1 parent 74bc85d commit ce1349c

File tree

11 files changed

+30
-54
lines changed

11 files changed

+30
-54
lines changed

Tests/SWBCorePerfTests/SerializationPerfTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ fileprivate struct SerializationPerfTests: CoreBasedTests, PerfTests {
5454

5555
for _ in 0..<numberOfTargets {
5656
let sz = self.serializeMacroEvaluationScope(scope)
57-
#expect(sz != nil)
5857
accumulatedBytes += Float64(sz.byteString.count)
5958
}
6059

Tests/SWBCoreTests/BuildRuleTests.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ import SWBMacro
5454
let scope = MacroEvaluationScope(table: table)
5555

5656
// Match the rules against the rule set.
57-
let hAction = ruleSet.match(hFile, scope)
58-
#expect(hAction != nil)
57+
let _ = ruleSet.match(hFile, scope)
5958
let cAction = ruleSet.match(cFile, scope)
6059
#expect(cAction.action != nil)
6160
#expect(cAction.diagnostics.isEmpty)

Tests/SWBCoreTests/PIFLoadingTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,10 +1365,10 @@ private final class ProjectModelItemClass: ProjectModelItem {
13651365

13661366
// Check that the build files and the target dependency resolved.
13671367
#expect(appTarget!.dependencies.map { $0.guid } == [frameworkTarget!.guid])
1368-
#expect(((appTarget!.buildPhases[0] as! SourcesBuildPhase).buildFiles[0] === classOneFileRef!) != nil)
1369-
#expect(((appTarget!.buildPhases[1] as! FrameworksBuildPhase).buildFiles[0] === cocoaFwkFileRef!) != nil)
1370-
#expect(((frameworkTarget!.buildPhases[0] as! SourcesBuildPhase).buildFiles[0] === classTwoFileRef!) != nil)
1371-
#expect(((frameworkTarget!.buildPhases[1] as! FrameworksBuildPhase).buildFiles[0] === classTwoFileRef!) != nil)
1368+
#expect((appTarget!.buildPhases[0] as! SourcesBuildPhase).buildFiles[0] === classOneFileRef!)
1369+
#expect((appTarget!.buildPhases[1] as! FrameworksBuildPhase).buildFiles[0] === cocoaFwkFileRef!)
1370+
#expect((frameworkTarget!.buildPhases[0] as! SourcesBuildPhase).buildFiles[0] === classTwoFileRef!)
1371+
#expect((frameworkTarget!.buildPhases[1] as! FrameworksBuildPhase).buildFiles[0] === classTwoFileRef!)
13721372
#expect(appTarget?.productReference.target == appTarget)
13731373
#expect(frameworkTarget?.productReference.target == frameworkTarget)
13741374
}

Tests/SWBCoreTests/SettingsTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4236,7 +4236,7 @@ import SWBMacro
42364236

42374237
let parameters = BuildParameters(action: .build, configuration: "Debug")
42384238
for (target, version) in expectations {
4239-
let settings = Settings(workspaceContext: context, buildRequestContext: buildRequestContext, parameters: parameters, project: testProject, target: try #require(testWorkspace.target(for: target.guid)))
4239+
let settings = Settings(workspaceContext: context, buildRequestContext: buildRequestContext, parameters: parameters, project: testProject, target: testWorkspace.target(for: target.guid))
42404240
let effectiveSwiftVersion = settings.globalScope.evaluate(BuiltinMacros.EFFECTIVE_SWIFT_VERSION)
42414241
#expect(effectiveSwiftVersion == version)
42424242
}

Tests/SWBMacroTests/MacroBasicTests.swift

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,16 @@ import SWBMacro
2323
let namespace = MacroNamespace(debugDescription: "test")
2424

2525
let firstBoolDecl = try namespace.declareBooleanMacro("SomeBooleanMacro")
26-
#expect(firstBoolDecl != nil)
2726
#expect(firstBoolDecl.type == .boolean)
2827

2928
let repeatedBoolDecl = try namespace.declareBooleanMacro("SomeBooleanMacro")
30-
#expect(repeatedBoolDecl != nil)
3129
#expect(repeatedBoolDecl.type == .boolean)
3230
#expect(repeatedBoolDecl === firstBoolDecl)
3331

3432
var didCatchExpectedException: Bool = false
3533
do {
36-
let collidingStringDecl = try namespace.declareStringMacro("SomeBooleanMacro")
37-
#expect(collidingStringDecl == nil)
38-
}
39-
catch {
34+
_ = try namespace.declareStringMacro("SomeBooleanMacro")
35+
} catch {
4036
didCatchExpectedException = true
4137
}
4238
#expect(didCatchExpectedException)
@@ -48,27 +44,21 @@ import SWBMacro
4844
let namespace = MacroNamespace(debugDescription: "test")
4945

5046
let booleanDecl = try namespace.declareBooleanMacro("BooleanMacro")
51-
#expect(booleanDecl != nil)
5247
#expect(booleanDecl.type == .boolean)
5348

5449
let stringDecl = try namespace.declareStringMacro("StringMacro")
55-
#expect(stringDecl != nil)
5650
#expect(stringDecl.type == .string)
5751

5852
let stringListDecl = try namespace.declareStringListMacro("StringListMacro")
59-
#expect(stringListDecl != nil)
6053
#expect(stringListDecl.type == .stringList)
6154

6255
let userDefinedDecl = try namespace.declareUserDefinedMacro("UserDefinedMacro")
63-
#expect(userDefinedDecl != nil)
6456
#expect(userDefinedDecl.type == .userDefined)
6557

6658
let pathDecl = try namespace.declarePathMacro("PathMacro")
67-
#expect(pathDecl != nil)
6859
#expect(pathDecl.type == .path)
6960

7061
let pathListDecl = try namespace.declarePathListMacro("PathListMacro")
71-
#expect(pathListDecl != nil)
7262
#expect(pathListDecl.type == .pathList)
7363

7464
var diags1 = Array<MacroExpressionDiagnostic>()
@@ -116,19 +106,16 @@ import SWBMacro
116106

117107
// Declarate a string macro in the lower namespace.
118108
let lowerStringDecl = try lowerNamespace.declareStringMacro("StringMacro")
119-
#expect(lowerStringDecl != nil)
120109
#expect(lowerStringDecl.type == .string)
121110

122111
// Create the middle of the three namespaces, and make sure we can see the string macro declaration from the lower namespace.
123112
let middleNamespace = MacroNamespace(parent: lowerNamespace, debugDescription: "middle")
124113
let middleStringDecl = try middleNamespace.declareStringMacro("StringMacro")
125-
#expect(middleStringDecl != nil)
126114
#expect(middleStringDecl.type == .string)
127115
#expect(middleStringDecl === lowerStringDecl)
128116

129117
// Also declare a string list macro in the middle namespace.
130118
let middleStringListDecl = try middleNamespace.declareStringListMacro("StringListMacro")
131-
#expect(middleStringListDecl != nil)
132119
#expect(middleStringListDecl.type == .stringList)
133120

134121
// Make sure we cannot reach the middle-namespace string list macro declaration if we do the lookup from the lower namespace.
@@ -138,19 +125,16 @@ import SWBMacro
138125
// Create the upper of the three namespaces, and make sure we can see the string macro declaration from the lower namespace.
139126
let upperNamespace = MacroNamespace(parent: middleNamespace, debugDescription: "upper")
140127
let upperStringDecl = try upperNamespace.declareStringMacro("StringMacro")
141-
#expect(upperStringDecl != nil)
142128
#expect(upperStringDecl.type == .string)
143129
#expect(upperStringDecl === lowerStringDecl)
144130

145131
// Make sure we can also see the string list macro declaration from the middle namespace.
146132
let upperStringListDecl = try upperNamespace.declareStringListMacro("StringListMacro")
147-
#expect(upperStringListDecl != nil)
148133
#expect(upperStringListDecl.type == .stringList)
149134
#expect(upperStringListDecl === middleStringListDecl)
150135

151136
// Make sure we can also declare a boolean macro in the upper namespace.
152137
let upperBooleanDecl = try upperNamespace.declareBooleanMacro("BooleanMacro")
153-
#expect(upperBooleanDecl != nil)
154138
#expect(upperBooleanDecl.type == .boolean)
155139

156140
// Make sure we cannot reach the upper-namespace boolean macro declaration if we do the lookup from either the lower or the middle namespace.
@@ -161,7 +145,6 @@ import SWBMacro
161145

162146
// Make sure we can also declare a path macro in the upper namespace.
163147
let upperPathDecl = try upperNamespace.declarePathMacro("PathMacro")
164-
#expect(upperPathDecl != nil)
165148
#expect(upperPathDecl.type == .path)
166149

167150
// Make sure we cannot reach the upper-namespace path macro declaration if we do the lookup from either the lower or the middle namespace.
@@ -173,7 +156,6 @@ import SWBMacro
173156

174157
// Make sure we can also declare a path macro in the upper namespace.
175158
let upperPathListDecl = try upperNamespace.declarePathListMacro("PathListMacro")
176-
#expect(upperPathListDecl != nil)
177159
#expect(upperPathListDecl.type == .pathList)
178160

179161
// Make sure we cannot reach the upper-namespace path list macro declaration if we do the lookup from either the lower or the middle namespace.

Tests/SWBTaskConstructionTests/HeadermapTaskConstructionTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ fileprivate struct HeadermapTaskConstructionTests: CoreBasedTests {
374374
}
375375
}
376376
}
377-
#expect(hmapContents != nil)
378377
}
379378

380379
@Test(.requireSDKs(.macOS))

Tests/SWBTaskConstructionTests/SwiftModuleOnlyTaskConstructionTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ fileprivate struct SwiftModuleOnlyTaskConstructionTests: CoreBasedTests {
910910
if tpc.isZippered {
911911
try checkPlatform(
912912
tpc.secondaryPlatform,
913-
deploymentTarget: try #require(tpc.zipperedModuleOnlyDeploymentTarget))
913+
deploymentTarget: tpc.zipperedModuleOnlyDeploymentTarget)
914914
}
915915
}
916916
}

0 commit comments

Comments
 (0)