feat: scaffold v0.1 foundation
This commit is contained in:
parent
c4fb0c6a01
commit
170ca32f58
34 changed files with 6175 additions and 5 deletions
43
tests/cli.rs
Normal file
43
tests/cli.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#![allow(clippy::expect_used)]
|
||||
#![doc = "Black-box CLI framing and exit-status tests."]
|
||||
|
||||
use std::process::Command;
|
||||
|
||||
#[test]
|
||||
fn unimplemented_operation_is_a_typed_json_runtime_failure() {
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_ghidr"))
|
||||
.arg("doctor")
|
||||
.output()
|
||||
.expect("run ghidr");
|
||||
assert_eq!(output.status.code(), Some(1));
|
||||
assert!(output.stdout.is_empty());
|
||||
let error: serde_json::Value =
|
||||
serde_json::from_slice(&output.stderr).expect("valid JSON error");
|
||||
assert_eq!(error["error"]["code"], "internal_not_implemented");
|
||||
assert_eq!(error["error"]["details"]["operation"], "doctor");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_invocation_is_one_json_document_on_stderr() {
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_ghidr"))
|
||||
.args(["functions", "sample", "--limit", "0"])
|
||||
.output()
|
||||
.expect("run ghidr");
|
||||
assert_eq!(output.status.code(), Some(2));
|
||||
assert!(output.stdout.is_empty());
|
||||
let error: serde_json::Value =
|
||||
serde_json::from_slice(&output.stderr).expect("valid JSON error");
|
||||
assert_eq!(error["error"]["code"], "invalid_arguments");
|
||||
assert_eq!(output.stderr.last(), Some(&b'\n'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_human_parse_failure_is_not_json() {
|
||||
let output = Command::new(env!("CARGO_BIN_EXE_ghidr"))
|
||||
.args(["--format", "human", "decompile", "sample"])
|
||||
.output()
|
||||
.expect("run ghidr");
|
||||
assert_eq!(output.status.code(), Some(2));
|
||||
assert!(output.stdout.is_empty());
|
||||
assert!(serde_json::from_slice::<serde_json::Value>(&output.stderr).is_err());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue