@@ -1206,41 +1206,15 @@ final class BuildPlanTests: XCTestCase {
1206
1206
1207
1207
func testParseAsLibraryFlagForExe( ) throws {
1208
1208
let fs = InMemoryFileSystem ( emptyFiles:
1209
- // executable has a single source file not named `main.swift`, without @main .
1209
+ // First executable has a single source file not named `main.swift`.
1210
1210
" /Pkg/Sources/exe1/foo.swift " ,
1211
- // executable has a single source file named `main.swift`, without @main .
1211
+ // Second executable has a single source file named `main.swift`.
1212
1212
" /Pkg/Sources/exe2/main.swift " ,
1213
- // executable has a single source file not named `main.swift`, with @main.
1214
- " /Pkg/Sources/exe3/foo.swift " ,
1215
- // executable has a single source file named `main.swift`, with @main
1216
- " /Pkg/Sources/exe4/main.swift " ,
1217
- // executable has multiple source files.
1218
- " /Pkg/Sources/exe5/bar.swift " ,
1219
- " /Pkg/Sources/exe5/main.swift "
1213
+ // Third executable has multiple source files.
1214
+ " /Pkg/Sources/exe3/bar.swift " ,
1215
+ " /Pkg/Sources/exe3/main.swift "
1220
1216
)
1221
1217
1222
- try fs. writeFileContents ( AbsolutePath ( " /Pkg/Sources/exe3/foo.swift " ) ) {
1223
- """
1224
- @main
1225
- struct Runner {
1226
- static func main() {
1227
- print( " hello world " )
1228
- }
1229
- }
1230
- """
1231
- }
1232
-
1233
- try fs. writeFileContents ( AbsolutePath ( " /Pkg/Sources/exe4/main.swift " ) ) {
1234
- """
1235
- @main
1236
- struct Runner {
1237
- static func main() {
1238
- print( " hello world " )
1239
- }
1240
- }
1241
- """
1242
- }
1243
-
1244
1218
let observability = ObservabilitySystem . makeForTesting ( )
1245
1219
let graph = try loadPackageGraph (
1246
1220
fileSystem: fs,
@@ -1253,8 +1227,6 @@ final class BuildPlanTests: XCTestCase {
1253
1227
TargetDescription ( name: " exe1 " , type: . executable) ,
1254
1228
TargetDescription ( name: " exe2 " , type: . executable) ,
1255
1229
TargetDescription ( name: " exe3 " , type: . executable) ,
1256
- TargetDescription ( name: " exe4 " , type: . executable) ,
1257
- TargetDescription ( name: " exe5 " , type: . executable) ,
1258
1230
] ) ,
1259
1231
] ,
1260
1232
observabilityScope: observability. topScope
@@ -1268,30 +1240,22 @@ final class BuildPlanTests: XCTestCase {
1268
1240
observabilityScope: observability. topScope
1269
1241
) )
1270
1242
1271
- result. checkProductsCount ( 5 )
1272
- result. checkTargetsCount ( 5 )
1243
+ result. checkProductsCount ( 3 )
1244
+ result. checkTargetsCount ( 3 )
1273
1245
1274
1246
XCTAssertNoDiagnostics ( observability. diagnostics)
1275
1247
1276
- // single source file not named main, and without @main should not have -parse-as-library.
1248
+ // Check that the first target ( single source file not named main) has -parse-as-library.
1277
1249
let exe1 = try result. target ( for: " exe1 " ) . swiftTarget ( ) . emitCommandLine ( )
1278
- XCTAssertNoMatch ( exe1, [ " -parse-as-library " ] )
1250
+ XCTAssertMatch ( exe1, [ " -parse-as-library " ] )
1279
1251
1280
- // single source file named main, and without @main should not have -parse-as-library.
1252
+ // Check that the second target ( single source file named main) does not have -parse-as-library.
1281
1253
let exe2 = try result. target ( for: " exe2 " ) . swiftTarget ( ) . emitCommandLine ( )
1282
1254
XCTAssertNoMatch ( exe2, [ " -parse-as-library " ] )
1283
1255
1284
- // single source file not named main, with @main should have -parse-as-library.
1256
+ // Check that the third target (multiple source files) does not have -parse-as-library.
1285
1257
let exe3 = try result. target ( for: " exe3 " ) . swiftTarget ( ) . emitCommandLine ( )
1286
- XCTAssertMatch ( exe3, [ " -parse-as-library " ] )
1287
-
1288
- // single source file named main, with @main should have -parse-as-library.
1289
- let exe4 = try result. target ( for: " exe4 " ) . swiftTarget ( ) . emitCommandLine ( )
1290
- XCTAssertMatch ( exe4, [ " -parse-as-library " ] )
1291
-
1292
- // multiple source files should not have -parse-as-library.
1293
- let exe5 = try result. target ( for: " exe5 " ) . swiftTarget ( ) . emitCommandLine ( )
1294
- XCTAssertNoMatch ( exe5, [ " -parse-as-library " ] )
1258
+ XCTAssertNoMatch ( exe3, [ " -parse-as-library " ] )
1295
1259
}
1296
1260
1297
1261
func testCModule( ) throws {
0 commit comments