Skip to content
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

[Feature]: Add support for capturing stdout and stderr #111

Open
tsv1 opened this issue Jan 2, 2025 · 0 comments
Open

[Feature]: Add support for capturing stdout and stderr #111

tsv1 opened this issue Jan 2, 2025 · 0 comments

Comments

@tsv1
Copy link
Member

tsv1 commented Jan 2, 2025

Summary

Introduce a CLI flag to capture stdout and stderr during execution. This will enhance the ability of plugins to write structured outputs, such as JSON or XML, to stdout without interference.

Problem

Currently, stdout and stderr are not captured, making it inconvenient for plugins to produce structured output formats like JSON or XML directly to stdout. This limitation hinders use cases where plugins, in addition to tests, generate output that needs to be processed or logged in a structured manner.

Proposal

Detailed Description

  1. Introduce a CLI Flag:

    • Add a flag (e.g., --capture-output) to enable capturing stdout and stderr.
    • By default, the flag is off, preserving the current behavior where output is not captured.
  2. Capture and Redirect Output:

    • Redirect stdout and stderr streams to an in-memory buffer or a designated file when the flag is enabled.
    • Provide an option to access the captured output at the end of execution.
  3. Integration with Plugins:

    • Ensure compatibility with existing plugins that may rely on current output behavior.
    • Plugins should be able to detect if output capturing is enabled and adjust their behavior accordingly.

Examples/Use Cases

  • CLI Usage:

    vedro run --capture-output
    • Captures stdout and stderr during the execution.
  • Plugin Scenario:

    • A reporting plugin writes test results in JSON to stdout. With capturing enabled, the JSON output can be saved or redirected for further processing.

Backward Compatibility Notes

  • The default behavior remains unchanged (output is not captured).
  • Users must explicitly enable the feature using the new CLI flag.

Alternatives Considered

  • Redirecting output to files by default: This approach was deemed intrusive and could disrupt existing workflows.
  • Plugin-level configuration: While providing flexibility, this would require additional effort from plugin developers and would not address the broader use case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant