@@ -121,11 +121,11 @@ fileprivate struct BuildBacktraceTests: CoreBasedTests {
121121 results. checkTask ( . matchTargetName( " TargetBar " ) , . matchRuleType( " Ld " ) ) { task in
122122 results. checkBacktrace ( task, [
123123 " <category='ruleInputRebuilt' description='an input of 'Link TargetBar (x86_64)' changed'> " ,
124- " <category='ruleInputRebuilt' description='the producer of file ' \( SRCROOT . str) /build/EagerLinkingTBDs/Debug/TargetFoo.framework/Versions/A/TargetFoo.tbd' ran'> " ,
124+ " <category='ruleInputRebuilt' description='the task producing file ' \( SRCROOT . str) /build/EagerLinkingTBDs/Debug/TargetFoo.framework/Versions/A/TargetFoo.tbd' ran'> " ,
125125 " <category='ruleInputRebuilt' description='an input of 'Generate TBD TargetFoo' changed'> " ,
126- " <category='ruleInputRebuilt' description='the producer of file ' \( SRCROOT . str) /build/Debug/TargetFoo.framework/Versions/A/TargetFoo' ran'> " ,
126+ " <category='ruleInputRebuilt' description='the task producing file ' \( SRCROOT . str) /build/Debug/TargetFoo.framework/Versions/A/TargetFoo' ran'> " ,
127127 " <category='ruleInputRebuilt' description='an input of 'Link TargetFoo (x86_64)' changed'> " ,
128- " <category='ruleInputRebuilt' description='the producer of file ' \( SRCROOT . str) /build/aProject.build/Debug/TargetFoo.build/Objects-normal/x86_64/foo.o' ran'> " ,
128+ " <category='ruleInputRebuilt' description='the task producing file ' \( SRCROOT . str) /build/aProject.build/Debug/TargetFoo.build/Objects-normal/x86_64/foo.o' ran'> " ,
129129 " <category='ruleInputRebuilt' description='an input of 'Compile foo.c (x86_64)' changed'> " ,
130130 " <category='ruleHadInvalidValue' description='file ' \( SRCROOT . str) /Sources/foo.c' changed'> "
131131 ] )
@@ -139,8 +139,8 @@ fileprivate struct BuildBacktraceTests: CoreBasedTests {
139139 results. checkTask ( . matchTargetName( " TargetFoo " ) , . matchRuleType( " CompileC " ) ) { task in
140140 results. checkBacktrace ( task, [
141141 " <category='ruleInputRebuilt' description='an input of 'Compile foo.c (x86_64)' changed'> " ,
142- " <category='ruleInputRebuilt' description='the producer of file ' \( SRCROOT . str) /build/aProject.build/Debug/TargetFoo.build/Objects-normal/x86_64/7187679823f38a2a940e0043cdf9d637-common-args.resp' ran'> " ,
143- " <category='ruleSignatureChanged' description='signature of 'Write 7187679823f38a2a940e0043cdf9d637-common-args.resp (x86_64)' changed'> "
142+ " <category='ruleInputRebuilt' description='the task producing file ' \( SRCROOT . str) /build/aProject.build/Debug/TargetFoo.build/Objects-normal/x86_64/7187679823f38a2a940e0043cdf9d637-common-args.resp' ran'> " ,
143+ " <category='ruleSignatureChanged' description='arguments, environment, or working directory of 'Write 7187679823f38a2a940e0043cdf9d637-common-args.resp (x86_64)' changed'> "
144144 ] )
145145 }
146146 if tester. fs. fileSystemMode == . checksumOnly {
@@ -155,10 +155,10 @@ fileprivate struct BuildBacktraceTests: CoreBasedTests {
155155 results. checkTask ( . matchTargetName( " TargetBar " ) , . matchRuleType( " Ld " ) ) { task in
156156 results. checkBacktrace ( task, [
157157 " <category='ruleInputRebuilt' description='an input of 'Link TargetBar (x86_64)' changed'> " ,
158- " <category='ruleInputRebuilt' description='the producer of file ' \( SRCROOT . str) /build/aProject.build/Debug/TargetBar.build/Objects-normal/x86_64/bar.o' ran'> " ,
158+ " <category='ruleInputRebuilt' description='the task producing file ' \( SRCROOT . str) /build/aProject.build/Debug/TargetBar.build/Objects-normal/x86_64/bar.o' ran'> " ,
159159 " <category='ruleInputRebuilt' description='an input of 'Compile bar.c (x86_64)' changed'> " ,
160- " <category='ruleInputRebuilt' description='the producer of file ' \( SRCROOT . str) /build/aProject.build/Debug/TargetBar.build/Objects-normal/x86_64/7187679823f38a2a940e0043cdf9d637-common-args.resp' ran'> " ,
161- " <category='ruleSignatureChanged' description='signature of 'Write 7187679823f38a2a940e0043cdf9d637-common-args.resp (x86_64)' changed'> "
160+ " <category='ruleInputRebuilt' description='the task producing file ' \( SRCROOT . str) /build/aProject.build/Debug/TargetBar.build/Objects-normal/x86_64/7187679823f38a2a940e0043cdf9d637-common-args.resp' ran'> " ,
161+ " <category='ruleSignatureChanged' description='arguments, environment, or working directory of 'Write 7187679823f38a2a940e0043cdf9d637-common-args.resp (x86_64)' changed'> "
162162 ] )
163163 }
164164 }
@@ -320,7 +320,7 @@ fileprivate struct BuildBacktraceTests: CoreBasedTests {
320320 results. checkNoDiagnostics ( )
321321 results. checkTask ( . matchTargetName( " TargetFoo " ) , . matchRuleType( " CompileC " ) ) { task in
322322 results. checkBacktrace ( task, [
323- " <category='ruleHadInvalidValue' description=''Compile foo.c (x86_64)' did not have up-to-date outputs '> " ,
323+ " <category='ruleHadInvalidValue' description='outputs of 'Compile foo.c (x86_64)' were missing or modified '> " ,
324324 ] )
325325 }
326326 }
@@ -374,7 +374,7 @@ fileprivate struct BuildBacktraceTests: CoreBasedTests {
374374 results. checkNoDiagnostics ( )
375375 results. checkTask ( . matchTargetName( " TargetFoo " ) , . matchRuleType( " PhaseScriptExecution " ) ) { task in
376376 results. checkBacktrace ( task, [
377- " <category='ruleHadInvalidValue' description=''Run custom shell script 'Script'' is configured to run in every incremental build'> "
377+ " <category='ruleHadInvalidValue' description=''Run custom shell script 'Script'' was configured to run in every incremental build'> "
378378 ] )
379379 }
380380 }
@@ -471,4 +471,107 @@ fileprivate struct BuildBacktraceTests: CoreBasedTests {
471471 }
472472 }
473473 }
474+
475+ @Test ( . requireSDKs( . macOS) )
476+ func backtraceTextRendering( ) async throws {
477+ try await withTemporaryDirectory { tmpDirPath async throws -> Void in
478+ let testWorkspace = TestWorkspace (
479+ " Test " ,
480+ sourceRoot: tmpDirPath. join ( " Test " ) ,
481+ projects: [
482+ TestProject (
483+ " aProject " ,
484+ groupTree: TestGroup (
485+ " Sources " ,
486+ path: " Sources " ,
487+ children: [
488+ TestFile ( " foo.c " ) ,
489+ TestFile ( " bar.c " ) ,
490+ ] ) ,
491+ buildConfigurations: [
492+ TestBuildConfiguration (
493+ " Debug " ,
494+ buildSettings: [
495+ " PRODUCT_NAME " : " $(TARGET_NAME) " ,
496+ ] )
497+ ] ,
498+ targets: [
499+ TestStandardTarget (
500+ " TargetFoo " ,
501+ type: . framework,
502+ buildPhases: [
503+ TestSourcesBuildPhase ( [
504+ " foo.c " ,
505+ ] ) ,
506+ ] ) ,
507+ TestStandardTarget (
508+ " TargetBar " ,
509+ type: . framework,
510+ buildPhases: [
511+ TestSourcesBuildPhase ( [
512+ " bar.c " ,
513+ ] ) ,
514+ TestFrameworksBuildPhase ( [
515+ " TargetFoo.framework "
516+ ] )
517+ ] , dependencies: [ " TargetFoo " ] ) ,
518+ ] )
519+ ] )
520+
521+ let tester = try await BuildOperationTester ( getCore ( ) , testWorkspace, simulated: false , fileSystem: localFS)
522+ let parameters = BuildParameters ( configuration: " Debug " )
523+ let buildRequest = BuildRequest ( parameters: parameters, buildTargets: tester. workspace. projects [ 0 ] . targets. map ( { BuildRequest . BuildTargetInfo ( parameters: parameters, target: $0) } ) , dependencyScope: . workspace, continueBuildingAfterErrors: true , useParallelTargets: true , useImplicitDependencies: false , useDryRun: false )
524+ let SRCROOT = testWorkspace. sourceRoot. join ( " aProject " )
525+
526+ // Create the source files.
527+ try await tester. fs. writeFileContents ( SRCROOT . join ( " Sources/foo.c " ) ) { file in
528+ file <<<
529+ """
530+ int foo(void) {
531+ return 1;
532+ }
533+ """
534+ }
535+ try await tester. fs. writeFileContents ( SRCROOT . join ( " Sources/bar.c " ) ) { file in
536+ file <<<
537+ """
538+ int bar(void) {
539+ return 2;
540+ }
541+ """
542+ }
543+
544+ try await tester. checkBuild ( runDestination: . macOS, buildRequest: buildRequest, persistent: true ) { results in
545+ results. checkNoDiagnostics ( )
546+ }
547+
548+ try await tester. checkNullBuild ( runDestination: . macOS, buildRequest: buildRequest, persistent: true )
549+
550+ try await tester. fs. writeFileContents ( SRCROOT . join ( " Sources/foo.c " ) ) { file in
551+ file <<<
552+ """
553+ int foo2(void) {
554+ return 42;
555+ }
556+ """
557+ }
558+
559+ try await tester. checkBuild ( runDestination: . macOS, buildRequest: buildRequest, persistent: true ) { results in
560+ results. checkNoDiagnostics ( )
561+ results. checkTask ( . matchTargetName( " TargetBar " ) , . matchRuleType( " Ld " ) ) { task in
562+ results. checkTextualBacktrace ( task, """
563+ #0: an input of 'Link TargetBar (x86_64)' changed
564+ #1: the task producing file ' \( SRCROOT . str) /build/EagerLinkingTBDs/Debug/TargetFoo.framework/Versions/A/TargetFoo.tbd' ran
565+ #2: an input of 'Generate TBD TargetFoo' changed
566+ #3: the task producing file ' \( SRCROOT . str) /build/Debug/TargetFoo.framework/Versions/A/TargetFoo' ran
567+ #4: an input of 'Link TargetFoo (x86_64)' changed
568+ #5: the task producing file ' \( SRCROOT . str) /build/aProject.build/Debug/TargetFoo.build/Objects-normal/x86_64/foo.o' ran
569+ #6: an input of 'Compile foo.c (x86_64)' changed
570+ #7: file ' \( SRCROOT . str) /Sources/foo.c' changed
571+
572+ """ )
573+ }
574+ }
575+ }
576+ }
474577}
0 commit comments