@@ -155,7 +155,7 @@ package final class BuildOperationTester {
155
155
case subtaskDidReportProgress( SubtaskProgressEvent , count: Int )
156
156
157
157
/// The build emitted a backtrace frame.
158
- case emittedBuildBacktraceFrame( identifier : SWBProtocol . BuildOperationBacktraceFrameEmitted . Identifier , previousFrameIdentifier : SWBProtocol . BuildOperationBacktraceFrameEmitted . Identifier ? , category : SWBProtocol . BuildOperationBacktraceFrameEmitted . Category , description : String )
158
+ case emittedBuildBacktraceFrame( BuildOperationBacktraceFrameEmitted )
159
159
160
160
package var description : String {
161
161
switch self {
@@ -189,8 +189,8 @@ package final class BuildOperationTester {
189
189
return " activityEmittedData( \( ruleInfo) , bytes: \( ByteString ( bytes) . asString) "
190
190
case . activityEnded( ruleInfo: let ruleInfo) :
191
191
return " activityEnded( \( ruleInfo) ) "
192
- case . emittedBuildBacktraceFrame( identifier : let id , previousFrameIdentifier : let previousID , category : let category , description : let description ) :
193
- return " emittedBuildBacktraceFrame( \( id ) , previous: \( String ( describing: previousID ) ) , category: \( category) , description: \( description) ) "
192
+ case . emittedBuildBacktraceFrame( let frame ) :
193
+ return " emittedBuildBacktraceFrame( \( frame . identifier ) , previous: \( String ( describing: frame . previousFrameIdentifier ) ) , category: \( frame . category) , description: \( frame . description) ) "
194
194
case . previouslyBatchedSubtaskUpToDate( let signature) :
195
195
return " previouslyBatchedSubtaskUpToDate( \( signature) ) "
196
196
}
@@ -735,18 +735,6 @@ package final class BuildOperationTester {
735
735
736
736
}
737
737
738
- package func checkNoTaskWithBacktraces( _ conditions: TaskCondition ... , sourceLocation: SourceLocation = #_sourceLocation) {
739
- for matchedTask in findMatchingTasks ( conditions) {
740
- Issue . record ( " found unexpected task matching conditions ' \( conditions) ', found: \( matchedTask) " , sourceLocation: sourceLocation)
741
-
742
- if let frameID = getBacktraceID ( matchedTask, sourceLocation: sourceLocation) {
743
- enumerateBacktraces ( frameID) { _, category, description in
744
- Issue . record ( " ...<category=' \( category) ' description=' \( description) '> " , sourceLocation: sourceLocation)
745
- }
746
- }
747
- }
748
- }
749
-
750
738
/// Check whether the results contains a dependency cycle error. If so, then consume the error and create a `CycleChecking` object and pass it to the block. Otherwise fail.
751
739
package func checkDependencyCycle( _ pattern: StringPattern , kind: DiagnosticKind = . error, failIfNotFound: Bool = true , sourceLocation: SourceLocation = #_sourceLocation, body: ( CycleChecker ) async throws -> Void ) async throws {
752
740
guard let message = getDiagnosticMessage ( pattern, kind: kind, checkDiagnostic: { _ in true } ) else {
@@ -1045,55 +1033,6 @@ package final class BuildOperationTester {
1045
1033
startedTasks. remove ( task)
1046
1034
}
1047
1035
1048
- private func getBacktraceID( _ task: Task, sourceLocation: SourceLocation = #_sourceLocation) -> BuildOperationBacktraceFrameEmitted. Identifier? {
1049
- guard let frameID: BuildOperationBacktraceFrameEmitted . Identifier = events. compactMap ( { ( event) -> BuildOperationBacktraceFrameEmitted . Identifier ? in
1050
- guard case . emittedBuildBacktraceFrame( identifier: let identifier, previousFrameIdentifier: _, category: _, description: _) = event, case . task( let signature) = identifier, BuildOperationTaskSignature . taskIdentifier ( ByteString ( encodingAsUTF8: task. identifier. rawValue) ) == signature else {
1051
- return nil
1052
- }
1053
- return identifier
1054
- // Iff the task is a dynamic task, there may be more than one corresponding frame if it was requested multiple times, in which case we choose the first. Non-dynamic tasks always have a 1-1 relationship with frames.
1055
- } ) . sorted ( ) . first else {
1056
- Issue . record ( " Did not find a single build backtrace frame for task: \( task. identifier) " , sourceLocation: sourceLocation)
1057
- return nil
1058
- }
1059
- return frameID
1060
- }
1061
-
1062
- private func enum erateBacktraces( _ identifier: BuildOperationBacktraceFrameEmitted . Identifier, _ handleFrameInfo: ( _ identifier: BuildOperationBacktraceFrameEmitted . Identifier? , _ category: BuildOperationBacktraceFrameEmitted . Category, _ description: String) - > ( ) ) {
1063
- var currentFrameID : BuildOperationBacktraceFrameEmitted . Identifier ? = identifier
1064
- while let id = currentFrameID {
1065
- if let frameInfo: ( BuildOperationBacktraceFrameEmitted . Identifier ? , BuildOperationBacktraceFrameEmitted . Category , String ) = events. compactMap ( { ( event) -> ( BuildOperationBacktraceFrameEmitted . Identifier ? , BuildOperationBacktraceFrameEmitted . Category , String ) ? in
1066
- guard case . emittedBuildBacktraceFrame( identifier: id, previousFrameIdentifier: let previousFrameIdentifier, category: let category, description: let description) = event else {
1067
- return nil
1068
- }
1069
- return ( previousFrameIdentifier, category, description)
1070
- // Iff the task is a dynamic task, there may be more than one corresponding frame if it was requested multiple times, in which case we choose the first. Non-dynamic tasks always have a 1-1 relationship with frames.
1071
- } ) . sorted ( by: { $0. 0 } ) . first {
1072
- handleFrameInfo ( frameInfo. 0 , frameInfo. 1 , frameInfo. 2 )
1073
- currentFrameID = frameInfo. 0
1074
- } else {
1075
- currentFrameID = nil
1076
- }
1077
- }
1078
- }
1079
-
1080
- package func checkBacktrace( _ identifier: BuildOperationBacktraceFrameEmitted . Identifier, _ patterns: [ StringPattern] , sourceLocation: SourceLocation = #_sourceLocation) {
1081
- var frameDescriptions : [ String ] = [ ]
1082
- enumerateBacktraces ( identifier) { ( _, category, description) in
1083
- frameDescriptions. append ( " <category=' \( category) ' description=' \( description) '> " )
1084
- }
1085
-
1086
- XCTAssertMatch ( frameDescriptions, patterns, sourceLocation: sourceLocation)
1087
- }
1088
-
1089
- package func checkBacktrace( _ task: Task, _ patterns: [ StringPattern] , sourceLocation: SourceLocation = #_sourceLocation) {
1090
- if let frameID = getBacktraceID ( task, sourceLocation: sourceLocation) {
1091
- checkBacktrace ( frameID, patterns, sourceLocation: sourceLocation)
1092
- } else {
1093
- // already recorded an issue
1094
- }
1095
- }
1096
-
1097
1036
private class TaskDependencyResolver {
1098
1037
/// The database schema has to match what `BuildSystemImpl` defines in `getMergedSchemaVersion()`.
1099
1038
/// Can be removed once rdar://85336712 is resolved.
@@ -1563,42 +1502,6 @@ package final class BuildOperationTester {
1563
1502
}
1564
1503
}
1565
1504
1566
- /// Ensure that the build is a null build.
1567
- package func checkNullBuild( _ name: String? = nil , parameters: BuildParameters? = nil , runDestination: RunDestinationInfo? , buildRequest inputBuildRequest: BuildRequest? = nil , buildCommand: BuildCommand? = nil , schemeCommand: SchemeCommand? = . launch, persistent: Bool = false , serial: Bool = false , buildOutputMap: [ String: String] ? = nil , signableTargets: Set< String> = [ ] , signableTargetInputs: [ String: ProvisioningTaskInputs] = [ : ] , clientDelegate: ( any ClientDelegate ) ? = nil , excludedTasks: Set< String> = [ " ClangStatCache " , " LinkAssetCatalogSignature " ] , diagnosticsToValidate: Set< DiagnosticKind> = [ . note, . error, . warning] , sourceLocation: SourceLocation = #_sourceLocation) async throws {
1568
-
1569
- func body( results: BuildResults ) throws -> Void {
1570
- results. consumeTasksMatchingRuleTypes ( excludedTasks)
1571
- results. checkNoTaskWithBacktraces ( sourceLocation: sourceLocation)
1572
-
1573
- results. checkNote ( . equal( " Building targets in dependency order " ) , failIfNotFound: false )
1574
- results. checkNote ( . prefix( " Target dependency graph " ) , failIfNotFound: false )
1575
-
1576
- for kind in diagnosticsToValidate {
1577
- switch kind {
1578
- case . note:
1579
- results. checkNoNotes ( sourceLocation: sourceLocation)
1580
-
1581
- case . warning:
1582
- results. checkNoWarnings ( sourceLocation: sourceLocation)
1583
-
1584
- case . error:
1585
- results. checkNoErrors ( sourceLocation: sourceLocation)
1586
-
1587
- case . remark:
1588
- results. checkNoRemarks ( sourceLocation: sourceLocation)
1589
-
1590
- default :
1591
- // other kinds are ignored
1592
- break
1593
- }
1594
- }
1595
- }
1596
-
1597
- try await UserDefaults . withEnvironment ( [ " EnableBuildBacktraceRecording " : " true " ] ) {
1598
- try await checkBuild ( name, parameters: parameters, runDestination: runDestination, buildRequest: inputBuildRequest, buildCommand: buildCommand, schemeCommand: schemeCommand, persistent: persistent, serial: serial, buildOutputMap: buildOutputMap, signableTargets: signableTargets, signableTargetInputs: signableTargetInputs, clientDelegate: clientDelegate, sourceLocation: sourceLocation, body: body)
1599
- }
1600
- }
1601
-
1602
1505
package static func buildRequestForIndexOperation(
1603
1506
workspace: Workspace,
1604
1507
buildTargets: [ any TestTarget ] ? = nil ,
@@ -2252,7 +2155,7 @@ private final class BuildOperationTesterDelegate: BuildOperationDelegate {
2252
2155
2253
2156
func recordBuildBacktraceFrame( identifier: SWBProtocol . BuildOperationBacktraceFrameEmitted . Identifier , previousFrameIdentifier: SWBProtocol . BuildOperationBacktraceFrameEmitted . Identifier ? , category: SWBProtocol . BuildOperationBacktraceFrameEmitted . Category , kind: SWBProtocol . BuildOperationBacktraceFrameEmitted . Kind , description: String ) {
2254
2157
queue. async {
2255
- self . events. append ( . emittedBuildBacktraceFrame( identifier: identifier, previousFrameIdentifier: previousFrameIdentifier, category: category, description: description) )
2158
+ self . events. append ( . emittedBuildBacktraceFrame( . init ( identifier: identifier, previousFrameIdentifier: previousFrameIdentifier, category: category, kind : kind , description: description) ) )
2256
2159
}
2257
2160
}
2258
2161
}
0 commit comments