Skip to content

[CMake] Temporarily remove Foundation dependency #617

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion Sources/Testing/ABI/EntryPoints/ABIEntryPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
//

#if canImport(Foundation) && !SWT_NO_ABI_ENTRY_POINT
#if !SWT_NO_FOUNDATION && canImport(Foundation) && !SWT_NO_ABI_ENTRY_POINT
#if SWT_BUILDING_WITH_CMAKE
@_implementationOnly import _TestingInternals
#else
Expand Down
6 changes: 3 additions & 3 deletions Sources/Testing/ABI/EntryPoints/EntryPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func parseCommandLineArguments(from args: [String]) throws -> __CommandLineArgum
}

#if !SWT_NO_FILE_IO
#if canImport(Foundation)
#if !SWT_NO_FOUNDATION && canImport(Foundation)
// Configuration for the test run passed in as a JSON file (experimental)
//
// This argument should always be the first one we parse.
Expand Down Expand Up @@ -442,7 +442,7 @@ public func configurationForEntryPoint(from args: __CommandLineArguments_v0) thr
}
}

#if canImport(Foundation)
#if !SWT_NO_FOUNDATION && canImport(Foundation)
// Event stream output (experimental)
if let eventStreamOutputPath = args.eventStreamOutputPath {
let file = try FileHandle(forWritingAtPath: eventStreamOutputPath)
Expand Down Expand Up @@ -508,7 +508,7 @@ public func configurationForEntryPoint(from args: __CommandLineArguments_v0) thr
return configuration
}

#if canImport(Foundation) && !SWT_NO_FILE_IO
#if !SWT_NO_FOUNDATION && canImport(Foundation) && !SWT_NO_FILE_IO
/// Create an event handler that streams events to the given file using the
/// specified ABI version.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/Testing/ABI/v0/ABIv0.Record+Streaming.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
//

#if canImport(Foundation) && (!SWT_NO_FILE_IO || !SWT_NO_ABI_ENTRY_POINT)
#if !SWT_NO_FOUNDATION && canImport(Foundation) && (!SWT_NO_FILE_IO || !SWT_NO_ABI_ENTRY_POINT)
extension ABIv0.Record {
/// Create an event handler that encodes events as JSON and forwards them to
/// an ABI-friendly event handler.
Expand Down
4 changes: 4 additions & 0 deletions Sources/Testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,9 @@ target_compile_options(Testing PRIVATE
-enable-library-evolution
-emit-module-interface -emit-module-interface-path $<TARGET_PROPERTY:Testing,Swift_MODULE_DIRECTORY>/Testing.swiftinterface)

# FIXME: Temporarily drop Foundation dependency in CMake build.
target_compile_definitions(Testing PRIVATE
SWT_NO_FOUNDATION)

include(SwiftModuleInstallation)
_swift_testing_install_target(Testing)
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension Test.Case.Argument.ID {
///
/// - ``CustomTestArgumentEncodable``
init?(identifying value: some Sendable, parameter: Test.Parameter) throws {
#if canImport(Foundation)
#if !SWT_NO_FOUNDATION && canImport(Foundation)
func customArgumentWrapper(for value: some CustomTestArgumentEncodable) -> some Encodable {
_CustomArgumentWrapper(rawValue: value)
}
Expand All @@ -89,7 +89,7 @@ extension Test.Case.Argument.ID {
#endif
}

#if canImport(Foundation)
#if !SWT_NO_FOUNDATION && canImport(Foundation)
/// Encode the specified test argument value and store its encoded
/// representation as an array of bytes suitable for storing in an instance of
/// ``Test/Case/Argument/ID-swift.struct``.
Expand Down
6 changes: 3 additions & 3 deletions Sources/Testing/Support/JSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
//

#if canImport(Foundation)
#if !SWT_NO_FOUNDATION && canImport(Foundation)
private import Foundation
#endif

Expand All @@ -30,7 +30,7 @@ enum JSON {
///
/// - Throws: Whatever is thrown by `body` or by the encoding process.
static func withEncoding<R>(of value: some Encodable, userInfo: [CodingUserInfoKey: Any] = [:], _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R {
#if canImport(Foundation)
#if !SWT_NO_FOUNDATION && canImport(Foundation)
let encoder = JSONEncoder()

// Keys must be sorted to ensure deterministic matching of encoded data.
Expand Down Expand Up @@ -60,7 +60,7 @@ enum JSON {
///
/// - Throws: Whatever is thrown by the decoding process.
static func decode<T>(_ type: T.Type, from jsonRepresentation: UnsafeRawBufferPointer) throws -> T where T: Decodable {
#if canImport(Foundation)
#if !SWT_NO_FOUNDATION && canImport(Foundation)
try withExtendedLifetime(jsonRepresentation) {
let byteCount = jsonRepresentation.count
let data = if byteCount > 0 {
Expand Down