@@ -33,6 +33,7 @@ import Workspace
33
33
import XCTest
34
34
35
35
import struct TSCBasic. ByteString
36
+ import func TSCBasic. withTemporaryFile
36
37
37
38
import enum TSCUtility. Diagnostics
38
39
@@ -785,6 +786,7 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
785
786
exe,
786
787
[
787
788
" -enable-batch-mode " ,
789
+ " -serialize-diagnostics " ,
788
790
" -Onone " ,
789
791
" -enable-testing " ,
790
792
. equal( self . j) ,
@@ -803,6 +805,7 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
803
805
lib,
804
806
[
805
807
" -enable-batch-mode " ,
808
+ " -serialize-diagnostics " ,
806
809
" -Onone " ,
807
810
" -enable-testing " ,
808
811
. equal( self . j) ,
@@ -1854,6 +1857,7 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
1854
1857
[
1855
1858
. anySequence,
1856
1859
" -enable-batch-mode " ,
1860
+ " -serialize-diagnostics " ,
1857
1861
" -Onone " ,
1858
1862
" -enable-testing " ,
1859
1863
. equal( self . j) ,
@@ -2355,6 +2359,7 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
2355
2359
[
2356
2360
. anySequence,
2357
2361
" -enable-batch-mode " ,
2362
+ " -serialize-diagnostics " ,
2358
2363
" -Onone " ,
2359
2364
" -enable-testing " ,
2360
2365
. equal( self . j) ,
@@ -2374,6 +2379,7 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
2374
2379
[
2375
2380
. anySequence,
2376
2381
" -enable-batch-mode " ,
2382
+ " -serialize-diagnostics " ,
2377
2383
" -Onone " ,
2378
2384
" -enable-testing " ,
2379
2385
" -Xfrontend " ,
@@ -2852,6 +2858,7 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
2852
2858
let matchText = try result. moduleBuildDescription ( for: " exe " ) . swift ( ) . compileArguments ( )
2853
2859
let assertionText : [ StringPattern ] = [
2854
2860
" -enable-batch-mode " ,
2861
+ " -serialize-diagnostics " ,
2855
2862
" -Onone " ,
2856
2863
" -enable-testing " ,
2857
2864
. equal( self . j) ,
@@ -3153,6 +3160,7 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
3153
3160
exe,
3154
3161
[
3155
3162
" -enable-batch-mode " ,
3163
+ " -serialize-diagnostics " ,
3156
3164
" -Onone " ,
3157
3165
" -enable-testing " ,
3158
3166
. equal( self . j) ,
@@ -3171,6 +3179,7 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
3171
3179
lib,
3172
3180
[
3173
3181
" -enable-batch-mode " ,
3182
+ " -serialize-diagnostics " ,
3174
3183
" -Onone " ,
3175
3184
" -enable-testing " ,
3176
3185
. equal( self . j) ,
@@ -3811,6 +3820,7 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
3811
3820
let exe = try result. moduleBuildDescription ( for: " exe " ) . swift ( ) . compileArguments ( )
3812
3821
XCTAssertMatch ( exe, [
3813
3822
" -enable-batch-mode " ,
3823
+ " -serialize-diagnostics " ,
3814
3824
" -Onone " ,
3815
3825
" -enable-testing " ,
3816
3826
. equal( self . j) ,
@@ -6975,6 +6985,59 @@ class BuildPlanTestCase: BuildSystemProviderTestCase {
6975
6985
print ( myLib. additionalFlags)
6976
6986
XCTAssertFalse ( myLib. additionalFlags. contains ( where: { $0. contains ( " -tool/include " ) } ) , " flags shouldn't contain tools items " )
6977
6987
}
6988
+
6989
+ func testDiagnosticsAreMentionedInOutputsFileMap( ) async throws {
6990
+ let fs = InMemoryFileSystem (
6991
+ emptyFiles:
6992
+ " /Pkg/Sources/exe/main.swift " ,
6993
+ " /Pkg/Sources/exe/aux.swift " ,
6994
+ " /Pkg/Sources/lib/lib.swift "
6995
+ )
6996
+
6997
+ let observability = ObservabilitySystem . makeForTesting ( )
6998
+ let graph = try loadModulesGraph (
6999
+ fileSystem: fs,
7000
+ manifests: [
7001
+ Manifest . createRootManifest (
7002
+ displayName: " Pkg " ,
7003
+ path: " /Pkg " ,
7004
+ targets: [
7005
+ TargetDescription ( name: " exe " , dependencies: [ " lib " ] ) ,
7006
+ TargetDescription ( name: " lib " , dependencies: [ ] ) ,
7007
+ ]
7008
+ ) ,
7009
+ ] ,
7010
+ observabilityScope: observability. topScope
7011
+ )
7012
+ XCTAssertNoDiagnostics ( observability. diagnostics)
7013
+
7014
+ let plan = try await mockBuildPlan (
7015
+ graph: graph,
7016
+ linkingParameters: . init(
7017
+ shouldLinkStaticSwiftStdlib: true
7018
+ ) ,
7019
+ fileSystem: fs,
7020
+ observabilityScope: observability. topScope
7021
+ )
7022
+ let result = try BuildPlanResult ( plan: plan)
7023
+
7024
+ result. checkProductsCount ( 1 )
7025
+ result. checkTargetsCount ( 2 )
7026
+
7027
+ for module in result. targetMap {
7028
+ let buildDescription = try module. swift ( )
7029
+
7030
+ try withTemporaryFile { file in
7031
+ try buildDescription. writeOutputFileMap ( to: . init( file. path. pathString) )
7032
+
7033
+ let fileMap = try String ( bytes: fs. readFileContents ( file. path) . contents, encoding: . utf8)
7034
+
7035
+ for diagnosticFile in buildDescription. diagnosticFiles {
7036
+ XCTAssertMatch ( fileMap, . contains( diagnosticFile. pathString) )
7037
+ }
7038
+ }
7039
+ }
7040
+ }
6978
7041
}
6979
7042
6980
7043
class BuildPlanNativeTests : BuildPlanTestCase {
0 commit comments