@@ -1125,7 +1125,96 @@ struct BuildCommandTestCases {
1125
1125
}
1126
1126
}
1127
1127
1128
-
1128
+ private static func buildSystemAndOutputLocation( ) throws -> [ ( BuildSystemProvider . Kind , Basics . RelativePath ) ] {
1129
+ return try SupportedBuildSystemOnPlatform . map { buildSystem in
1130
+ switch buildSystem {
1131
+ case . xcode:
1132
+ return (
1133
+ . xcode,
1134
+ try RelativePath ( validating: " .build " )
1135
+ . appending ( " apple " )
1136
+ . appending ( " Products " )
1137
+ . appending ( " Debug " )
1138
+ . appending ( " ExecutableNew " )
1139
+ )
1140
+ case . swiftbuild:
1141
+ let triple = try UserToolchain . default. targetTriple. withoutVersion ( ) . tripleString
1142
+ return (
1143
+ . swiftbuild,
1144
+ try RelativePath ( validating: " .build " )
1145
+ . appending ( triple)
1146
+ . appending ( " Products " )
1147
+ . appending ( " Debug " )
1148
+ . appending ( " ExecutableNew " )
1149
+ )
1150
+ case . native:
1151
+ return (
1152
+ . native,
1153
+ try RelativePath ( validating: " .build " )
1154
+ . appending ( " debug " )
1155
+ . appending ( " ExecutableNew.build " )
1156
+ . appending ( " main.swift.o " )
1157
+ )
1158
+ }
1159
+ }
1160
+ }
1161
+
1162
+ @Test ( arguments: try buildSystemAndOutputLocation ( ) )
1163
+ func doesNotRebuildWithVerboseFlag(
1164
+ buildSystem: BuildSystemProvider . Kind ,
1165
+ outputFile: Basics . RelativePath
1166
+ ) async throws {
1167
+ try await fixture ( name: " ValidLayouts/SingleModule/ExecutableNew " ) { fixturePath in
1168
+ _ = try await self . build (
1169
+ [ ] ,
1170
+ packagePath: fixturePath,
1171
+ cleanAfterward: false ,
1172
+ buildSystem: buildSystem,
1173
+ )
1174
+
1175
+ let mainOFile = fixturePath. appending ( outputFile)
1176
+ let initialMainOMtime = try FileManager . default. attributesOfItem ( atPath: mainOFile. pathString) [ . modificationDate] as? Date
1177
+
1178
+ _ = try await self . build (
1179
+ [ " --verbose " ] ,
1180
+ packagePath: fixturePath,
1181
+ cleanAfterward: false ,
1182
+ buildSystem: buildSystem,
1183
+ )
1184
+
1185
+ let subsequentMainOMtime = try FileManager . default. attributesOfItem ( atPath: mainOFile. pathString) [ . modificationDate] as? Date
1186
+ #expect( initialMainOMtime == subsequentMainOMtime, " Expected no rebuild to occur when using the verbose flag, but the file was modified. " )
1187
+ }
1188
+ }
1189
+
1190
+ @Test ( arguments: try buildSystemAndOutputLocation ( ) )
1191
+ func doesNotRebuildWithSwiftcArgsThatDontAffectIncrementalBuilds(
1192
+ buildSystem: BuildSystemProvider . Kind ,
1193
+ outputFile: Basics . RelativePath
1194
+ ) async throws {
1195
+ try await fixture ( name: " ValidLayouts/SingleModule/ExecutableNew " ) { fixturePath in
1196
+ _ = try await self . build (
1197
+ [ ] ,
1198
+ packagePath: fixturePath,
1199
+ cleanAfterward: false ,
1200
+ buildSystem: buildSystem,
1201
+ )
1202
+
1203
+ let mainOFile = fixturePath. appending ( outputFile)
1204
+ let initialMainOMtime = try FileManager . default. attributesOfItem ( atPath: mainOFile. pathString) [ . modificationDate] as? Date
1205
+
1206
+ _ = try await self . build (
1207
+ [ " -Xswiftc " , " -diagnostic-style=llvm " ] ,
1208
+ packagePath: fixturePath,
1209
+ cleanAfterward: false ,
1210
+ buildSystem: buildSystem,
1211
+ )
1212
+
1213
+ let subsequentMainOMtime = try FileManager . default. attributesOfItem ( atPath: mainOFile. pathString) [ . modificationDate] as? Date
1214
+ #expect( initialMainOMtime == subsequentMainOMtime, " Expected no rebuild to occur when supplying -diagnostic-style, but the file was modified. " )
1215
+ }
1216
+ }
1217
+
1129
1218
@Test (
1130
1219
. SWBINTTODO( " Test failed because of missing plugin support in the PIF builder. This can be reinvestigated after the support is there. " ) ,
1131
1220
. tags(
@@ -1233,5 +1322,16 @@ struct BuildCommandTestCases {
1233
1322
1234
1323
}
1235
1324
1325
+ extension Triple {
1326
+ func withoutVersion( ) throws -> Triple {
1327
+ if isDarwin ( ) {
1328
+ let stringWithoutVersion = tripleString ( forPlatformVersion: " " )
1329
+ return try Triple ( stringWithoutVersion)
1330
+ } else {
1331
+ return self
1332
+ }
1333
+ }
1334
+ }
1335
+
1236
1336
1237
1337
0 commit comments