move earlier to avoid more work
This commit is contained in:
parent
de7bacabd3
commit
92c54b7a6f
1 changed files with 10 additions and 14 deletions
|
|
@ -494,6 +494,16 @@ class FunctionOptimizer:
|
|||
should_run_experiment = self.experiment_id is not None
|
||||
logger.info(f"!lsp|Function Trace ID: {self.function_trace_id}")
|
||||
ph("cli-optimize-function-start", {"function_trace_id": self.function_trace_id})
|
||||
|
||||
# Early check: if --no-gen-tests is set, verify there are existing tests for this function
|
||||
if self.args.no_gen_tests:
|
||||
func_qualname = self.function_to_optimize.qualified_name_with_modules_from_root(self.project_root)
|
||||
if not self.function_to_tests.get(func_qualname):
|
||||
return Failure(
|
||||
f"No existing tests found for '{self.function_to_optimize.function_name}'. "
|
||||
f"Cannot optimize without tests when --no-gen-tests is set."
|
||||
)
|
||||
|
||||
self.cleanup_leftover_test_return_values()
|
||||
file_name_from_test_module_name.cache_clear()
|
||||
ctx_result = self.get_code_optimization_context()
|
||||
|
|
@ -1774,20 +1784,6 @@ class FunctionOptimizer:
|
|||
return Failure(f"/!\\ NO TESTS GENERATED for {self.function_to_optimize.function_name}")
|
||||
|
||||
function_to_concolic_tests, concolic_test_str = future_concolic_tests.result()
|
||||
|
||||
# When --no-gen-tests is set, check if there are any tests available (existing + concolic)
|
||||
if self.args.no_gen_tests:
|
||||
func_qualname = self.function_to_optimize.qualified_name_with_modules_from_root(self.project_root)
|
||||
has_existing_tests = bool(self.function_to_tests.get(func_qualname))
|
||||
if not has_existing_tests:
|
||||
logger.warning(
|
||||
f"No existing tests found for {self.function_to_optimize.function_name} and --no-gen-tests is set"
|
||||
)
|
||||
return Failure(
|
||||
f"No existing tests found for '{self.function_to_optimize.function_name}'. "
|
||||
f"Cannot optimize without tests when --no-gen-tests is set."
|
||||
)
|
||||
|
||||
count_tests = len(tests)
|
||||
if concolic_test_str:
|
||||
count_tests += 1
|
||||
|
|
|
|||
Loading…
Reference in a new issue