-
Notifications
You must be signed in to change notification settings - Fork 120
Add experimental AdvancedConsoleOutputRecorder skeleton framework #1253
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
Open
tienquocbui
wants to merge
17
commits into
swiftlang:main
Choose a base branch
from
tienquocbui:gsoc-development
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+87
−6
Open
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8831664
feat: Add advanced hierarchical console output recorder for Swift Tes…
tienquocbui 1786cbf
Merge remote-tracking branch 'upstream/main'
tienquocbui b067a9a
Merge branch 'swiftlang:main' into main
tienquocbui 73a60ae
Add advanced console output recorder with progress bar and hierarchic…
tienquocbui 87425d9
Merge branch 'swiftlang:main' into feature/advanced-console-output-re…
tienquocbui bea236d
Implementing progress bar with live update
tienquocbui fd9a811
Merge pull request #1 from tienquocbui/kelvin/new-console-output
tienquocbui 042438f
Fix: Signal Handling System and Live Failure Reporting
tienquocbui 699459c
Add skeleton AdvancedConsoleOutputRecorder framework
tienquocbui 6a1c6db
Merge main branch with latest upstream changes
tienquocbui f6c46fa
Fix trailing newline in AdvancedConsoleOutputRecorder
tienquocbui ef8252b
Align experimental integration with upstream patterns
tienquocbui c82be0b
Add experimental AdvancedConsoleOutputRecorder skeleton
tienquocbui 7eb599a
Merge upstream/main into gsoc-development
tienquocbui 16e581a
Fix Environment.flag optional unwrapping in EntryPoint.swift
tienquocbui 3c80e1b
Fix skeleton implementation based on code review feedback
tienquocbui 0a496ac
Remove LiveUpdatingLine.swift and its CMakeLists.txt reference
tienquocbui File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
Sources/Testing/Events/Recorder/Event.AdvancedConsoleOutputRecorder.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2025 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
// | ||
|
||
extension Event { | ||
/// An experimental console output recorder that provides enhanced test result | ||
/// display capabilities. | ||
/// | ||
/// This recorder is currently experimental and must be enabled via the | ||
/// `SWT_ENABLE_EXPERIMENTAL_CONSOLE_OUTPUT` environment variable. | ||
/// | ||
/// Future capabilities will include: | ||
/// - Hierarchical test result display with tree visualization | ||
/// - Live progress indicators during test execution | ||
/// - Enhanced SF Symbols integration on supported platforms | ||
struct AdvancedConsoleOutputRecorder: Sendable { | ||
/// Configuration options for the advanced console output recorder. | ||
struct Options: Sendable { | ||
/// Base console output recorder options to inherit from. | ||
var base: Event.ConsoleOutputRecorder.Options | ||
|
||
/// Whether to enable experimental hierarchical output display. | ||
/// Currently unused - reserved for future PR #2. | ||
var useHierarchicalOutput: Bool | ||
tienquocbui marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// Whether to show successful tests in the output. | ||
/// Currently unused - reserved for future PR #2. | ||
var showSuccessfulTests: Bool | ||
|
||
init() { | ||
self.base = Event.ConsoleOutputRecorder.Options() | ||
self.useHierarchicalOutput = true | ||
self.showSuccessfulTests = true | ||
} | ||
} | ||
|
||
/// The options for this recorder. | ||
let options: Options | ||
|
||
/// The write function for this recorder. | ||
let write: @Sendable (String) -> Void | ||
|
||
/// The fallback console recorder for standard output. | ||
private let _fallbackRecorder: Event.ConsoleOutputRecorder | ||
|
||
/// Initialize the advanced console output recorder. | ||
/// | ||
/// - Parameters: | ||
/// - options: Configuration options for the recorder. | ||
/// - write: A closure that writes output to its destination. | ||
init(options: Options = Options(), writingUsing write: @escaping @Sendable (String) -> Void) { | ||
self.options = options | ||
self.write = write | ||
self._fallbackRecorder = Event.ConsoleOutputRecorder(options: options.base, writingUsing: write) | ||
} | ||
} | ||
} | ||
|
||
extension Event.AdvancedConsoleOutputRecorder { | ||
/// Handle an event by processing it and generating appropriate output. | ||
/// | ||
/// Currently this is a skeleton implementation that delegates to the | ||
/// standard ConsoleOutputRecorder. | ||
tienquocbui marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// | ||
/// - Parameters: | ||
/// - event: The event to handle. | ||
/// - eventContext: The context associated with the event. | ||
func handle(_ event: borrowing Event, in eventContext: borrowing Event.Context) { | ||
tienquocbui marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Skeleton implementation: delegate to standard recorder | ||
// Future PRs will add enhanced functionality here | ||
_fallbackRecorder.record(event, in: eventContext) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2025 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
// | ||
|
||
/// Prints a string to the console by overwriting the current line without creating a new line. | ||
/// This is ideal for creating single-line, live-updating progress bars or status indicators. | ||
/// | ||
/// - Parameter text: The text to display on the current line | ||
/// | ||
/// ## Technical Details | ||
/// - Uses carriage return (`\r`) to move cursor to beginning of current line | ||
/// - Uses ANSI escape code (`\u{001B}[2K`) to clear the entire line | ||
/// - Does not append a newline character, allowing the line to be overwritten again | ||
/// | ||
/// ## Example Usage | ||
/// ```swift | ||
/// printLiveUpdatingLine("Processing... 25%") | ||
/// // Later... | ||
/// printLiveUpdatingLine("Processing... 50%") | ||
/// // Later... | ||
/// printLiveUpdatingLine("Processing... 100%") | ||
/// ``` | ||
public func printLiveUpdatingLine(_ text: String) { | ||
tienquocbui marked this conversation as resolved.
Show resolved
Hide resolved
|
||
print("\r\u{001B}[2K\(text)", terminator: "") | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.