()
| 10 | |
| 11 | |
| 12 | async def run(): |
| 13 | settings = get_settings().get("default") |
| 14 | args = parse_args_full_repo(settings) |
| 15 | |
| 16 | if args.project_language == "python": |
| 17 | context_helper = ContextHelper(args) |
| 18 | else: |
| 19 | raise NotImplementedError("Unsupported language: {}".format(args.project_language)) |
| 20 | |
| 21 | # scan the project directory for test files |
| 22 | test_files = find_test_files(args) |
| 23 | print("============\nTest files to be extended:\n" + "".join(f"{f}\n============\n" for f in test_files)) |
| 24 | |
| 25 | # start the language server |
| 26 | async with context_helper.start_server(): |
| 27 | print("LSP server initialized.") |
| 28 | |
| 29 | generate_log_files = not args.suppress_log_files |
| 30 | ai_caller = AICaller(model=args.model, generate_log_files=generate_log_files) |
| 31 | |
| 32 | # main loop for analyzing test files |
| 33 | for test_file in test_files: |
| 34 | # Find the context files for the test file |
| 35 | context_files = await context_helper.find_test_file_context(test_file) |
| 36 | print("Context files for test file '{}':\n{}".format(test_file, "".join(f"{f}\n" for f in context_files))) |
| 37 | |
| 38 | # Analyze the test file against the context files |
| 39 | print("\nAnalyzing test file against context files...") |
| 40 | source_file, context_files_include = await context_helper.analyze_context( |
| 41 | test_file, context_files, ai_caller |
| 42 | ) |
| 43 | |
| 44 | if source_file: |
| 45 | try: |
| 46 | # Run the CoverAgent for the test file |
| 47 | args_copy = copy.deepcopy(args) |
| 48 | args_copy.source_file_path = source_file |
| 49 | args_copy.test_command_dir = args.project_root |
| 50 | args_copy.test_file_path = test_file |
| 51 | args_copy.included_files = context_files_include |
| 52 | |
| 53 | config = CoverAgentConfig.from_cli_args_with_defaults(args_copy) |
| 54 | agent = CoverAgent(config) |
| 55 | agent.run() |
| 56 | except Exception as e: |
| 57 | print(f"Error running CoverAgent for test file '{test_file}': {e}") |
| 58 | pass |
| 59 | |
| 60 | |
| 61 | def main(): |
no test coverage detected