Skip to main content

MockCommandRunner

Struct MockCommandRunner 

Source
pub struct MockCommandRunner {
Show 38 fields pub inference_response: String, pub inference_success: bool, pub convert_success: bool, pub tps: f64, pub crash: bool, pub inference_stderr: Option<String>, pub profile_ci_unavailable: bool, pub profile_ci_stderr: Option<String>, pub inspect_success: bool, pub validate_success: bool, pub bench_success: bool, pub check_success: bool, pub profile_success: bool, pub diff_tensors_success: bool, pub compare_inference_success: bool, pub custom_exit_code: Option<i32>, pub profile_flamegraph_success: bool, pub profile_focus_success: bool, pub fingerprint_success: bool, pub validate_stats_success: bool, pub validate_strict_success: bool, pub pull_success: bool, pub pull_model_path: String, pub inspect_json_success: bool, pub inspect_tensor_names: Vec<String>, pub ollama_success: bool, pub ollama_response: String, pub ollama_pull_success: bool, pub ollama_create_success: bool, pub serve_success: bool, pub http_get_success: bool, pub http_get_response: String, pub profile_memory_success: bool, pub chat_success: bool, pub chat_response: String, pub http_post_success: bool, pub http_post_response: String, pub spawn_serve_success: bool,
}
Expand description

Mock command runner for testing

This struct uses many boolean flags intentionally - each flag controls an independent success/failure behavior for testing different scenarios.

Fields§

§inference_response: String

Default response for inference

§inference_success: bool

Whether inference should succeed

§convert_success: bool

Default response for convert

§tps: f64

Tokens per second to report

§crash: bool

Simulate a crash (negative exit code)

§inference_stderr: Option<String>

Custom stderr message for inference

§profile_ci_unavailable: bool

Simulate profile_ci feature not available

§profile_ci_stderr: Option<String>

Custom stderr for profile_ci

§inspect_success: bool

Whether inspect should fail

§validate_success: bool

Whether validate should fail

§bench_success: bool

Whether bench should fail

§check_success: bool

Whether check should fail

§profile_success: bool

Whether profile should fail

§diff_tensors_success: bool

Whether diff_tensors should fail

§compare_inference_success: bool

Whether compare_inference should fail

§custom_exit_code: Option<i32>

Custom exit code (if Some, overrides normal exit code logic)

§profile_flamegraph_success: bool

Whether profile_with_flamegraph should fail

§profile_focus_success: bool

Whether profile_with_focus should fail

§fingerprint_success: bool

Whether fingerprint_model should fail

§validate_stats_success: bool

Whether validate_stats should fail

§validate_strict_success: bool

Whether validate_model_strict should fail

§pull_success: bool

Whether pull_model should succeed

§pull_model_path: String

Path returned by pull_model on success

§inspect_json_success: bool

Whether inspect_model_json should succeed

§inspect_tensor_names: Vec<String>

Tensor names returned by inspect_model_json

§ollama_success: bool

Whether ollama inference should succeed

§ollama_response: String

Custom response for ollama inference

§ollama_pull_success: bool

Whether ollama pull should succeed

§ollama_create_success: bool

Whether ollama create should succeed

§serve_success: bool

Whether serve_model should succeed

§http_get_success: bool

Whether http_get should succeed

§http_get_response: String

Custom HTTP response body

§profile_memory_success: bool

Whether profile_memory should succeed

§chat_success: bool

Whether run_chat should succeed

§chat_response: String

Custom response for chat

§http_post_success: bool

Whether http_post should succeed

§http_post_response: String

Custom response for http_post

§spawn_serve_success: bool

Whether spawn_serve should succeed

Implementations§

Source§

impl MockCommandRunner

Source

pub fn new() -> Self

Create a new mock runner with default responses

Source

pub fn with_inference_response(self, response: impl Into<String>) -> Self

Set the inference response

Source

pub fn with_inference_failure(self) -> Self

Set whether inference should fail

Source

pub fn with_convert_failure(self) -> Self

Set whether convert should fail

Source

pub fn with_tps(self, tps: f64) -> Self

Set the TPS to report

Source

pub fn with_crash(self) -> Self

Simulate a crash (negative exit code)

Source

pub fn with_inference_response_and_stderr( self, response: impl Into<String>, stderr: impl Into<String>, ) -> Self

Set the inference response with custom stderr

Source

pub fn with_profile_ci_unavailable(self) -> Self

Simulate profile_ci feature not available

Source

pub fn with_profile_ci_stderr(self, stderr: impl Into<String>) -> Self

Set custom stderr for profile_ci

Source

pub fn with_inspect_failure(self) -> Self

Set whether inspect should fail

Source

pub fn with_validate_failure(self) -> Self

Set whether validate should fail

Source

pub fn with_bench_failure(self) -> Self

Set whether bench should fail

Source

pub fn with_check_failure(self) -> Self

Set whether check should fail

Source

pub fn with_profile_failure(self) -> Self

Set whether profile should fail

Source

pub fn with_diff_tensors_failure(self) -> Self

Set whether diff_tensors should fail

Source

pub fn with_compare_inference_failure(self) -> Self

Set whether compare_inference should fail

Source

pub fn with_exit_code(self, code: i32) -> Self

Set a custom exit code for inference

Source

pub fn with_profile_flamegraph_failure(self) -> Self

Set whether profile_with_flamegraph should fail

Source

pub fn with_profile_focus_failure(self) -> Self

Set whether profile_with_focus should fail

Source

pub fn with_fingerprint_failure(self) -> Self

Set whether fingerprint_model should fail

Source

pub fn with_validate_stats_failure(self) -> Self

Set whether validate_stats should fail

Source

pub fn with_validate_strict_failure(self) -> Self

Set whether validate_model_strict should fail

Source

pub fn with_pull_failure(self) -> Self

Set whether pull_model should fail

Source

pub fn with_pull_model_path(self, path: impl Into<String>) -> Self

Set the model path returned by pull_model

Source

pub fn with_inspect_json_failure(self) -> Self

Set whether inspect_model_json should fail

Source

pub fn with_tensor_names(self, names: Vec<String>) -> Self

Set custom tensor names for inspect_model_json

Source

pub fn with_ollama_response(self, response: impl Into<String>) -> Self

Set custom ollama inference response

Source

pub fn with_ollama_failure(self) -> Self

Set whether ollama inference should fail

Source

pub fn with_ollama_pull_failure(self) -> Self

Set whether ollama pull should fail

Source

pub fn with_ollama_create_failure(self) -> Self

Set whether ollama create should fail

Source

pub fn with_serve_failure(self) -> Self

Set whether serve_model should fail

Source

pub fn with_http_get_failure(self) -> Self

Set whether http_get should fail

Source

pub fn with_http_get_response(self, response: impl Into<String>) -> Self

Set custom HTTP response body

Source

pub fn with_profile_memory_failure(self) -> Self

Set whether profile_memory should fail

Source

pub fn with_chat_failure(self) -> Self

Set whether run_chat should fail

Source

pub fn with_chat_response(self, response: impl Into<String>) -> Self

Set custom chat response

Source

pub fn with_http_post_failure(self) -> Self

Set whether http_post should fail

Source

pub fn with_http_post_response(self, response: impl Into<String>) -> Self

Set custom http_post response

Source

pub fn with_spawn_serve_failure(self) -> Self

Set whether spawn_serve should fail

Trait Implementations§

Source§

impl Clone for MockCommandRunner

Source§

fn clone(&self) -> MockCommandRunner

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CommandRunner for MockCommandRunner

Source§

fn run_inference( &self, _model_path: &Path, prompt: &str, _max_tokens: u32, _no_gpu: bool, _extra_args: &[&str], ) -> CommandOutput

Execute an apr run command
Source§

fn convert_model(&self, _source: &Path, _target: &Path) -> CommandOutput

Execute an apr convert command
Source§

fn inspect_model(&self, _model_path: &Path) -> CommandOutput

Execute an apr rosetta inspect command
Source§

fn validate_model(&self, _model_path: &Path) -> CommandOutput

Execute an apr validate command
Source§

fn validate_model_strict(&self, _model_path: &Path) -> CommandOutput

Execute an apr validate command with –strict –json flags Read more
Source§

fn bench_model(&self, _model_path: &Path) -> CommandOutput

Execute an apr bench command
Source§

fn check_model(&self, _model_path: &Path) -> CommandOutput

Execute an apr check command
Source§

fn profile_model( &self, _model_path: &Path, _warmup: u32, _measure: u32, ) -> CommandOutput

Execute an apr profile command
Source§

fn profile_ci( &self, _model_path: &Path, min_throughput: Option<f64>, max_p99: Option<f64>, _warmup: u32, _measure: u32, ) -> CommandOutput

Execute apr profile in CI mode
Source§

fn diff_tensors( &self, _model_a: &Path, _model_b: &Path, json: bool, ) -> CommandOutput

Execute apr rosetta diff-tensors
Source§

fn compare_inference( &self, _model_a: &Path, _model_b: &Path, _prompt: &str, _max_tokens: u32, _tolerance: f64, ) -> CommandOutput

Execute apr rosetta compare-inference
Source§

fn profile_with_flamegraph( &self, _model_path: &Path, _output_path: &Path, _no_gpu: bool, ) -> CommandOutput

Execute apr run with –profile and –profile-output for flamegraph
Source§

fn profile_with_focus( &self, _model_path: &Path, _focus: &str, _no_gpu: bool, ) -> CommandOutput

Execute apr run with –profile and –focus
Source§

fn fingerprint_model(&self, _model_path: &Path, json: bool) -> CommandOutput

Execute apr rosetta fingerprint to capture tensor statistics
Source§

fn validate_stats(&self, _fp_a: &Path, _fp_b: &Path) -> CommandOutput

Execute apr rosetta validate-stats to compare tensor statistics
Source§

fn pull_model(&self, _hf_repo: &str) -> CommandOutput

Execute apr pull --json <hf_repo> to acquire model from cache or remote
Source§

fn inspect_model_json(&self, _model_path: &Path) -> CommandOutput

Execute apr rosetta inspect --json to get model metadata including tensor names Read more
Source§

fn run_ollama_inference( &self, _model_tag: &str, _prompt: &str, _temperature: f64, ) -> CommandOutput

Execute ollama run <model_tag> for parity testing (GH-6/AC-2)
Source§

fn pull_ollama_model(&self, _model_tag: &str) -> CommandOutput

Execute ollama pull <model_tag> to acquire model (GH-6/AC-2)
Source§

fn create_ollama_model( &self, _model_tag: &str, _modelfile_path: &Path, ) -> CommandOutput

Execute ollama create <tag> -f <modelfile> to register a GGUF with ollama (F-OLLAMA-005)
Source§

fn serve_model(&self, _model_path: &Path, _port: u16) -> CommandOutput

Execute apr serve and return immediately (F-OLLAMA-004) Read more
Source§

fn http_get(&self, _url: &str) -> CommandOutput

Execute an HTTP GET request (F-OLLAMA-004)
Source§

fn profile_memory(&self, _model_path: &Path) -> CommandOutput

Execute apr profile --memory for memory usage (F-PERF-005)
Source§

fn run_chat( &self, _model_path: &Path, prompt: &str, _no_gpu: bool, _extra_args: &[&str], ) -> CommandOutput

Execute apr chat command with prompt piped via stdin (Bug 200)
Source§

fn http_post(&self, _url: &str, _body: &str) -> CommandOutput

Execute an HTTP POST request (Bug 200: serve modality)
Source§

fn spawn_serve( &self, _model_path: &Path, _port: u16, _no_gpu: bool, ) -> CommandOutput

Spawn apr serve in background and return the child process PID (Bug 200) Read more
Source§

impl Debug for MockCommandRunner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MockCommandRunner

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more