| 
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,  | 
@@ -1583,11 +1583,14 @@ def establish_original_code_baseline(  | 
1583 | 1583 |                 )  | 
1584 | 1584 |         if not behavioral_results:  | 
1585 | 1585 |             logger.warning(  | 
1586 |  | -                f"force_lsp|Couldn't run any tests for original function {self.function_to_optimize.function_name}. SKIPPING OPTIMIZING THIS FUNCTION."  | 
 | 1586 | +                f"force_lsp|Couldn't run any tests for original function {self.function_to_optimize.function_name}. Skipping optimization."  | 
1587 | 1587 |             )  | 
1588 | 1588 |             console.rule()  | 
1589 | 1589 |             return Failure("Failed to establish a baseline for the original code - bevhavioral tests failed.")  | 
1590 | 1590 |         if not coverage_critic(coverage_results, self.args.test_framework):  | 
 | 1591 | +            did_pass_all_tests = all(result.did_pass for result in behavioral_results)  | 
 | 1592 | +            if not did_pass_all_tests:  | 
 | 1593 | +                return Failure("Tests failed to pass for the original code.")  | 
1591 | 1594 |             return Failure(  | 
1592 | 1595 |                 f"Test coverage is {coverage_results.coverage}%, which is below the required threshold of {COVERAGE_THRESHOLD}%."  | 
1593 | 1596 |             )  | 
@@ -1951,12 +1954,19 @@ def run_and_parse_tests(  | 
1951 | 1954 |                 f"stdout: {run_result.stdout}\n"  | 
1952 | 1955 |                 f"stderr: {run_result.stderr}\n"  | 
1953 | 1956 |             )  | 
1954 |  | -            if "ModuleNotFoundError" in run_result.stdout:  | 
 | 1957 | + | 
 | 1958 | +            unique_errors = extract_unique_errors(run_result.stdout)  | 
 | 1959 | + | 
 | 1960 | +            if unique_errors:  | 
1955 | 1961 |                 from rich.text import Text  | 
1956 | 1962 | 
 
  | 
1957 |  | -                match = ImportErrorPattern.search(run_result.stdout).group()  | 
1958 |  | -                panel = Panel(Text.from_markup(f"⚠️  {match} ", style="bold red"), expand=False)  | 
1959 |  | -                console.print(panel)  | 
 | 1963 | +                for error in unique_errors:  | 
 | 1964 | +                    if is_LSP_enabled():  | 
 | 1965 | +                        lsp_log(LspCodeMessage(code=error, file_name="errors"))  | 
 | 1966 | +                    else:  | 
 | 1967 | +                        panel = Panel(Text.from_markup(f"⚠️  {error} ", style="bold red"), expand=False)  | 
 | 1968 | +                        console.print(panel)  | 
 | 1969 | + | 
1960 | 1970 |         if testing_type in {TestingMode.BEHAVIOR, TestingMode.PERFORMANCE}:  | 
1961 | 1971 |             results, coverage_results = parse_test_results(  | 
1962 | 1972 |                 test_xml_path=result_file_path,  | 
 | 
0 commit comments