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.
Problem
--jsonbincurrently acceptsstdoutandstderras output destinations: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:
--json stdoutand--json stderrsupported.--jsonbin stdoutand--jsonbin stderrwith a clear error message.--jsonbinto use an actual filesystem path, for example:Possible Implementation
Add a shared helper for stream printer specs, for example:
Use it in both:
option_parser::printer_spec_to_ostreamandoption_parser::add_json_printer. Reject stream destinations only whenenable_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.