|
30 | 30 | replace_function_definitions_in_module, |
31 | 31 | ) |
32 | 32 | from codeflash.code_utils.code_utils import ( |
33 | | - ImportErrorPattern, |
34 | 33 | cleanup_paths, |
35 | 34 | create_rank_dictionary_compact, |
36 | 35 | diff_length, |
| 36 | + extract_unique_errors, |
37 | 37 | file_name_from_test_module_name, |
38 | 38 | get_run_tmp_file, |
39 | 39 | module_name_from_file_path, |
@@ -1576,11 +1576,14 @@ def establish_original_code_baseline( |
1576 | 1576 | ) |
1577 | 1577 | if not behavioral_results: |
1578 | 1578 | logger.warning( |
1579 | | - f"force_lsp|Couldn't run any tests for original function {self.function_to_optimize.function_name}. SKIPPING OPTIMIZING THIS FUNCTION." |
| 1579 | + f"force_lsp|Couldn't run any tests for original function {self.function_to_optimize.function_name}. Skipping optimization." |
1580 | 1580 | ) |
1581 | 1581 | console.rule() |
1582 | 1582 | return Failure("Failed to establish a baseline for the original code - bevhavioral tests failed.") |
1583 | 1583 | if not coverage_critic(coverage_results, self.args.test_framework): |
| 1584 | + did_pass_all_tests = all(result.did_pass for result in behavioral_results) |
| 1585 | + if not did_pass_all_tests: |
| 1586 | + return Failure("Tests failed to pass for the original code.") |
1584 | 1587 | return Failure( |
1585 | 1588 | f"Test coverage is {coverage_results.coverage}%, which is below the required threshold of {COVERAGE_THRESHOLD}%." |
1586 | 1589 | ) |
@@ -1944,12 +1947,19 @@ def run_and_parse_tests( |
1944 | 1947 | f"stdout: {run_result.stdout}\n" |
1945 | 1948 | f"stderr: {run_result.stderr}\n" |
1946 | 1949 | ) |
1947 | | - if "ModuleNotFoundError" in run_result.stdout: |
| 1950 | + |
| 1951 | + unique_errors = extract_unique_errors(run_result.stdout) |
| 1952 | + |
| 1953 | + if unique_errors: |
1948 | 1954 | from rich.text import Text |
1949 | 1955 |
|
1950 | | - match = ImportErrorPattern.search(run_result.stdout).group() |
1951 | | - panel = Panel(Text.from_markup(f"⚠️ {match} ", style="bold red"), expand=False) |
1952 | | - console.print(panel) |
| 1956 | + for error in unique_errors: |
| 1957 | + if is_LSP_enabled(): |
| 1958 | + lsp_log(LspCodeMessage(code=error, file_name="errors")) |
| 1959 | + else: |
| 1960 | + panel = Panel(Text.from_markup(f"⚠️ {error} ", style="bold red"), expand=False) |
| 1961 | + console.print(panel) |
| 1962 | + |
1953 | 1963 | if testing_type in {TestingMode.BEHAVIOR, TestingMode.PERFORMANCE}: |
1954 | 1964 | results, coverage_results = parse_test_results( |
1955 | 1965 | test_xml_path=result_file_path, |
|
0 commit comments