@@ -42,43 +42,39 @@ def existing_tests_source_for(
4242 rows = []
4343 headers = ["Test File::Test Function" , "Original ⏱️" , "Optimized ⏱️" , "Speedup" ]
4444 tests_root = test_cfg .tests_root
45- module_root = test_cfg .project_root_path
46- rel_tests_root = tests_root .relative_to (module_root )
4745 original_tests_to_runtimes : dict [Path , dict [str , int ]] = {}
4846 optimized_tests_to_runtimes : dict [Path , dict [str , int ]] = {}
4947 non_generated_tests = set ()
5048 for test_file in test_files :
51- non_generated_tests .add (Path ( test_file .tests_in_file .test_file ). relative_to ( tests_root ) )
49+ non_generated_tests .add (test_file .tests_in_file .test_file )
5250 # TODO confirm that original and optimized have the same keys
5351 all_invocation_ids = original_runtimes_all .keys () | optimized_runtimes_all .keys ()
5452 for invocation_id in all_invocation_ids :
55- rel_path = (
56- Path (invocation_id .test_module_path .replace ("." , os .sep )).with_suffix (".py" ).relative_to (rel_tests_root )
57- )
58- if rel_path not in non_generated_tests :
53+ abs_path = Path (invocation_id .test_module_path .replace ("." , os .sep )).with_suffix (".py" ).resolve ()
54+ if abs_path not in non_generated_tests :
5955 continue
60- if rel_path not in original_tests_to_runtimes :
61- original_tests_to_runtimes [rel_path ] = {}
62- if rel_path not in optimized_tests_to_runtimes :
63- optimized_tests_to_runtimes [rel_path ] = {}
56+ if abs_path not in original_tests_to_runtimes :
57+ original_tests_to_runtimes [abs_path ] = {}
58+ if abs_path not in optimized_tests_to_runtimes :
59+ optimized_tests_to_runtimes [abs_path ] = {}
6460 qualified_name = (
6561 invocation_id .test_class_name + "." + invocation_id .test_function_name # type: ignore[operator]
6662 if invocation_id .test_class_name
6763 else invocation_id .test_function_name
6864 )
69- if qualified_name not in original_tests_to_runtimes [rel_path ]:
70- original_tests_to_runtimes [rel_path ][qualified_name ] = 0 # type: ignore[index]
71- if qualified_name not in optimized_tests_to_runtimes [rel_path ]:
72- optimized_tests_to_runtimes [rel_path ][qualified_name ] = 0 # type: ignore[index]
65+ if qualified_name not in original_tests_to_runtimes [abs_path ]:
66+ original_tests_to_runtimes [abs_path ][qualified_name ] = 0 # type: ignore[index]
67+ if qualified_name not in optimized_tests_to_runtimes [abs_path ]:
68+ optimized_tests_to_runtimes [abs_path ][qualified_name ] = 0 # type: ignore[index]
7369 if invocation_id in original_runtimes_all :
74- original_tests_to_runtimes [rel_path ][qualified_name ] += min (original_runtimes_all [invocation_id ]) # type: ignore[index]
70+ original_tests_to_runtimes [abs_path ][qualified_name ] += min (original_runtimes_all [invocation_id ]) # type: ignore[index]
7571 if invocation_id in optimized_runtimes_all :
76- optimized_tests_to_runtimes [rel_path ][qualified_name ] += min (optimized_runtimes_all [invocation_id ]) # type: ignore[index]
72+ optimized_tests_to_runtimes [abs_path ][qualified_name ] += min (optimized_runtimes_all [invocation_id ]) # type: ignore[index]
7773 # parse into string
78- all_rel_paths = (
74+ all_abs_paths = (
7975 original_tests_to_runtimes .keys ()
8076 ) # both will have the same keys as some default values are assigned in the previous loop
81- for filename in sorted (all_rel_paths ):
77+ for filename in sorted (all_abs_paths ):
8278 all_qualified_names = original_tests_to_runtimes [
8379 filename
8480 ].keys () # both will have the same keys as some default values are assigned in the previous loop
@@ -90,6 +86,7 @@ def existing_tests_source_for(
9086 ):
9187 print_optimized_runtime = format_time (optimized_tests_to_runtimes [filename ][qualified_name ])
9288 print_original_runtime = format_time (original_tests_to_runtimes [filename ][qualified_name ])
89+ print_filename = filename .relative_to (tests_root )
9390 greater = (
9491 optimized_tests_to_runtimes [filename ][qualified_name ]
9592 > original_tests_to_runtimes [filename ][qualified_name ]
@@ -104,7 +101,7 @@ def existing_tests_source_for(
104101 if greater :
105102 rows .append (
106103 [
107- f"`{ filename .as_posix ()} ::{ qualified_name } `" ,
104+ f"`{ print_filename .as_posix ()} ::{ qualified_name } `" ,
108105 f"{ print_original_runtime } " ,
109106 f"{ print_optimized_runtime } " ,
110107 f"⚠️{ perf_gain } %" ,
@@ -113,7 +110,7 @@ def existing_tests_source_for(
113110 else :
114111 rows .append (
115112 [
116- f"`{ filename .as_posix ()} ::{ qualified_name } `" ,
113+ f"`{ print_filename .as_posix ()} ::{ qualified_name } `" ,
117114 f"{ print_original_runtime } " ,
118115 f"{ print_optimized_runtime } " ,
119116 f"✅{ perf_gain } %" ,
0 commit comments