Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
11 changes: 10 additions & 1 deletion Sources/Testing/ABI/ABI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ extension ABI {
/// The current supported ABI version (ignoring any experimental versions.)
typealias CurrentVersion = v0

/// The highest supported ABI version (including any experimental versions.)
/// The highest defined and supported ABI version (including any experimental
/// versions.)
typealias HighestVersion = v6_3

#if !hasFeature(Embedded)
Expand Down Expand Up @@ -125,6 +126,14 @@ extension ABI {
VersionNumber(6, 3)
}
}

/// A namespace and type representing the ABI version whose symbols are
/// considered experimental.
enum ExperimentalVersion: Sendable, Version {
static var versionNumber: VersionNumber {
VersionNumber(99, 0)
}
}
}

/// A namespace for ABI version 0 symbols.
Expand Down
8 changes: 6 additions & 2 deletions Sources/Testing/ABI/Encoded/ABI.EncodedEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ extension ABI {
instant = EncodedInstant(encoding: event.instant)
self.messages = messages.map(EncodedMessage.init)
testID = event.testID.map(EncodedTest.ID.init)
if eventContext.test?.isParameterized == true {
_testCase = eventContext.testCase.map(EncodedTestCase.init)

// Experimental
if V.versionNumber >= ABI.ExperimentalVersion.versionNumber {
if eventContext.test?.isParameterized == true {
_testCase = eventContext.testCase.map(EncodedTestCase.init)
}
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions Sources/Testing/ABI/Encoded/ABI.EncodedIssue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ extension ABI {
}

// Experimental
if let backtrace = issue.sourceContext.backtrace {
_backtrace = EncodedBacktrace(encoding: backtrace, in: eventContext)
}
if let error = issue.error {
_error = EncodedError(encoding: error, in: eventContext)
if V.versionNumber >= ABI.ExperimentalVersion.versionNumber {
if let backtrace = issue.sourceContext.backtrace {
_backtrace = EncodedBacktrace(encoding: backtrace, in: eventContext)
}
if let error = issue.error {
_error = EncodedError(encoding: error, in: eventContext)
}
}
}
}
Expand Down
30 changes: 20 additions & 10 deletions Sources/Testing/ABI/Encoded/ABI.EncodedTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,39 @@ extension ABI {
/// The tags associated with the test.
///
/// - Warning: Tags are not yet part of the JSON schema.
///
/// @Metadata {
/// @Available("Swift Testing ABI", introduced: 6.3)
/// }
var _tags: [String]?

init(encoding test: borrowing Test) {
if test.isSuite {
kind = .suite
} else {
kind = .function
let testIsParameterized = test.isParameterized
isParameterized = testIsParameterized
if testIsParameterized {
_testCases = test.uncheckedTestCases?.map(EncodedTestCase.init(encoding:))
}
isParameterized = test.isParameterized
}
name = test.name
displayName = test.displayName
sourceLocation = test.sourceLocation
id = ID(encoding: test.id)

if V.versionNumber >= ABI.v6_3.versionNumber {
// Experimental test case encoding: This field was included in v0 with an
// underscore-prefixed name despite not having been formally proposed, and
// a prominent client (the VS Code Swift plugin) depends on it. To avoid
// breaking existing versions of that plugin, continue unconditionally
// including this field in versions earlier than 6.3 (including v0). In
// 6.3 and later, don't include it by default but allow opting-in to it
// via an environment variable. (This is to maintain compatibility until
// the field has been formally proposed and accepted, and discourage new
// clients from becoming dependent on it in the mean time.) Finally,
// in the special experimental version always include this field.
if isParameterized == true,
(V.versionNumber < ABI.v6_3.versionNumber
|| V.versionNumber >= ABI.ExperimentalVersion.versionNumber
|| Environment.flag(named: "SWT_ENABLE_EXPERIMENTAL_EVENT_STREAM_TEST_CASE_ENCODING") == true) {
_testCases = test.uncheckedTestCases?.map(EncodedTestCase.init(encoding:))
}

// Experimental
if V.versionNumber >= ABI.ExperimentalVersion.versionNumber {
let tags = test.tags
if !tags.isEmpty {
_tags = tags.map(String.init(describing:))
Expand Down
4 changes: 2 additions & 2 deletions Sources/Testing/ABI/EntryPoints/EntryPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ func entryPoint(passing args: __CommandLineArguments_v0?, eventHandler: Event.Ha
// Check for experimental console output flag
if Environment.flag(named: "SWT_ENABLE_EXPERIMENTAL_CONSOLE_OUTPUT") == true {
// Use experimental AdvancedConsoleOutputRecorder
var advancedOptions = Event.AdvancedConsoleOutputRecorder<ABI.HighestVersion>.Options()
var advancedOptions = Event.AdvancedConsoleOutputRecorder<ABI.ExperimentalVersion>.Options()
advancedOptions.base = .for(.stderr)

let eventRecorder = Event.AdvancedConsoleOutputRecorder<ABI.HighestVersion>(options: advancedOptions) { string in
let eventRecorder = Event.AdvancedConsoleOutputRecorder<ABI.ExperimentalVersion>(options: advancedOptions) { string in
try? FileHandle.stderr.write(string)
}

Expand Down
7 changes: 3 additions & 4 deletions Sources/Testing/ExitTests/ExitTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,9 @@ extension ABI {
/// The ABI version to use for encoding and decoding events sent over the back
/// channel.
///
/// The back channel always uses the latest ABI version (even if experimental)
/// since both the producer and consumer use this exact version of the testing
/// library.
fileprivate typealias BackChannelVersion = v6_3
/// The back channel always uses the experimental ABI version since both the
/// producer and consumer use this exact version of the testing library.
fileprivate typealias BackChannelVersion = ExperimentalVersion
}

@_spi(ForToolsIntegrationOnly)
Expand Down
2 changes: 1 addition & 1 deletion Tests/TestingTests/SwiftPMTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ struct SwiftPMTests {
}
#expect(testRecords.count == 1)
for testRecord in testRecords {
if version.versionNumber >= ABI.v6_3.versionNumber {
if version.versionNumber >= ABI.ExperimentalVersion.versionNumber {
#expect(testRecord._tags != nil)
} else {
#expect(testRecord._tags == nil)
Expand Down