Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8831664
feat: Add advanced hierarchical console output recorder for Swift Tes…
tienquocbui Jul 7, 2025
1786cbf
Merge remote-tracking branch 'upstream/main'
tienquocbui Jul 7, 2025
b067a9a
Merge branch 'swiftlang:main' into main
tienquocbui Jul 8, 2025
73a60ae
Add advanced console output recorder with progress bar and hierarchic…
tienquocbui Jul 11, 2025
87425d9
Merge branch 'swiftlang:main' into feature/advanced-console-output-re…
tienquocbui Jul 24, 2025
bea236d
Implementing progress bar with live update
tienquocbui Jul 24, 2025
fd9a811
Merge pull request #1 from tienquocbui/kelvin/new-console-output
tienquocbui Jul 24, 2025
042438f
Fix: Signal Handling System and Live Failure Reporting
tienquocbui Jul 24, 2025
699459c
Add skeleton AdvancedConsoleOutputRecorder framework
tienquocbui Aug 1, 2025
6a1c6db
Merge main branch with latest upstream changes
tienquocbui Aug 1, 2025
f6c46fa
Fix trailing newline in AdvancedConsoleOutputRecorder
tienquocbui Aug 1, 2025
ef8252b
Align experimental integration with upstream patterns
tienquocbui Aug 1, 2025
c82be0b
Add experimental AdvancedConsoleOutputRecorder skeleton
tienquocbui Aug 6, 2025
7eb599a
Merge upstream/main into gsoc-development
tienquocbui Aug 6, 2025
16e581a
Fix Environment.flag optional unwrapping in EntryPoint.swift
tienquocbui Aug 8, 2025
3c80e1b
Fix skeleton implementation based on code review feedback
tienquocbui Aug 13, 2025
0a496ac
Remove LiveUpdatingLine.swift and its CMakeLists.txt reference
tienquocbui Aug 13, 2025
23b6dee
Merge upstream/main into gsoc-development2 for ABI refactor work
tienquocbui Aug 19, 2025
1c1cf8d
Implement ABI refactor for AdvancedConsoleOutputRecorder
tienquocbui Aug 19, 2025
be46b29
Address code review feedback from Stuart
tienquocbui Aug 21, 2025
9f67472
Fix typo error
tienquocbui Aug 21, 2025
c113964
Make AdvancedConsoleOutputRecorder generic over ABI.Version
tienquocbui Aug 21, 2025
ddf12ae
Fix naming convention: Context -> _Context
tienquocbui Aug 21, 2025
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
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.Options()
var advancedOptions = Event.AdvancedConsoleOutputRecorder<ABI.HighestVersion>.Options()
advancedOptions.base = .for(.stderr)

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension Event {
///
/// This recorder is currently experimental and must be enabled via the
/// `SWT_ENABLE_EXPERIMENTAL_CONSOLE_OUTPUT` environment variable.
struct AdvancedConsoleOutputRecorder: Sendable {
struct AdvancedConsoleOutputRecorder<V: ABI.Version>: Sendable {
/// Configuration options for the advanced console output recorder.
struct Options: Sendable {
/// Base console output recorder options to inherit from.
Expand All @@ -25,6 +25,15 @@ extension Event {
}
}

/// Context for storing data across events during test execution.
private struct _Context: Sendable {
/// Storage for test information, keyed by test ID string value.
/// This is needed because ABI.EncodedEvent doesn't contain full test context.
var testStorage: [String: ABI.EncodedTest<V>] = [:]

// Future storage for result data and other event information can be added here
}

/// The options for this recorder.
let options: Options

Expand All @@ -34,6 +43,12 @@ extension Event {
/// The fallback console recorder for standard output.
private let _fallbackRecorder: Event.ConsoleOutputRecorder

/// Context storage for test information and results.
private let _context: Locked<_Context>

/// Human-readable output recorder for generating messages.
private let _humanReadableRecorder: Event.HumanReadableOutputRecorder

/// Initialize the advanced console output recorder.
///
/// - Parameters:
Expand All @@ -43,21 +58,77 @@ extension Event {
self.options = options
self.write = write
self._fallbackRecorder = Event.ConsoleOutputRecorder(options: options.base, writingUsing: write)
self._context = Locked(rawValue: _Context())
self._humanReadableRecorder = Event.HumanReadableOutputRecorder()
}
}
}

extension Event.AdvancedConsoleOutputRecorder {
/// Record an event by processing it and generating appropriate output.
///
/// Currently this is a skeleton implementation that delegates to
/// ``Event/ConsoleOutputRecorder``.
/// This implementation converts the Event to ABI.EncodedEvent for internal processing,
/// following the ABI-based architecture for future separation into a harness process.
///
/// - Parameters:
/// - event: The event to record.
/// - eventContext: The context associated with the event.
func record(_ event: borrowing Event, in eventContext: borrowing Event.Context) {
// Skeleton implementation: delegate to ConsoleOutputRecorder
// Handle test discovery to populate our test storage
if case .testDiscovered = event.kind, let test = eventContext.test {
let encodedTest = ABI.EncodedTest<V>(encoding: test)
_context.withLock { context in
context.testStorage[encodedTest.id.stringValue] = encodedTest
}
}

// Generate human-readable messages for the event
let messages = _humanReadableRecorder.record(event, in: eventContext)

// Convert Event to ABI.EncodedEvent
if let encodedEvent = ABI.EncodedEvent<V>(encoding: event, in: eventContext, messages: messages) {
// Process the ABI event
_processABIEvent(encodedEvent)
}

// For now, still delegate to the fallback recorder to maintain existing functionality
_fallbackRecorder.record(event, in: eventContext)
}

/// Process an ABI.EncodedEvent for advanced console output.
///
/// This is where the enhanced console logic will be implemented in future PRs.
/// Currently this is a placeholder that demonstrates the ABI conversion.
///
/// - Parameters:
/// - encodedEvent: The ABI-encoded event to process.
private func _processABIEvent(_ encodedEvent: ABI.EncodedEvent<V>) {
// TODO: Implement enhanced console output logic here
// This will be expanded in subsequent PRs for:
// - Failure summary display
// - Progress bar functionality
// - Hierarchical test result display

// For now, we just demonstrate that we can access the ABI event data
switch encodedEvent.kind {
case .runStarted:
// Could implement run start logic here
break
case .testStarted:
// Could implement test start logic here
break
case .issueRecorded:
// Could implement issue recording logic here
break
case .testEnded:
// Could implement test end logic here
break
case .runEnded:
// Could implement run end logic here
break
default:
// Handle other event types
break
}
}
}