Skip to content

Commit 5974348

Browse files
authored
Merge pull request #556 from swiftlang/revert-499-owenv/test-discovery
Revert "XCTest discovery support for non-Darwin platforms"
2 parents db41e13 + c1f1cf3 commit 5974348

File tree

24 files changed

+89
-1442
lines changed

24 files changed

+89
-1442
lines changed

Sources/SWBApplePlatform/Specs/DarwinProductTypes.xcspec

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -461,17 +461,4 @@
461461
);
462462
Platforms = (driverkit);
463463
},
464-
{
465-
_Domain = darwin;
466-
Type = ProductType;
467-
Identifier = com.apple.product-type.tool.swiftpm-test-runner;
468-
Name = "SwiftPM Unit Test Runner";
469-
Description = "SwiftPM Unit Test Runner";
470-
DefaultBuildProperties = {
471-
__SKIP_BUILD = YES;
472-
};
473-
PackageTypes = (
474-
com.apple.package-type.mach-o-executable
475-
);
476-
},
477464
)

Sources/SWBCSupport/IndexStore.h

Lines changed: 0 additions & 194 deletions
This file was deleted.

Sources/SWBCSupport/SWBCSupport.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
#include "CLibclang.h"
2323
#include "CLibRemarksHelper.h"
24-
#include "IndexStore.h"
2524
#include "PluginAPI.h"
2625
#include "PluginAPI_functions.h"
2726
#include "PluginAPI_types.h"

