@@ -14,7 +14,7 @@ extension Event {
14
14
///
15
15
/// This recorder is currently experimental and must be enabled via the
16
16
/// `SWT_ENABLE_EXPERIMENTAL_CONSOLE_OUTPUT` environment variable.
17
- struct AdvancedConsoleOutputRecorder : Sendable {
17
+ struct AdvancedConsoleOutputRecorder < V : ABI . Version > : Sendable {
18
18
/// Configuration options for the advanced console output recorder.
19
19
struct Options : Sendable {
20
20
/// Base console output recorder options to inherit from.
@@ -25,6 +25,15 @@ extension Event {
25
25
}
26
26
}
27
27
28
+ /// Context for storing data across events during test execution.
29
+ private struct _Context : Sendable {
30
+ /// Storage for test information, keyed by test ID string value.
31
+ /// This is needed because ABI.EncodedEvent doesn't contain full test context.
32
+ var testStorage : [ String : ABI . EncodedTest < V > ] = [ : ]
33
+
34
+ // Future storage for result data and other event information can be added here
35
+ }
36
+
28
37
/// The options for this recorder.
29
38
let options : Options
30
39
@@ -34,6 +43,12 @@ extension Event {
34
43
/// The fallback console recorder for standard output.
35
44
private let _fallbackRecorder : Event . ConsoleOutputRecorder
36
45
46
+ /// Context storage for test information and results.
47
+ private let _context : Locked < _Context >
48
+
49
+ /// Human-readable output recorder for generating messages.
50
+ private let _humanReadableRecorder : Event . HumanReadableOutputRecorder
51
+
37
52
/// Initialize the advanced console output recorder.
38
53
///
39
54
/// - Parameters:
@@ -43,21 +58,77 @@ extension Event {
43
58
self . options = options
44
59
self . write = write
45
60
self . _fallbackRecorder = Event . ConsoleOutputRecorder ( options: options. base, writingUsing: write)
61
+ self . _context = Locked ( rawValue: _Context ( ) )
62
+ self . _humanReadableRecorder = Event . HumanReadableOutputRecorder ( )
46
63
}
47
64
}
48
65
}
49
66
50
67
extension Event . AdvancedConsoleOutputRecorder {
51
68
/// Record an event by processing it and generating appropriate output.
52
69
///
53
- /// Currently this is a skeleton implementation that delegates to
54
- /// ``Event/ConsoleOutputRecorder`` .
70
+ /// This implementation converts the Event to ABI.EncodedEvent for internal processing,
71
+ /// following the ABI-based architecture for future separation into a harness process .
55
72
///
56
73
/// - Parameters:
57
74
/// - event: The event to record.
58
75
/// - eventContext: The context associated with the event.
59
76
func record( _ event: borrowing Event , in eventContext: borrowing Event . Context ) {
60
- // Skeleton implementation: delegate to ConsoleOutputRecorder
77
+ // Handle test discovery to populate our test storage
78
+ if case . testDiscovered = event. kind, let test = eventContext. test {
79
+ let encodedTest = ABI . EncodedTest< V> ( encoding: test)
80
+ _context. withLock { context in
81
+ context. testStorage [ encodedTest. id. stringValue] = encodedTest
82
+ }
83
+ }
84
+
85
+ // Generate human-readable messages for the event
86
+ let messages = _humanReadableRecorder. record ( event, in: eventContext)
87
+
88
+ // Convert Event to ABI.EncodedEvent
89
+ if let encodedEvent = ABI . EncodedEvent< V> ( encoding: event, in: eventContext, messages: messages) {
90
+ // Process the ABI event
91
+ _processABIEvent ( encodedEvent)
92
+ }
93
+
94
+ // For now, still delegate to the fallback recorder to maintain existing functionality
61
95
_fallbackRecorder. record ( event, in: eventContext)
62
96
}
97
+
98
+ /// Process an ABI.EncodedEvent for advanced console output.
99
+ ///
100
+ /// This is where the enhanced console logic will be implemented in future PRs.
101
+ /// Currently this is a placeholder that demonstrates the ABI conversion.
102
+ ///
103
+ /// - Parameters:
104
+ /// - encodedEvent: The ABI-encoded event to process.
105
+ private func _processABIEvent( _ encodedEvent: ABI . EncodedEvent < V > ) {
106
+ // TODO: Implement enhanced console output logic here
107
+ // This will be expanded in subsequent PRs for:
108
+ // - Failure summary display
109
+ // - Progress bar functionality
110
+ // - Hierarchical test result display
111
+
112
+ // For now, we just demonstrate that we can access the ABI event data
113
+ switch encodedEvent. kind {
114
+ case . runStarted:
115
+ // Could implement run start logic here
116
+ break
117
+ case . testStarted:
118
+ // Could implement test start logic here
119
+ break
120
+ case . issueRecorded:
121
+ // Could implement issue recording logic here
122
+ break
123
+ case . testEnded:
124
+ // Could implement test end logic here
125
+ break
126
+ case . runEnded:
127
+ // Could implement run end logic here
128
+ break
129
+ default :
130
+ // Handle other event types
131
+ break
132
+ }
133
+ }
63
134
}
0 commit comments