use super::*;
#[test]
fn test_inspect_command_echo_example() {
use super::inspect_command;
use super::InspectionFormat;
let result = inspect_command("echo-example", InspectionFormat::Markdown, None, false);
let _ = result; }
#[test]
fn test_inspect_command_bootstrap_example() {
use super::inspect_command;
use super::InspectionFormat;
let result = inspect_command("bootstrap-example", InspectionFormat::Json, None, false);
let _ = result; }
#[test]
fn test_inspect_command_json_ast() {
use super::inspect_command;
use super::InspectionFormat;
let json_ast = r#"{"ExecuteCommand": {"command_name": "echo", "args": ["test"]}}"#;
let result = inspect_command(json_ast, InspectionFormat::Markdown, None, false);
let _ = result; }
#[test]
fn test_inspect_command_invalid_input() {
use super::inspect_command;
use super::InspectionFormat;
let result = inspect_command("invalid-example", InspectionFormat::Markdown, None, false);
assert!(result.is_err());
}
#[test]
fn test_inspect_command_html_format() {
use super::inspect_command;
use super::InspectionFormat;
let result = inspect_command("echo-example", InspectionFormat::Html, None, false);
let _ = result; }
#[test]
fn test_inspect_command_with_output_file() {
use super::inspect_command;
use super::InspectionFormat;
use tempfile::NamedTempFile;
let temp_file = NamedTempFile::new().unwrap();
let result = inspect_command(
"echo-example",
InspectionFormat::Markdown,
Some(temp_file.path()),
false,
);
let _ = result;
let content = fs::read_to_string(temp_file.path()).unwrap();
assert!(!content.is_empty());
assert!(content.contains("Formal Verification Report"));
}
#[test]
fn test_inspect_command_invalid_json() {
use super::inspect_command;
use super::InspectionFormat;
let invalid_json = r#"{"invalid": json}"#;
let result = inspect_command(invalid_json, InspectionFormat::Json, None, false);
assert!(result.is_err());
}
#[test]
fn test_inspect_command_all_formats() {
use super::inspect_command;
use super::InspectionFormat;
for format in [
InspectionFormat::Markdown,
InspectionFormat::Json,
InspectionFormat::Html,
] {
let result = inspect_command("echo-example", format.clone(), None, false);
assert!(result.is_ok(), "Failed with format: {format:?}");
}
}
#[test]
fn test_inspect_command_rust_file() {
let temp_dir = TempDir::new().unwrap();
let input_path = temp_dir.path().join("test.rs");
fs::write(&input_path, "fn main() { let x = 42; }").unwrap();
let result = inspect_command(
input_path.to_str().unwrap(),
InspectionFormat::Markdown,
None,
false,
);
let _ = result;
}
#[test]
fn test_inspect_command_shell_script() {
let temp_dir = TempDir::new().unwrap();
let input_path = temp_dir.path().join("script.sh");
fs::write(&input_path, "#!/bin/bash\necho hello").unwrap();
let result = inspect_command(
input_path.to_str().unwrap(),
InspectionFormat::Json,
None,
true,
);
let _ = result;
}
#[test]
fn test_make_parse_command_basic() {
let temp_dir = TempDir::new().unwrap();
let makefile = temp_dir.path().join("Makefile");
fs::write(
&makefile,
".PHONY: all clean\n\nall:\n\t@echo 'Building...'\n\nclean:\n\t@rm -f *.o\n",
)
.unwrap();
let result = make_parse_command(&makefile, MakeOutputFormat::Text);
assert!(result.is_ok());
}
#[test]
fn test_make_parse_command_json_format() {
let temp_dir = TempDir::new().unwrap();
let makefile = temp_dir.path().join("Makefile");
fs::write(&makefile, "all:\n\t@echo 'test'\n").unwrap();
let result = make_parse_command(&makefile, MakeOutputFormat::Json);
assert!(result.is_ok());
}
#[test]
fn test_make_lint_command_basic() {
let temp_dir = TempDir::new().unwrap();
let makefile = temp_dir.path().join("Makefile");
fs::write(
&makefile,
".SUFFIXES:\n.DELETE_ON_ERROR:\n.PHONY: all\nall:\n\t@echo test\n",
)
.unwrap();
let result = make_lint_command(&makefile, LintFormat::Human, false, None, None);
assert!(result.is_ok());
}
#[test]
fn test_make_lint_command_with_fix() {
let temp_dir = TempDir::new().unwrap();
let makefile = temp_dir.path().join("Makefile");
let output = temp_dir.path().join("Makefile.fixed");
fs::write(&makefile, ".PHONY: all\nall:\n\t@echo test\n").unwrap();
let result = make_lint_command(&makefile, LintFormat::Human, true, Some(&output), None);
let _ = result;
}
#[test]
fn test_make_lint_command_json_format() {
let temp_dir = TempDir::new().unwrap();
let makefile = temp_dir.path().join("Makefile");
fs::write(&makefile, ".PHONY: all\nall:\n\t@echo test\n").unwrap();
let result = make_lint_command(
&makefile,
LintFormat::Human,
false,
None,
Some("NONEXISTENT"),
);
let _ = result;
}
#[test]
fn test_make_lint_command_with_rules_filter() {
let temp_dir = TempDir::new().unwrap();
let makefile = temp_dir.path().join("Makefile");
fs::write(&makefile, "all:\n\t@echo test\n").unwrap();
let result = make_lint_command(&makefile, LintFormat::Human, false, None, Some("MAKE001"));
let _ = result;
}
#[test]
fn test_make_purify_command_basic() {
let temp_dir = TempDir::new().unwrap();
let input = temp_dir.path().join("Makefile");
let output = temp_dir.path().join("Makefile.purified");
fs::write(&input, ".PHONY: all\nall:\n\t@echo test\n").unwrap();
let result = make_purify_command(
&input,
Some(&output),
false, false, ReportFormat::Human,
false, false, false, None, false, false, );
assert!(result.is_ok());
}
#[test]
fn test_config_analyze_command_basic() {
let temp_dir = TempDir::new().unwrap();
let config_file = temp_dir.path().join(".bashrc");
fs::write(
&config_file,
"export PATH=\"/usr/bin:$PATH\"\nalias ll='ls -la'\n",
)
.unwrap();
let result = config_analyze_command(&config_file, ConfigOutputFormat::Human);
assert!(result.is_ok());
}
#[test]
fn test_config_analyze_command_json() {
let temp_dir = TempDir::new().unwrap();
let config_file = temp_dir.path().join(".zshrc");
fs::write(&config_file, "export EDITOR=vim\n").unwrap();
let result = config_analyze_command(&config_file, ConfigOutputFormat::Json);
assert!(result.is_ok());
}
#[test]
fn test_config_lint_command_basic() {
let temp_dir = TempDir::new().unwrap();
let config_file = temp_dir.path().join(".bashrc");
fs::write(&config_file, "export PATH=/usr/bin\n").unwrap();
let result = config_lint_command(&config_file, ConfigOutputFormat::Human);
let _ = result;
}
#[test]
fn test_config_analyze_command_json_format() {
let temp_dir = TempDir::new().unwrap();
let config_file = temp_dir.path().join(".bashrc");
fs::write(
&config_file,
"export PATH=/usr/bin:$PATH\nalias ll='ls -la'\n",
)
.unwrap();
let result = config_analyze_command(&config_file, ConfigOutputFormat::Json);
assert!(result.is_ok());
}
#[test]
fn test_config_analyze_command_nonexistent() {
let result = config_analyze_command(
&PathBuf::from("/nonexistent/.bashrc"),
ConfigOutputFormat::Human,
);
assert!(result.is_err());
}
#[test]
fn test_config_lint_command_json() {
let temp_dir = TempDir::new().unwrap();
let config_file = temp_dir.path().join(".bashrc");
fs::write(&config_file, "export PATH=/usr/bin\n").unwrap();
let result = config_lint_command(&config_file, ConfigOutputFormat::Json);
let _ = result;
}
#[test]
fn test_purify_command_basic() {
let temp_dir = TempDir::new().unwrap();
let input_path = temp_dir.path().join("script.sh");
let output_path = temp_dir.path().join("purified.sh");
fs::write(&input_path, "#!/bin/bash\necho $RANDOM").unwrap();
let result = purify_command(PurifyCommandOptions {
input: &input_path,
output: Some(&output_path),
report: false,
with_tests: false,
property_tests: false,
type_check: false,
emit_guards: false,
type_strict: false,
diff: false,
verify: false,
recursive: false,
});
let _ = result;
}
#[test]
fn test_purify_command_with_lint() {
let temp_dir = TempDir::new().unwrap();
let input_path = temp_dir.path().join("script.sh");
fs::write(&input_path, "#!/bin/bash\necho hello world").unwrap();
let result = purify_command(PurifyCommandOptions {
input: &input_path,
output: None,
report: true,
with_tests: false,
property_tests: false,
type_check: false,
emit_guards: false,
type_strict: false,
diff: false,
verify: false,
recursive: false,
});
let _ = result;
}
#[test]
include!("command_tests_tools_tests_purify.rs");