Sources/SWBCore/Settings/BuiltinMacros.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,6 @@ public final class BuiltinMacros {
750750
public static let INDEX_PREPARED_TARGET_MARKER_PATH = BuiltinMacros.declareStringMacro("INDEX_PREPARED_TARGET_MARKER_PATH")
751751
public static let INDEX_REGULAR_BUILD_PRODUCTS_DIR = BuiltinMacros.declareStringMacro("INDEX_REGULAR_BUILD_PRODUCTS_DIR")
752752
public static let INDEX_REGULAR_BUILD_INTERMEDIATES_DIR = BuiltinMacros.declareStringMacro("INDEX_REGULAR_BUILD_INTERMEDIATES_DIR")
753-
public static let INDEX_STORE_LIBRARY_PATH = BuiltinMacros.declarePathMacro("INDEX_STORE_LIBRARY_PATH")
754753
public static let INFOPLIST_ENFORCE_MINIMUM_OS = BuiltinMacros.declareBooleanMacro("INFOPLIST_ENFORCE_MINIMUM_OS")
755754
public static let INFOPLIST_EXPAND_BUILD_SETTINGS = BuiltinMacros.declareBooleanMacro("INFOPLIST_EXPAND_BUILD_SETTINGS")
756755
public static let INFOPLIST_FILE = BuiltinMacros.declarePathMacro("INFOPLIST_FILE")
@@ -1797,7 +1796,6 @@ public final class BuiltinMacros {
17971796
INDEX_PREPARED_TARGET_MARKER_PATH,
17981797
INDEX_REGULAR_BUILD_PRODUCTS_DIR,
17991798
INDEX_REGULAR_BUILD_INTERMEDIATES_DIR,
1800-
INDEX_STORE_LIBRARY_PATH,
18011799
INDEX_ENABLE_DATA_STORE,
18021800
INDEX_PRECOMPS_DIR,
18031801
INFOPLIST_ENFORCE_MINIMUM_OS,

Sources/SWBCore/SpecImplementations/ProductTypes.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ public class ProductTypeSpec : Spec, SpecType, @unchecked Sendable {
321321
}
322322

323323
/// Returns whether the product type supports embedding Swift standard libraries inside it.
324-
public func supportsEmbeddingSwiftStandardLibraries(producer: CommandProducer) -> Bool {
324+
public var supportsEmbeddingSwiftStandardLibraries: Bool {
325325
// Most product types don't support having the Swift libraries embedded in them.
326326
return false
327327
}
@@ -381,7 +381,7 @@ public final class ApplicationProductTypeSpec : BundleProductTypeSpec, @unchecke
381381
return "PBXApplicationProductType"
382382
}
383383

384-
public override func supportsEmbeddingSwiftStandardLibraries(producer: CommandProducer) -> Bool {
384+
public override var supportsEmbeddingSwiftStandardLibraries: Bool {
385385
return true
386386
}
387387

@@ -602,8 +602,8 @@ public final class XCTestBundleProductTypeSpec : BundleProductTypeSpec, @uncheck
602602
super.init(parser, basedOnSpec)
603603
}
604604

605-
public override func supportsEmbeddingSwiftStandardLibraries(producer: CommandProducer) -> Bool {
606-
return producer.isApplePlatform
605+
public override var supportsEmbeddingSwiftStandardLibraries: Bool {
606+
return true
607607
}
608608

609609
public class func usesXCTRunner(_ scope: MacroEvaluationScope) -> Bool {
@@ -649,7 +649,7 @@ public final class XCTestBundleProductTypeSpec : BundleProductTypeSpec, @uncheck
649649
var (tableOpt, warnings, errors) = super.overridingBuildSettings(scope, platform: platform)
650650
var table = tableOpt ?? MacroValueAssignmentTable(namespace: scope.namespace)
651651

652-
let isDeviceBuild = platform?.isDeploymentPlatform == true && platform?.name != scope.evaluate(BuiltinMacros.HOST_PLATFORM)
652+
let isDeviceBuild = platform?.isDeploymentPlatform == true && platform?.identifier != "com.apple.platform.macosx"
653653
if isDeviceBuild {
654654
// For tests running on devices (not simulators) we always want to generate dSYMs so that symbolication can give file and line information about test failures.
655655
table.push(BuiltinMacros.DEBUG_INFORMATION_FORMAT, literal: "dwarf-with-dsym")

Sources/SWBCore/SpecImplementations/Tools/SwiftCompiler.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3763,9 +3763,6 @@ public extension BuildPhaseWithBuildFiles {
37633763
/// - Returns: If the build phase contains any Swift source files that are not filtered out via the platform filter or excluded source file name patterns.
37643764
func containsSwiftSources(_ referenceLookupContext: any ReferenceLookupContext, _ specLookupContext: any SpecLookupContext, _ scope: MacroEvaluationScope, _ filePathResolver: FilePathResolver) -> Bool {
37653765
guard let swiftFileType = specLookupContext.lookupFileType(identifier: "sourcecode.swift") else { return false }
3766-
if scope.evaluate(BuiltinMacros.GENERATE_TEST_ENTRY_POINT) {
3767-
return true
3768-
}
37693766
return containsFiles(ofType: swiftFileType, referenceLookupContext, specLookupContext, scope, filePathResolver)
37703767
}
37713768
}

Sources/SWBGenericUnixPlatform/Specs/Unix.xcspec

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,41 @@
2424
SortNumber = 0;
2525
},
2626

27+
// Test type bundle (bodged to be a tool)
2728
{
2829
Domain = generic-unix;
2930
Type = ProductType;
3031
Identifier = com.apple.product-type.bundle.unit-test;
31-
BasedOn = com.apple.product-type.library.dynamic;
32+
Class = PBXToolProductType;
33+
Name = "Command-line Tool";
34+
Description = "Standalone command-line tool";
35+
DefaultTargetName = "Command-line Tool";
3236
DefaultBuildProperties = {
33-
// Index store data is required to discover XCTest tests
34-
COMPILER_INDEX_STORE_ENABLE = YES;
35-
SWIFT_INDEX_STORE_ENABLE = YES;
36-
// Testability is needed to generate code to invoke discovered XCTest tests
37-
SWIFT_ENABLE_TESTABILITY = YES;
37+
FULL_PRODUCT_NAME = "$(EXECUTABLE_NAME)";
38+
EXECUTABLE_PREFIX = "";
39+
EXECUTABLE_SUFFIX = ".xctest";
40+
REZ_EXECUTABLE = YES;
41+
INSTALL_PATH = "/usr/local/bin";
42+
FRAMEWORK_FLAG_PREFIX = "-framework";
43+
LIBRARY_FLAG_PREFIX = "-l";
44+
LIBRARY_FLAG_NOSPACE = YES;
45+
GCC_DYNAMIC_NO_PIC = NO;
46+
LD_NO_PIE = NO;
47+
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
48+
GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
49+
STRIP_STYLE = "all";
50+
CODE_SIGNING_ALLOWED = NO;
51+
IsUnitTest = YES;
52+
SWIFT_FORCE_DYNAMIC_LINK_STDLIB = YES;
53+
SWIFT_FORCE_STATIC_LINK_STDLIB = NO;
54+
// Avoid warning for executable types
55+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
56+
GENERATE_TEST_ENTRY_POINT = YES;
57+
GENERATED_TEST_ENTRY_POINT_PATH = "$(DERIVED_SOURCES_DIR)/test_entry_point.swift";
3858
};
59+
PackageTypes = (
60+
com.apple.package-type.mach-o-executable // default
61+
);
3962
},
4063

4164
// Dynamic library (masquerading as a framework to placate Swift's project structure)

Sources/SWBProjectModel/PIFGenerationModel.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ public enum PIF {
295295
case executable = "com.apple.product-type.tool"
296296
case hostBuildTool = "com.apple.product-type.tool.host-build"
297297
case unitTest = "com.apple.product-type.bundle.unit-test"
298-
case swiftpmTestRunner = "com.apple.product-type.tool.swiftpm-test-runner"
299298
case bundle = "com.apple.product-type.bundle"
300299
case packageProduct = "packageProduct"
301300
public var asString: String { return rawValue }
@@ -1023,7 +1022,6 @@ public enum PIF {
10231022
public var SWIFT_ADD_TOOLCHAIN_SWIFTSYNTAX_SEARCH_PATHS: String?
10241023
public var SWIFT_FORCE_STATIC_LINK_STDLIB: String?
10251024
public var SWIFT_FORCE_DYNAMIC_LINK_STDLIB: String?
1026-
public var SWIFT_INDEX_STORE_ENABLE: String?
10271025
public var SWIFT_INSTALL_OBJC_HEADER: String?
10281026
public var SWIFT_LOAD_BINARY_MACROS: [String]?
10291027
public var SWIFT_MODULE_ALIASES: [String]?

Sources/SWBQNXPlatform/Specs/QNX.xcspec

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,39 @@
2424
SortNumber = 0;
2525
},
2626

27+
// Test type bundle (bodged to be a tool)
2728
{
2829
Domain = qnx;
2930
Type = ProductType;
3031
Identifier = com.apple.product-type.bundle.unit-test;
31-
BasedOn = com.apple.product-type.library.dynamic;
32+
Class = PBXToolProductType;
33+
Name = "Command-line Tool";
34+
Description = "Standalone command-line tool";
35+
DefaultTargetName = "Command-line Tool";
3236
DefaultBuildProperties = {
33-
// Index store data is required to discover XCTest tests
34-
COMPILER_INDEX_STORE_ENABLE = YES;
35-
SWIFT_INDEX_STORE_ENABLE = YES;
36-
// Testability is needed to generate code to invoke discovered XCTest tests
37-
SWIFT_ENABLE_TESTABILITY = YES;
37+
FULL_PRODUCT_NAME = "$(EXECUTABLE_NAME)";
38+
EXECUTABLE_PREFIX = "";
39+
EXECUTABLE_SUFFIX = ".xctest";
40+
REZ_EXECUTABLE = YES;
41+
INSTALL_PATH = "/usr/local/bin";
42+
FRAMEWORK_FLAG_PREFIX = "-framework";
43+
LIBRARY_FLAG_PREFIX = "-l";
44+
LIBRARY_FLAG_NOSPACE = YES;
45+
GCC_DYNAMIC_NO_PIC = NO;
46+
LD_NO_PIE = NO;
47+
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
48+
GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
49+
STRIP_STYLE = "all";
50+
CODE_SIGNING_ALLOWED = NO;
51+
IsUnitTest = YES;
52+
SWIFT_FORCE_DYNAMIC_LINK_STDLIB = YES;
53+
SWIFT_FORCE_STATIC_LINK_STDLIB = NO;
54+
// Avoid warning for executable types
55+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
3856
};
57+
PackageTypes = (
58+
com.apple.package-type.mach-o-executable // default
59+
);
3960
},
4061

4162
// Dynamic library (masquerading as a framework to placate Swift's project structure)

0 commit comments

Comments
 (0)