Skip to content

Revert "XCTest discovery support for non-Darwin platforms" #556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions Sources/SWBApplePlatform/Specs/DarwinProductTypes.xcspec
Original file line number Diff line number Diff line change
Expand Up @@ -461,17 +461,4 @@
);
Platforms = (driverkit);
},
{
_Domain = darwin;
Type = ProductType;
Identifier = com.apple.product-type.tool.swiftpm-test-runner;
Name = "SwiftPM Unit Test Runner";
Description = "SwiftPM Unit Test Runner";
DefaultBuildProperties = {
__SKIP_BUILD = YES;
};
PackageTypes = (
com.apple.package-type.mach-o-executable
);
},
)
194 changes: 0 additions & 194 deletions Sources/SWBCSupport/IndexStore.h

This file was deleted.

1 change: 0 additions & 1 deletion Sources/SWBCSupport/SWBCSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "CLibclang.h"
#include "CLibRemarksHelper.h"
#include "IndexStore.h"
#include "PluginAPI.h"
#include "PluginAPI_functions.h"
#include "PluginAPI_types.h"
Expand Down
2 changes: 0 additions & 2 deletions Sources/SWBCore/Settings/BuiltinMacros.swift
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,6 @@ public final class BuiltinMacros {
public static let INDEX_PREPARED_TARGET_MARKER_PATH = BuiltinMacros.declareStringMacro("INDEX_PREPARED_TARGET_MARKER_PATH")
public static let INDEX_REGULAR_BUILD_PRODUCTS_DIR = BuiltinMacros.declareStringMacro("INDEX_REGULAR_BUILD_PRODUCTS_DIR")
public static let INDEX_REGULAR_BUILD_INTERMEDIATES_DIR = BuiltinMacros.declareStringMacro("INDEX_REGULAR_BUILD_INTERMEDIATES_DIR")
public static let INDEX_STORE_LIBRARY_PATH = BuiltinMacros.declarePathMacro("INDEX_STORE_LIBRARY_PATH")
public static let INFOPLIST_ENFORCE_MINIMUM_OS = BuiltinMacros.declareBooleanMacro("INFOPLIST_ENFORCE_MINIMUM_OS")
public static let INFOPLIST_EXPAND_BUILD_SETTINGS = BuiltinMacros.declareBooleanMacro("INFOPLIST_EXPAND_BUILD_SETTINGS")
public static let INFOPLIST_FILE = BuiltinMacros.declarePathMacro("INFOPLIST_FILE")
Expand Down Expand Up @@ -1797,7 +1796,6 @@ public final class BuiltinMacros {
INDEX_PREPARED_TARGET_MARKER_PATH,
INDEX_REGULAR_BUILD_PRODUCTS_DIR,
INDEX_REGULAR_BUILD_INTERMEDIATES_DIR,
INDEX_STORE_LIBRARY_PATH,
INDEX_ENABLE_DATA_STORE,
INDEX_PRECOMPS_DIR,
INFOPLIST_ENFORCE_MINIMUM_OS,
Expand Down
10 changes: 5 additions & 5 deletions Sources/SWBCore/SpecImplementations/ProductTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public class ProductTypeSpec : Spec, SpecType, @unchecked Sendable {
}

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

public override func supportsEmbeddingSwiftStandardLibraries(producer: CommandProducer) -> Bool {
public override var supportsEmbeddingSwiftStandardLibraries: Bool {
return true
}

Expand Down Expand Up @@ -602,8 +602,8 @@ public final class XCTestBundleProductTypeSpec : BundleProductTypeSpec, @uncheck
super.init(parser, basedOnSpec)
}

public override func supportsEmbeddingSwiftStandardLibraries(producer: CommandProducer) -> Bool {
return producer.isApplePlatform
public override var supportsEmbeddingSwiftStandardLibraries: Bool {
return true
}

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

let isDeviceBuild = platform?.isDeploymentPlatform == true && platform?.name != scope.evaluate(BuiltinMacros.HOST_PLATFORM)
let isDeviceBuild = platform?.isDeploymentPlatform == true && platform?.identifier != "com.apple.platform.macosx"
if isDeviceBuild {
// 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.
table.push(BuiltinMacros.DEBUG_INFORMATION_FORMAT, literal: "dwarf-with-dsym")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3763,9 +3763,6 @@ public extension BuildPhaseWithBuildFiles {
/// - 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.
func containsSwiftSources(_ referenceLookupContext: any ReferenceLookupContext, _ specLookupContext: any SpecLookupContext, _ scope: MacroEvaluationScope, _ filePathResolver: FilePathResolver) -> Bool {
guard let swiftFileType = specLookupContext.lookupFileType(identifier: "sourcecode.swift") else { return false }
if scope.evaluate(BuiltinMacros.GENERATE_TEST_ENTRY_POINT) {
return true
}
return containsFiles(ofType: swiftFileType, referenceLookupContext, specLookupContext, scope, filePathResolver)
}
}
Expand Down
35 changes: 29 additions & 6 deletions Sources/SWBGenericUnixPlatform/Specs/Unix.xcspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,41 @@
SortNumber = 0;
},

// Test type bundle (bodged to be a tool)
{
Domain = generic-unix;
Type = ProductType;
Identifier = com.apple.product-type.bundle.unit-test;
BasedOn = com.apple.product-type.library.dynamic;
Class = PBXToolProductType;
Name = "Command-line Tool";
Description = "Standalone command-line tool";
DefaultTargetName = "Command-line Tool";
DefaultBuildProperties = {
// Index store data is required to discover XCTest tests
COMPILER_INDEX_STORE_ENABLE = YES;
SWIFT_INDEX_STORE_ENABLE = YES;
// Testability is needed to generate code to invoke discovered XCTest tests
SWIFT_ENABLE_TESTABILITY = YES;
FULL_PRODUCT_NAME = "$(EXECUTABLE_NAME)";
EXECUTABLE_PREFIX = "";
EXECUTABLE_SUFFIX = ".xctest";
REZ_EXECUTABLE = YES;
INSTALL_PATH = "/usr/local/bin";
FRAMEWORK_FLAG_PREFIX = "-framework";
LIBRARY_FLAG_PREFIX = "-l";
LIBRARY_FLAG_NOSPACE = YES;
GCC_DYNAMIC_NO_PIC = NO;
LD_NO_PIE = NO;
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
STRIP_STYLE = "all";
CODE_SIGNING_ALLOWED = NO;
IsUnitTest = YES;
SWIFT_FORCE_DYNAMIC_LINK_STDLIB = YES;
SWIFT_FORCE_STATIC_LINK_STDLIB = NO;
// Avoid warning for executable types
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
GENERATE_TEST_ENTRY_POINT = YES;
GENERATED_TEST_ENTRY_POINT_PATH = "$(DERIVED_SOURCES_DIR)/test_entry_point.swift";
};
PackageTypes = (
com.apple.package-type.mach-o-executable // default
);
},

// Dynamic library (masquerading as a framework to placate Swift's project structure)
Expand Down
2 changes: 0 additions & 2 deletions Sources/SWBProjectModel/PIFGenerationModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ public enum PIF {
case executable = "com.apple.product-type.tool"
case hostBuildTool = "com.apple.product-type.tool.host-build"
case unitTest = "com.apple.product-type.bundle.unit-test"
case swiftpmTestRunner = "com.apple.product-type.tool.swiftpm-test-runner"
case bundle = "com.apple.product-type.bundle"
case packageProduct = "packageProduct"
public var asString: String { return rawValue }
Expand Down Expand Up @@ -1023,7 +1022,6 @@ public enum PIF {
public var SWIFT_ADD_TOOLCHAIN_SWIFTSYNTAX_SEARCH_PATHS: String?
public var SWIFT_FORCE_STATIC_LINK_STDLIB: String?
public var SWIFT_FORCE_DYNAMIC_LINK_STDLIB: String?
public var SWIFT_INDEX_STORE_ENABLE: String?
public var SWIFT_INSTALL_OBJC_HEADER: String?
public var SWIFT_LOAD_BINARY_MACROS: [String]?
public var SWIFT_MODULE_ALIASES: [String]?
Expand Down
33 changes: 27 additions & 6 deletions Sources/SWBQNXPlatform/Specs/QNX.xcspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,39 @@
SortNumber = 0;
},

// Test type bundle (bodged to be a tool)
{
Domain = qnx;
Type = ProductType;
Identifier = com.apple.product-type.bundle.unit-test;
BasedOn = com.apple.product-type.library.dynamic;
Class = PBXToolProductType;
Name = "Command-line Tool";
Description = "Standalone command-line tool";
DefaultTargetName = "Command-line Tool";
DefaultBuildProperties = {
// Index store data is required to discover XCTest tests
COMPILER_INDEX_STORE_ENABLE = YES;
SWIFT_INDEX_STORE_ENABLE = YES;
// Testability is needed to generate code to invoke discovered XCTest tests
SWIFT_ENABLE_TESTABILITY = YES;
FULL_PRODUCT_NAME = "$(EXECUTABLE_NAME)";
EXECUTABLE_PREFIX = "";
EXECUTABLE_SUFFIX = ".xctest";
REZ_EXECUTABLE = YES;
INSTALL_PATH = "/usr/local/bin";
FRAMEWORK_FLAG_PREFIX = "-framework";
LIBRARY_FLAG_PREFIX = "-l";
LIBRARY_FLAG_NOSPACE = YES;
GCC_DYNAMIC_NO_PIC = NO;
LD_NO_PIE = NO;
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
STRIP_STYLE = "all";
CODE_SIGNING_ALLOWED = NO;
IsUnitTest = YES;
SWIFT_FORCE_DYNAMIC_LINK_STDLIB = YES;
SWIFT_FORCE_STATIC_LINK_STDLIB = NO;
// Avoid warning for executable types
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
};
PackageTypes = (
com.apple.package-type.mach-o-executable // default
);
},

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