fix: resolve Windows 8.3 short paths in get_run_tmp_file and fix ruff lint errors

Add .resolve() to TemporaryDirectory path to expand Windows 8.3 short
paths (e.g. RUNNER~1) to canonical long form, fixing test_pickle_patcher
failures on Windows CI. Also add missing return type annotations and
noqa suppressions for benchmark test file.
This commit is contained in:
Kevin Turcios 2026-04-10 08:51:10 -05:00
parent ec14860d29
commit 8959ead2f9
2 changed files with 6 additions and 6 deletions

View file

@ -2,7 +2,7 @@ from codeflash.models.models import FunctionTestInvocation, InvocationId, TestRe
from codeflash.verification.parse_test_output import merge_test_results from codeflash.verification.parse_test_output import merge_test_results
def generate_test_invocations(count=100): def generate_test_invocations(count: int = 100) -> tuple[TestResults, TestResults]:
"""Generate a set number of test invocations for benchmarking.""" """Generate a set number of test invocations for benchmarking."""
test_results_xml = TestResults() test_results_xml = TestResults()
test_results_bin = TestResults() test_results_bin = TestResults()
@ -21,7 +21,7 @@ def generate_test_invocations(count=100):
function_getting_tested="sorter", function_getting_tested="sorter",
iteration_id=iteration_id, iteration_id=iteration_id,
), ),
file_name="/tmp/tests/unittest/test_bubble_sort__perfinstrumented.py", file_name="/tmp/tests/unittest/test_bubble_sort__perfinstrumented.py", # noqa: S108
did_pass=True, did_pass=True,
runtime=None if i % 3 == 0 else i * 100, # Vary runtime values runtime=None if i % 3 == 0 else i * 100, # Vary runtime values
test_framework="unittest", test_framework="unittest",
@ -42,7 +42,7 @@ def generate_test_invocations(count=100):
function_getting_tested="sorter", function_getting_tested="sorter",
iteration_id=iteration_id, iteration_id=iteration_id,
), ),
file_name="/tmp/tests/unittest/test_bubble_sort__perfinstrumented.py", file_name="/tmp/tests/unittest/test_bubble_sort__perfinstrumented.py", # noqa: S108
did_pass=True, did_pass=True,
runtime=500 + i * 20, # Generate varying runtime values runtime=500 + i * 20, # Generate varying runtime values
test_framework="unittest", test_framework="unittest",
@ -56,12 +56,12 @@ def generate_test_invocations(count=100):
return test_results_xml, test_results_bin return test_results_xml, test_results_bin
def run_merge_benchmark(count=100): def run_merge_benchmark(count: int = 100) -> None:
test_results_xml, test_results_bin = generate_test_invocations(count) test_results_xml, test_results_bin = generate_test_invocations(count)
# Perform the merge operation that will be benchmarked # Perform the merge operation that will be benchmarked
merge_test_results(xml_test_results=test_results_xml, bin_test_results=test_results_bin, test_framework="unittest") merge_test_results(xml_test_results=test_results_xml, bin_test_results=test_results_bin, test_framework="unittest")
def test_benchmark_merge_test_results(benchmark): def test_benchmark_merge_test_results(benchmark) -> None:
benchmark(run_merge_benchmark, 1000) # Default to 100 test invocations benchmark(run_merge_benchmark, 1000) # Default to 100 test invocations

View file

@ -423,7 +423,7 @@ def get_run_tmp_file(file_path: Path | str) -> Path:
file_path = Path(file_path) file_path = Path(file_path)
if not hasattr(get_run_tmp_file, "tmpdir_path"): if not hasattr(get_run_tmp_file, "tmpdir_path"):
get_run_tmp_file.tmpdir = TemporaryDirectory(prefix="codeflash_") get_run_tmp_file.tmpdir = TemporaryDirectory(prefix="codeflash_")
get_run_tmp_file.tmpdir_path = Path(get_run_tmp_file.tmpdir.name) get_run_tmp_file.tmpdir_path = Path(get_run_tmp_file.tmpdir.name).resolve()
return get_run_tmp_file.tmpdir_path / file_path return get_run_tmp_file.tmpdir_path / file_path