Skip to content

Capture StdoutInterceptor #72

@roxblnfk

Description

@roxblnfk

Need a global interceptor that buffers test output (stdout).

The interceptor should:

  • Wrap test execution with ob_start() / ob_get_clean()
  • Store captured output in TestResult metadata
  • Renderers decide how to display it (e.g., TeamCity shows always, CLI shows only on failure)
  • Track ob_get_level() before and after test. If level changed and test passed — mark as risky (default behavior)

Attribute

#[BufferOutput(enabled: bool)] — controls buffer capture for specific test.

Can be used to:

  • Disable capture when globally enabled
  • Enable capture when globally disabled

Open questions

how to configure behavior on buffer level mismatch?

Options:

  • onLevelMismatch: Status::Failed — single param for any change
  • onLevelIncrease / onLevelDecrease — separate params (increase = buffer leak, decrease = test closed external buffer)
  • null to ignore

Needs more thought on real use cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions