创建测试调用关系
(
&self,
test_function: &FunctionInfo,
all_functions: &[FunctionInfo],
code_graph: &mut PetCodeGraph,
)
| 1427 | |
| 1428 | /// 创建测试调用关系 |
| 1429 | fn _create_test_calls( |
| 1430 | &self, |
| 1431 | test_function: &FunctionInfo, |
| 1432 | all_functions: &[FunctionInfo], |
| 1433 | code_graph: &mut PetCodeGraph, |
| 1434 | ) { |
| 1435 | // 为测试函数创建到被测试函数的调用关系 |
| 1436 | let test_name = test_function.name.to_lowercase(); |
| 1437 | |
| 1438 | for other_func in all_functions { |
| 1439 | if other_func.id != test_function.id { |
| 1440 | let other_name = other_func.name.to_lowercase(); |
| 1441 | |
| 1442 | // 检查是否是被测试的函数 |
| 1443 | if test_name.contains(&other_name) || other_name.contains("test") { |
| 1444 | let relation = CallRelation { |
| 1445 | caller_id: test_function.id, |
| 1446 | callee_id: other_func.id, |
| 1447 | caller_name: test_function.name.clone(), |
| 1448 | callee_name: other_func.name.clone(), |
| 1449 | caller_file: test_function.file_path.clone(), |
| 1450 | callee_file: other_func.file_path.clone(), |
| 1451 | line_number: test_function.line_start, |
| 1452 | is_resolved: false, // 启发式调用标记为未解析 |
| 1453 | }; |
| 1454 | |
| 1455 | if let Err(e) = code_graph.add_call_relation(relation) { |
| 1456 | warn!("Failed to add test call relation: {}", e); |
| 1457 | } |
| 1458 | } |
| 1459 | } |
| 1460 | } |
| 1461 | } |
| 1462 | } |
| 1463 | |
| 1464 | /// 调用分析统计信息 |
no test coverage detected