Skip to content

Commit ddc2552

Browse files
committed
Eliminate print() debugging statements
Library and test code should not be printing to the console.
1 parent ee41322 commit ddc2552

File tree

8 files changed

+16
-43
lines changed

8 files changed

+16
-43
lines changed

Sources/SWBCore/Specs/PropertyDomainSpec.swift

-5
Original file line numberDiff line numberDiff line change
@@ -1283,11 +1283,6 @@ private let buildOptionTypes: [String: any BuildOptionType] = [
12831283
/// Get the command line arguments to use for this option in the given context.
12841284
func getArgumentsForCommand(_ producer: any CommandProducer, scope: MacroEvaluationScope, inputFileType: FileTypeSpec?, optionContext: (any BuildOptionGenerationContext)?, lookup: ((MacroDeclaration) -> MacroExpression?)?) -> [CommandLineArgument] {
12851285
// Filter by supported architecture.
1286-
1287-
if self.name == "ASSETCATALOG_COMPILER_INPUTS" {
1288-
print()
1289-
}
1290-
12911286
guard supportsArchitecture(scope.evaluate(BuiltinMacros.CURRENT_ARCH)) else {
12921287
return []
12931288
}

Sources/SWBTestSupport/PerfTestSupport.swift

+9
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,12 @@ extension Trait where Self == Testing.ConditionTrait {
4848
}
4949
}
5050
}
51+
52+
// Used to make printing for debugging purposes easier.
53+
private let shouldPrint = getEnvironmentVariable("SWB_PERF_TESTS_ENABLE_DEBUG_PRINT")?.boolValue ?? false
54+
55+
public func perfPrint(_ message: String) {
56+
if shouldPrint {
57+
print(message)
58+
}
59+
}

Tests/SWBBuildSystemTests/HostBuildToolBuildOperationTests.swift

+2-6
Original file line numberDiff line numberDiff line change
@@ -731,9 +731,7 @@ fileprivate struct HostBuildToolBuildOperationTests: CoreBasedTests {
731731

732732
// The tool itself should compile and link.
733733
results.checkTaskExists(.matchTargetName("Tool"), .matchRuleType("SwiftDriver Compilation"))
734-
results.checkTask(.matchTargetName("Tool"), .matchRuleType("Ld")) {
735-
print(Array($0.commandLineAsStrings))
736-
}
734+
results.checkTask(.matchTargetName("Tool"), .matchRuleType("Ld")) { _ in }
737735

738736
try results.checkTask(.matchTargetName("Framework"), .matchRuleType(ProductPlan.preparedForIndexPreCompilationRuleName)) { task in
739737
try results.checkTaskFollows(task, .matchTargetName("Tool"), .matchRuleType("Ld"))
@@ -816,9 +814,7 @@ fileprivate struct HostBuildToolBuildOperationTests: CoreBasedTests {
816814

817815
// The tool itself should compile and link.
818816
results.checkTaskExists(.matchTargetName("Tool"), .matchRuleType("SwiftDriver Compilation"))
819-
results.checkTask(.matchTargetName("Tool"), .matchRuleType("Ld")) {
820-
print(Array($0.commandLineAsStrings))
821-
}
817+
results.checkTask(.matchTargetName("Tool"), .matchRuleType("Ld")) { _ in }
822818

823819
try results.checkTask(.matchTargetName("Framework"), .matchRuleType(ProductPlan.preparedForIndexPreCompilationRuleName)) { task in
824820
try results.checkTaskFollows(task, .matchTargetName("Tool"), .matchRuleType("Ld"))

Tests/SWBCorePerfTests/MacroExpressionParsingPerfTests.swift

-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ fileprivate struct MacroExpressionParsingPerfTests: CoreBasedTests, PerfTests {
145145
}
146146

147147
func handleDiagnostic(_ diagnostic: MacroExpressionDiagnostic, parser: MacroExpressionParser) {
148-
print(diagnostic)
149148
}
150149
}
151150
for str in stringsToParseCopy {

Tests/SWBCorePerfTests/SerializationPerfTests.swift

+3-8
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ fileprivate struct SerializationPerfTests: CoreBasedTests, PerfTests {
4242

4343
func _testSerializingTargetScopePerf_XXX(numberOfTargets: Int) async throws {
4444
try await withTemporaryDirectory { tmpDirPath in
45-
// Used to make printing for debugging purposes easier.
46-
let shouldPrint = false
4745
let didEmitSerializedSize = SWBMutex(false)
4846

4947
let scope = try await createTestScope(tmpDirPath: tmpDirPath)
@@ -60,8 +58,7 @@ fileprivate struct SerializationPerfTests: CoreBasedTests, PerfTests {
6058

6159
if !didEmitSerializedSize.withLock({ $0 }) {
6260
let mb = accumulatedBytes / (1000.0 * 1000.0)
63-
if shouldPrint { print("Serialized \(mb) megabytes for \(numberOfTargets) targets") }
64-
_ = mb
61+
perfPrint("Serialized \(mb) megabytes for \(numberOfTargets) targets")
6562
didEmitSerializedSize.withLock { $0 = true }
6663
}
6764
}
@@ -91,8 +88,7 @@ fileprivate struct SerializationPerfTests: CoreBasedTests, PerfTests {
9188
let sz = self.serializeMacroEvaluationScope(scope)
9289

9390
let mb = Float64(sz.byteString.bytes.count) / (1000.0 * 1000.0)
94-
//print("Will deserialize \(mb) megabytes")
95-
_ = mb
91+
perfPrint("Will deserialize \(mb) megabytes")
9692

9793
let delegate = MacroEvaluationScopeDeserializerDelegate(namespace: scope.namespace)
9894

@@ -117,8 +113,7 @@ fileprivate struct SerializationPerfTests: CoreBasedTests, PerfTests {
117113
let sz = self.serializeMacroEvaluationScope(scope)
118114

119115
let mb = Float64(sz.byteString.bytes.count) / (1000.0 * 1000.0)
120-
//print("Will deserialize \(mb) megabytes")
121-
_ = mb
116+
perfPrint("Will deserialize \(mb) megabytes")
122117

123118
let delegate = MacroEvaluationScopeDeserializerDelegate(namespace: scope.namespace)
124119

Tests/SWBTaskConstructionTests/EagerLinkingTests.swift

-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ fileprivate struct EagerLinkingTests: CoreBasedTests {
165165
func objCLinkerInputsReadyDependsOnLipo() async throws {
166166
let tester = try await TaskConstructionTester(getCore(), objcTestProject)
167167
try await tester.checkBuild(BuildParameters(configuration: "Debug", activeRunDestination: .anyMac, overrides: ["ARCHS": "arm64 x86_64"])) { results in
168-
print(results)
169168
let linkBTask = try #require(results.getTask(.matchTargetName("B"), .matchRuleItem("Ld"), .matchRuleItem("x86_64")))
170169
let linkBTask2 = try #require(results.getTask(.matchTargetName("B"), .matchRuleItem("Ld"), .matchRuleItem("x86_64")))
171170
let lipoBTask = try #require(results.getTask(.matchTargetName("B"), .matchRuleType("CreateUniversalBinary")))

Tests/SWBTaskConstructionTests/ModuleVerifierTaskConstructionTests.swift

-20
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,6 @@ fileprivate struct ModuleVerifierTaskConstructionTests: CoreBasedTests {
146146
let arch = results.runDestinationTargetArchitecture
147147
results.checkNoDiagnostics()
148148

149-
for task in results.uncheckedTasks {
150-
print(task.ruleInfo)
151-
}
152-
153149
results.checkTarget(targetName) { target in
154150
results.checkTasks(.matchRuleType("VerifyModuleC")) {tasks in
155151
#expect(tasks.count == 6)
@@ -367,10 +363,6 @@ fileprivate struct ModuleVerifierTaskConstructionTests: CoreBasedTests {
367363
await tester.checkBuild() { results in
368364
results.checkNoDiagnostics()
369365

370-
for task in results.uncheckedTasks {
371-
print(task.ruleInfo)
372-
}
373-
374366
results.checkTarget(targetName) { target in
375367
results.checkTask(.matchRuleType("VerifyModuleC")) { task in
376368
task.checkCommandLineContains([
@@ -469,10 +461,6 @@ fileprivate struct ModuleVerifierTaskConstructionTests: CoreBasedTests {
469461
await tester.checkBuild() { results in
470462
results.checkNoDiagnostics()
471463

472-
for task in results.uncheckedTasks {
473-
print(task.ruleInfo)
474-
}
475-
476464
results.checkTarget(targetName) { target in
477465
results.checkTasks(.matchRuleType("VerifyModuleC")) { tasks in
478466
#expect(tasks.count == 2)
@@ -590,10 +578,6 @@ fileprivate struct ModuleVerifierTaskConstructionTests: CoreBasedTests {
590578
await tester.checkBuild() { results in
591579
results.checkNoDiagnostics()
592580

593-
for task in results.uncheckedTasks {
594-
print(task.ruleInfo)
595-
}
596-
597581
results.checkTarget(targetName) { target in
598582
results.checkTask(.matchRuleType("VerifyModuleC")) { task in
599583
let targetVariant = task.ruleInfo[2]
@@ -659,10 +643,6 @@ fileprivate struct ModuleVerifierTaskConstructionTests: CoreBasedTests {
659643
let arch = results.runDestinationTargetArchitecture
660644
results.checkNoDiagnostics()
661645

662-
for task in results.uncheckedTasks {
663-
print(task.ruleInfo)
664-
}
665-
666646
results.checkTarget(targetName) { target in
667647
results.checkTasks(.matchRuleType("VerifyModuleC")) {tasks in
668648
var ruleInfos: Set<[String]> = []

Tests/SWBUtilPerfTests/MsgPackSerializationPerfTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ fileprivate struct MsgPackSerializationPerfTests: PerfTests {
306306
if !didEmitSerializedSize
307307
{
308308
let mb = Float64(sz.byteString.bytes.count) / (1000.0 * 1000.0)
309-
print("Serialized \(mb) megabytes")
309+
perfPrint("Serialized \(mb) megabytes")
310310
didEmitSerializedSize = true
311311
}
312312
}
@@ -322,7 +322,7 @@ fileprivate struct MsgPackSerializationPerfTests: PerfTests {
322322
let sz = serializeCustomElementHierarchy(log)
323323

324324
let mb = Float64(sz.byteString.bytes.count) / (1000.0 * 1000.0)
325-
print("Will deserialize \(mb) megabytes")
325+
perfPrint("Will deserialize \(mb) megabytes")
326326

327327
try await measure {
328328
for _ in 1...iterations {

0 commit comments

Comments
 (0)