mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00:00
Plugins running compilers, linters or large diffs lost output: `start` kept only a 1 MiB tail and `run`/`run-command` truncated stderr. API 1.15 adds `process-options` (`max-output-bytes` up to 128 MiB, `buffer-bytes` up to 4 MiB), `run-captured`, which fails explicitly when either stream overflows, and `start-stream`, which streams losslessly with pipe backpressure: readers pause at the buffer limit, resume as `poll`/`chunk` consume, and `wait` drains up to the total limit so fast producers don't deadlock. Overflow stops the process tree and records its exit status before reaping it. `run`, `run-command` and `start` behave as before, and 1.14 components still load. Closes #4763 Co-authored-by: Akin01 <16496278+Akin01@users.noreply.github.com>
29 lines
1005 B
Rust
29 lines
1005 B
Rust
use openidea_plugin::{
|
|
ProcessOutput,
|
|
host::{self, Command, ProcessOptions},
|
|
mock::MockHost,
|
|
};
|
|
|
|
#[test]
|
|
fn process_captured_and_stream_apis_are_available_in_sdk() {
|
|
let mock = MockHost::install().with_capabilities(&["process:git"]);
|
|
mock.on_process("git", |_args, _stdin| {
|
|
Ok(ProcessOutput { status: Some(0), stdout: "mock stdout".into(), stderr: String::new() })
|
|
});
|
|
|
|
let cmd = Command::new("git").arg("status");
|
|
let options = ProcessOptions { max_output_bytes: Some(8 << 20), buffer_bytes: Some(64 << 10) };
|
|
|
|
let out = host::run_captured(&cmd, None, None, Some(options)).unwrap();
|
|
assert_eq!(out.status, Some(0));
|
|
assert_eq!(out.stdout, "mock stdout");
|
|
|
|
let child = host::start_stream(&cmd, None, Some(options)).unwrap();
|
|
let chunk = child.poll(1024).unwrap();
|
|
assert_eq!(chunk.stdout, "started: git\n");
|
|
assert_eq!(chunk.status, None);
|
|
|
|
let final_chunk = child.wait(100).unwrap();
|
|
assert_eq!(final_chunk.status, Some(0));
|
|
}
|