Skip to content

Reject --jsonbin stdout/stderr or define sidecar behavior for stream outputs #406

Description

@oleksandr-pavlyk

Problem

--jsonbin currently accepts stdout and stderr as output destinations:

./benchmark --jsonbin stdout
./benchmark --jsonbin stderr

This is problematic because jsonbin output writes binary sidecar files and records sidecar filenames in the JSON summaries. Those filenames are
intended to be relative to the JSON output file's directory.

For stream destinations, there is no JSON file path to anchor those sidecar paths. Today, json_printer treats the stream name as a filesystem
path, so it may create directories such as stdout-bin/ or stderr-bin/ in the current working directory and record sidecar paths that are not
meaningfully relative to a JSON file.

Desired Behavior

Define and enforce the CLI contract for jsonbin stream destinations.

Likely behavior:

  • Keep --json stdout and --json stderr supported.
  • Reject --jsonbin stdout and --jsonbin stderr with a clear error message.
  • Require --jsonbin to use an actual filesystem path, for example:
./benchmark --jsonbin results.json

Possible Implementation

Add a shared helper for stream printer specs, for example:

bool is_stream_printer_spec(const std::string& spec)
{
  return spec == "stdout" || spec == "stderr";
}

Use it in both: option_parser::printer_spec_to_ostream and option_parser::add_json_printer. Reject stream destinations only when enable_binary == true.

Notes

This was flagged during review of the jsonbin sidecar path handling changes #405. It is being tracked separately to keep that PR focused on making sidecar filenames relative to the JSON output path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions