Skip to content

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
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

tienquocbui
Copy link
Member

@tienquocbui tienquocbui commented Aug 6, 2025

Add experimental AdvancedConsoleOutputRecorder skeleton framework

Motivation:

The current console output for swift test is a static log, which presents challenges for developers in understanding test progress and diagnosing failures, especially in large, parallel test suites. This PR introduces the foundational "skeleton" for a new, advanced console reporter to address these issues.

The recorder is marked as experimental and must be explicitly enabled via the SWT_ENABLE_EXPERIMENTAL_CONSOLE_OUTPUT environment variable, ensuring it doesn't affect existing functionality.

Modifications:

  • Added Event.AdvancedConsoleOutputRecorder.swift: New experimental console output recorder skeleton with:
    • Basic structure and minimal configuration options
    • Currently delegates to Event.ConsoleOutputRecorder for actual output
    • Foundation framework ready for future development of advanced features

The implementation provides the foundation structure following established patterns in the codebase, ready for future development of advanced console features.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

tienquocbui and others added 14 commits July 7, 2025 21:30
…ting

- Implement Event.AdvancedConsoleOutputRecorder with beautiful tree structure
- Add SF symbols support with colors (play.circle, checkmark.circle, x.circle, etc.)
- Right-aligned timing display with 80-column fixed width
- Unicode box-drawing characters for hierarchical test output
- Issues displayed as sub-nodes under failed tests
- Enhanced start message with test count and running status
- Thread-safe parallel execution support
- Color-coded final summary with status icons
- Replace basic ConsoleOutputRecorder with enhanced version
- Add demo test files for validation

Features:
✅ Hierarchical tree structure with proper indentation
✅ SF Symbols on macOS with Unicode fallback
✅ Right-aligned timing information
✅ Color-coded status icons and output
✅ Issues as expandable sub-nodes
✅ Enhanced start/end messages
✅ Thread-safe concurrent test execution
Implementing progress bar with live update
- Add experimental AdvancedConsoleOutputRecorder activated via environment variable
- Implement clean skeleton structure for incremental PR development
- Fix terminal width hardcoding with 80-char safe fallback
- Follow HumanReadableOutputRecorder delegation pattern
- Update style guide compliance (80-char comment wrapping)
- Re-enable AttachmentTests and disable slow demo test suites
- Remove Foundation dependencies and signal handling
- Prepare foundation for PR #1 (Skeleton), PR #2 (Hierarchy), PR #3 (Progress)
- Update to latest main branch from upstream/main
- Integrate new ABI version handling and entry point improvements
- Preserve AdvancedConsoleOutputRecorder skeleton implementation
- Ready for first PR submission
Complete skeleton PR #1 preparation:
- Clean AdvancedConsoleOutputRecorder framework
- Environment variable activation integrated
- Latest upstream changes merged
- Ready for first PR submission
- Use upstream conditional compilation directives
- Match upstream verbosity check (> .min instead of >= 0)
- Simplify AdvancedConsoleOutputRecorder options for skeleton
- Fix event handler ordering to match upstream pattern
- Maintain zero impact on default behavior
@stmontgomery
Copy link
Contributor

@swift-ci please test

@grynspan
Copy link
Contributor

grynspan commented Aug 8, 2025

I've changed this PR to draft status for the moment. Once CI is passing, we can bring it back up. (I just don't want to accidentally click Merge before then.)

@grynspan grynspan marked this pull request as draft August 8, 2025 17:11
The Environment.flag(named:) function returns Bool? but was being used directly in an if statement. Changed to explicit comparison with true to handle the optional properly.
@stmontgomery
Copy link
Contributor

@swift-ci please test

@stmontgomery
Copy link
Contributor

@swift-ci please test

@stmontgomery
Copy link
Contributor

@swift-ci please test Linux

@stmontgomery stmontgomery marked this pull request as ready for review August 8, 2025 20:13
@stmontgomery
Copy link
Contributor

@swift-ci please test

@grynspan
Copy link
Contributor

grynspan commented Aug 8, 2025

I'll take a closer look on Monday!

@stmontgomery
Copy link
Contributor

@swift-ci please test

Copy link
Contributor

@grynspan grynspan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an overall abstraction problem here, which is that this code is eventually going to be moved to a separate repository (either SwiftPM or a new one) and will need to decode the JSON event stream rather than directly interact with our Swift Event type and its friends.

The code you build for this feature should be structured to take JSON Lines as input so that it's easy for us to migrate it. Otherwise it creates a large amount of work for us in the future to rewrite it to do that. Let's get it right the first time!

So I'd suggest that you refactor this code so that the event handler in EntryPoint.swift generates JSON lines as output (note we already do that, so see if you can reuse the existing code path for that!) and then have AdvancedConsoleOutputRecorder decode the JSON lines and process them.

(The visible effect will be that the output does not get forwarded to the existing ConsoleOutputRecorder type, but that's okay. We're not trying to make it look pretty yet.)

@grynspan
Copy link
Contributor

A cross-platform way to detect terminal width, which is essential for responsive formatting and avoids non-portable tools like stty size.

Placeholder for cross-platform terminal width detection

I don't see this functionality, even stubbed out, anywhere. Did I miss it?

@grynspan grynspan added the gsoc ☀️ Google Summer of Code contributions label Aug 13, 2025
- Change handle() to record() for consistency with other recorders
- Update documentation to use proper DocC reference (Event/ConsoleOutputRecorder)
- Remove unused configuration options (useHierarchicalOutput, showSuccessfulTests)
- Simplify LiveUpdatingLine documentation
- Remove future capability descriptions from main documentation
Since we cannot control the output stream, the LiveUpdatingLine functionality
is not usable in practice and should be removed from the skeleton implementation.
@tienquocbui
Copy link
Member Author

A cross-platform way to detect terminal width, which is essential for responsive formatting and avoids non-portable tools like stty size.

Placeholder for cross-platform terminal width detection

I don't see this functionality, even stubbed out, anywhere. Did I miss it?

That's my mistake in the PR description, the terminal width detection will be implemented in the follow-up PRs

@stmontgomery
Copy link
Contributor

@swift-ci please test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command-line experience ⌨️ enhancements to the command line interface enhancement New feature or request gsoc ☀️ Google Summer of Code contributions
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants