Main entry point for the test analyzer.
()
| 658 | return '\n'.join(lines) |
| 659 | |
| 660 | def main(): |
| 661 | """Main entry point for the test analyzer.""" |
| 662 | parser = argparse.ArgumentParser( |
| 663 | description="Test Analyzer for PyFlowGraph", |
| 664 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 665 | epilog=""" |
| 666 | Examples: |
| 667 | python test_analyzer.py # Analyze latest test results |
| 668 | python test_analyzer.py --results test_output.json # Analyze specific results |
| 669 | python test_analyzer.py --format claude # Claude Code optimized output |
| 670 | python test_analyzer.py --coverage-only # Focus on coverage analysis |
| 671 | """ |
| 672 | ) |
| 673 | |
| 674 | parser.add_argument("--results", type=Path, |
| 675 | help="Test results JSON file to analyze") |
| 676 | parser.add_argument("--format", choices=["detailed", "summary", "claude"], |
| 677 | default="detailed", help="Output format") |
| 678 | parser.add_argument("--coverage-only", action="store_true", |
| 679 | help="Focus only on coverage analysis") |
| 680 | parser.add_argument("--output-file", type=Path, |
| 681 | help="Save report to file") |
| 682 | |
| 683 | args = parser.parse_args() |
| 684 | |
| 685 | try: |
| 686 | analyzer = TestAnalyzer() |
| 687 | |
| 688 | if args.coverage_only: |
| 689 | # Just analyze coverage gaps |
| 690 | gaps = analyzer.analyze_coverage_gaps() |
| 691 | print(f"Found {len(gaps)} coverage gaps") |
| 692 | for gap in gaps: |
| 693 | print(f" {gap.priority}: {gap.file_path}::{gap.function_name}") |
| 694 | else: |
| 695 | # Full analysis |
| 696 | report = analyzer.analyze(args.results) |
| 697 | formatted_report = analyzer.format_report(report, args.format) |
| 698 | |
| 699 | print(formatted_report) |
| 700 | |
| 701 | if args.output_file: |
| 702 | with open(args.output_file, 'w') as f: |
| 703 | f.write(formatted_report) |
| 704 | print(f"\nReport saved to: {args.output_file}") |
| 705 | |
| 706 | except Exception as e: |
| 707 | print(f"Error analyzing tests: {e}") |
| 708 | sys.exit(1) |
| 709 | |
| 710 | if __name__ == "__main__": |
| 711 | main() |
no test coverage detected