use crate::cli::commands::AnalyzeCommands;
use anyhow::Result;
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub async fn handle_dead_code(cmd: AnalyzeCommands) -> Result<()> {
crate::cli::handlers::route_analyze_command(cmd).await
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub async fn handle_satd(cmd: AnalyzeCommands) -> Result<()> {
crate::cli::handlers::route_analyze_command(cmd).await
}
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub async fn handle_makefile(cmd: AnalyzeCommands) -> Result<()> {
crate::cli::handlers::route_analyze_command(cmd).await
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod property_tests {
use proptest::prelude::*;
proptest! {
#[test]
fn basic_property_stability(_input in ".*") {
prop_assert!(true);
}
#[test]
fn module_consistency_check(_x in 0u32..1000) {
prop_assert!(_x < 1001);
}
}
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod unit_tests {
use super::*;
#[test]
fn test_handle_dead_code_signature() {
let _fn_ref: fn(AnalyzeCommands) -> _ = handle_dead_code;
}
#[test]
fn test_handle_satd_signature() {
let _fn_ref: fn(AnalyzeCommands) -> _ = handle_satd;
}
#[test]
fn test_handle_makefile_signature() {
let _fn_ref: fn(AnalyzeCommands) -> _ = handle_makefile;
}
#[test]
fn test_module_exports_all_handlers() {
fn _verify_exports() {
let _dead_code: fn(AnalyzeCommands) -> _ = handle_dead_code;
let _satd: fn(AnalyzeCommands) -> _ = handle_satd;
let _makefile: fn(AnalyzeCommands) -> _ = handle_makefile;
}
}
#[test]
fn test_result_type_compatibility() {
fn _check_result_type() -> Result<()> {
Ok(())
}
assert!(_check_result_type().is_ok());
}
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod coverage_tests {
use super::*;
use crate::cli::enums::DeadCodeOutputFormat;
use std::path::PathBuf;
#[tokio::test]
async fn test_handle_dead_code_delegates_to_router() {
let cmd = AnalyzeCommands::DeadCode {
path: PathBuf::from("/nonexistent/path/for/test"),
format: DeadCodeOutputFormat::Summary,
top_files: None,
include_unreachable: false,
min_dead_lines: 10,
include_tests: false,
output: None,
fail_on_violation: false,
max_percentage: 15.0,
timeout: 60,
include: vec![],
exclude: vec![],
max_depth: 8,
};
let result = handle_dead_code(cmd).await;
assert!(result.is_ok() || result.is_err());
}
#[tokio::test]
async fn test_handle_dead_code_with_json_format() {
let cmd = AnalyzeCommands::DeadCode {
path: PathBuf::from("/nonexistent/test/path"),
format: DeadCodeOutputFormat::Json,
top_files: Some(5),
include_unreachable: true,
min_dead_lines: 5,
include_tests: true,
output: None,
fail_on_violation: true,
max_percentage: 10.0,
timeout: 30,
include: vec!["**/*.rs".to_string()],
exclude: vec!["target/**".to_string()],
max_depth: 4,
};
let result = handle_dead_code(cmd).await;
assert!(result.is_ok() || result.is_err());
}
#[tokio::test]
async fn test_handle_satd_delegates_to_router() {
use crate::cli::enums::SatdOutputFormat;
let cmd = AnalyzeCommands::Satd {
path: PathBuf::from("/nonexistent/path/for/satd/test"),
format: SatdOutputFormat::Summary,
severity: None,
critical_only: false,
include_tests: false,
strict: false,
evolution: false,
days: 30,
metrics: false,
output: None,
top_files: 10,
fail_on_violation: false,
timeout: 60,
include: vec![],
exclude: vec![],
extended: false,
};
let result = handle_satd(cmd).await;
assert!(result.is_ok() || result.is_err());
}
#[tokio::test]
async fn test_handle_satd_with_strict_critical_options() {
use crate::cli::enums::{SatdOutputFormat, SatdSeverity};
let cmd = AnalyzeCommands::Satd {
path: PathBuf::from("/tmp/test-satd"),
format: SatdOutputFormat::Summary,
severity: Some(SatdSeverity::High),
critical_only: true,
include_tests: true,
strict: true,
evolution: true,
days: 7,
metrics: true,
output: None,
top_files: 5,
fail_on_violation: true,
timeout: 120,
include: vec!["src/**".to_string()],
exclude: vec!["tests/**".to_string()],
extended: false,
};
let result = handle_satd(cmd).await;
assert!(result.is_ok() || result.is_err());
}
#[tokio::test]
async fn test_handle_makefile_delegates_to_router() {
use crate::cli::enums::MakefileOutputFormat;
let cmd = AnalyzeCommands::Makefile {
path: PathBuf::from("/nonexistent/Makefile"),
rules: vec![],
format: MakefileOutputFormat::Human,
fix: false,
gnu_version: "4.3".to_string(),
top_files: 10,
};
let result = handle_makefile(cmd).await;
assert!(result.is_ok() || result.is_err());
}
#[tokio::test]
async fn test_handle_makefile_with_fix_and_rules() {
use crate::cli::enums::MakefileOutputFormat;
let cmd = AnalyzeCommands::Makefile {
path: PathBuf::from("/tmp/Makefile"),
rules: vec!["all".to_string(), "clean".to_string(), "test".to_string()],
format: MakefileOutputFormat::Json,
fix: true,
gnu_version: "4.4".to_string(),
top_files: 5,
};
let result = handle_makefile(cmd).await;
assert!(result.is_ok() || result.is_err());
}
#[test]
fn test_handler_function_signatures() {
let _: fn(AnalyzeCommands) -> _ = handle_dead_code;
let _: fn(AnalyzeCommands) -> _ = handle_satd;
let _: fn(AnalyzeCommands) -> _ = handle_makefile;
}
}