Skip to content

Commit 7493d6e

Browse files
authored
Move JSON ABI source files to prepare for v1. (#953)
At this time, we expect most of the "ABIv1" JSON schema will be the same as the current "ABIv0" one, so this PR reshuffles the source files supporting it so they can be more readily reused between the two. Future PRs will start adding actual "ABIv1" functionality—this is just a bookkeeping PR. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 74a8c52 commit 7493d6e

19 files changed

+88
-71
lines changed

Documentation/ABI/JSON.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ See https://swift.org/CONTRIBUTORS.txt for Swift project authors
1313
This document outlines the JSON schemas used by the testing library for its ABI
1414
entry point and for the `--event-stream-output-path` command-line argument. For
1515
more information about the ABI entry point, see the documentation for
16-
[ABIv0.EntryPoint](https://github.com/search?q=repo%3Aapple%2Fswift-testing%EntryPoint&type=code).
16+
[ABI.v0.EntryPoint](https://github.com/search?q=repo%3Aapple%2Fswift-testing%EntryPoint&type=code).
1717

1818
## Modified Backus-Naur form
1919

Sources/Testing/ABI/v0/ABIv0.Record+Streaming.swift renamed to Sources/Testing/ABI/ABI.Record+Streaming.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//
1010

1111
#if canImport(Foundation) && (!SWT_NO_FILE_IO || !SWT_NO_ABI_ENTRY_POINT)
12-
extension ABIv0.Record {
12+
extension ABI.Record {
1313
/// Post-process encoded JSON and write it to a file.
1414
///
1515
/// - Parameters:

Sources/Testing/ABI/v0/ABIv0.Record.swift renamed to Sources/Testing/ABI/ABI.Record.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
extension ABIv0 {
11+
extension ABI {
1212
/// A type implementing the JSON encoding of records for the ABI entry point
1313
/// and event stream output.
1414
///
@@ -48,7 +48,7 @@ extension ABIv0 {
4848

4949
// MARK: - Codable
5050

51-
extension ABIv0.Record: Codable {
51+
extension ABI.Record: Codable {
5252
private enum CodingKeys: String, CodingKey {
5353
case version
5454
case kind
@@ -73,10 +73,10 @@ extension ABIv0.Record: Codable {
7373
version = try container.decode(Int.self, forKey: .version)
7474
switch try container.decode(String.self, forKey: .kind) {
7575
case "test":
76-
let test = try container.decode(ABIv0.EncodedTest.self, forKey: .payload)
76+
let test = try container.decode(ABI.EncodedTest.self, forKey: .payload)
7777
kind = .test(test)
7878
case "event":
79-
let event = try container.decode(ABIv0.EncodedEvent.self, forKey: .payload)
79+
let event = try container.decode(ABI.EncodedEvent.self, forKey: .payload)
8080
kind = .event(event)
8181
case let kind:
8282
throw DecodingError.dataCorrupted(.init(codingPath: decoder.codingPath, debugDescription: "Unrecognized record kind '\(kind)'"))

Sources/Testing/ABI/ABI.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// This source file is part of the Swift.org open source project
3+
//
4+
// Copyright (c) 2024–2025 Apple Inc. and the Swift project authors
5+
// Licensed under Apache License v2.0 with Runtime Library Exception
6+
//
7+
// See https://swift.org/LICENSE.txt for license information
8+
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
//
10+
11+
/// A namespace for ABI symbols.
12+
@_spi(ForToolsIntegrationOnly)
13+
public enum ABI: Sendable {}
14+
15+
// MARK: -
16+
17+
@_spi(ForToolsIntegrationOnly)
18+
extension ABI {
19+
/// A namespace for ABI version 0 symbols.
20+
public enum v0: Sendable {}
21+
22+
/// A namespace for ABI version 1 symbols.
23+
@_spi(Experimental)
24+
public enum v1: Sendable {}
25+
}
26+
27+
/// A namespace for ABI version 0 symbols.
28+
@_spi(ForToolsIntegrationOnly)
29+
@available(*, deprecated, renamed: "ABI.v0")
30+
public typealias ABIv0 = ABI.v0

Sources/Testing/ABI/v0/Encoded/ABIv0.EncodedAttachment.swift renamed to Sources/Testing/ABI/Encoded/ABI.EncodedAttachment.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
extension ABIv0 {
11+
extension ABI {
1212
/// A type implementing the JSON encoding of ``Attachment`` for the ABI entry
1313
/// point and event stream output.
1414
///
@@ -29,4 +29,4 @@ extension ABIv0 {
2929

3030
// MARK: - Codable
3131

32-
extension ABIv0.EncodedAttachment: Codable {}
32+
extension ABI.EncodedAttachment: Codable {}

Sources/Testing/ABI/v0/Encoded/ABIv0.EncodedBacktrace.swift renamed to Sources/Testing/ABI/Encoded/ABI.EncodedBacktrace.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
extension ABIv0 {
11+
extension ABI {
1212
/// A type implementing the JSON encoding of ``Backtrace`` for the ABI entry
1313
/// point and event stream output.
1414
///
@@ -33,7 +33,7 @@ extension ABIv0 {
3333

3434
// MARK: - Codable
3535

36-
extension ABIv0.EncodedBacktrace: Codable {
36+
extension ABI.EncodedBacktrace: Codable {
3737
func encode(to encoder: any Encoder) throws {
3838
try symbolicatedAddresses.encode(to: encoder)
3939
}

Sources/Testing/ABI/v0/Encoded/ABIv0.EncodedError.swift renamed to Sources/Testing/ABI/Encoded/ABI.EncodedError.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
extension ABIv0 {
11+
extension ABI {
1212
/// A type implementing the JSON encoding of ``Error`` for the ABI entry point
1313
/// and event stream output.
1414
///
@@ -39,7 +39,7 @@ extension ABIv0 {
3939

4040
// MARK: - Error
4141

42-
extension ABIv0.EncodedError: Error {
42+
extension ABI.EncodedError: Error {
4343
var _domain: String {
4444
domain
4545
}
@@ -56,11 +56,11 @@ extension ABIv0.EncodedError: Error {
5656

5757
// MARK: - Codable
5858

59-
extension ABIv0.EncodedError: Codable {}
59+
extension ABI.EncodedError: Codable {}
6060

6161
// MARK: - CustomTestStringConvertible
6262

63-
extension ABIv0.EncodedError: CustomTestStringConvertible {
63+
extension ABI.EncodedError: CustomTestStringConvertible {
6464
var testDescription: String {
6565
description
6666
}

Sources/Testing/ABI/v0/Encoded/ABIv0.EncodedEvent.swift renamed to Sources/Testing/ABI/Encoded/ABI.EncodedEvent.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
extension ABIv0 {
11+
extension ABI {
1212
/// A type implementing the JSON encoding of ``Event`` for the ABI entry point
1313
/// and event stream output.
1414
///
@@ -109,5 +109,5 @@ extension ABIv0 {
109109

110110
// MARK: - Codable
111111

112-
extension ABIv0.EncodedEvent: Codable {}
113-
extension ABIv0.EncodedEvent.Kind: Codable {}
112+
extension ABI.EncodedEvent: Codable {}
113+
extension ABI.EncodedEvent.Kind: Codable {}

Sources/Testing/ABI/v0/Encoded/ABIv0.EncodedInstant.swift renamed to Sources/Testing/ABI/Encoded/ABI.EncodedInstant.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
extension ABIv0 {
11+
extension ABI {
1212
/// A type implementing the JSON encoding of ``Test/Clock/Instant`` for the
1313
/// ABI entry point and event stream output.
1414
///
@@ -37,4 +37,4 @@ extension ABIv0 {
3737

3838
// MARK: - Codable
3939

40-
extension ABIv0.EncodedInstant: Codable {}
40+
extension ABI.EncodedInstant: Codable {}

Sources/Testing/ABI/v0/Encoded/ABIv0.EncodedIssue.swift renamed to Sources/Testing/ABI/Encoded/ABI.EncodedIssue.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
//
1010

11-
extension ABIv0 {
11+
extension ABI {
1212
/// A type implementing the JSON encoding of ``Issue`` for the ABI entry point
1313
/// and event stream output.
1414
///
@@ -65,5 +65,5 @@ extension ABIv0 {
6565

6666
// MARK: - Codable
6767

68-
extension ABIv0.EncodedIssue: Codable {}
69-
extension ABIv0.EncodedIssue.Severity: Codable {}
68+
extension ABI.EncodedIssue: Codable {}
69+
extension ABI.EncodedIssue.Severity: Codable {}

0 commit comments

Comments
 (0)