66from typing import Dict , Tuple , List
77
88
9- def find_ops_directory (start_dir = None ):
9+ def find_ops_directory (location = None ):
1010 """
11- Find the ops directory by searching from start_dir upwards.
11+ Find the ops directory by searching from location upwards.
1212
1313 Args:
14- start_dir : Starting directory for search (default: current file's parent)
14+ location : Starting directory for search (default: current file's parent)
1515
1616 Returns:
1717 Path: Path to ops directory or None if not found
1818 """
19- if start_dir is None :
20- start_dir = Path (__file__ ).parent
21-
22- # Look for ops directory in common locations
23- possible_locations = [
24- start_dir / "ops" ,
25- start_dir / ".." / "ops" ,
26- start_dir / ".." / "test" / "ops" ,
27- start_dir / "test" / "ops" ,
28- ]
29-
30- for location in possible_locations :
31- ops_dir = location .resolve ()
32- if ops_dir .exists () and any (ops_dir .glob ("*.py" )):
33- return ops_dir
19+ if location is None :
20+ location = Path (__file__ ).parent / "ops"
21+
22+ ops_dir = location .resolve ()
23+ if ops_dir .exists () and any (ops_dir .glob ("*.py" )):
24+ return ops_dir
3425
3526 return None
3627
@@ -116,7 +107,7 @@ def run_all_op_tests(ops_dir=None, specific_ops=None, extra_args=None):
116107 filtered_files = []
117108 for test_file in operator_test_files :
118109 test_name = test_file .stem .lower ()
119- if any (op .lower () in test_name for op in specific_ops ):
110+ if any (op .lower () == test_name for op in specific_ops ):
120111 filtered_files .append (test_file )
121112 operator_test_files = filtered_files
122113
@@ -135,16 +126,15 @@ def run_all_op_tests(ops_dir=None, specific_ops=None, extra_args=None):
135126 test_name = test_file .stem
136127
137128 try :
138- # Run the test script
139- cmd = [sys .executable , str (test_file )]
129+ # Run the test script - use the absolute path and run from current directory
130+ cmd = [sys .executable , str (test_file . absolute () )]
140131
141132 # Add extra arguments if provided
142133 if extra_args :
143134 cmd .extend (extra_args )
144135
145136 result = subprocess .run (
146137 cmd ,
147- cwd = ops_dir ,
148138 capture_output = True , # Capture output to analyze
149139 text = True ,
150140 )
@@ -154,22 +144,23 @@ def run_all_op_tests(ops_dir=None, specific_ops=None, extra_args=None):
154144 stderr_lower = result .stderr .lower ()
155145
156146 # Check for operator not implemented patterns
157- if "not implemented" in stdout_lower or "not implemented" in stderr_lower :
158- if "both operators not implemented" in stdout_lower :
159- # Both operators not implemented - skipped test
160- success = True # Not a failure, but skipped
161- returncode = - 2 # Special code for skipped
162- elif "one operator not implemented" in stdout_lower :
163- # One operator not implemented - partial test
164- success = False # Not fully successful
165- returncode = - 3 # Special code for partial
166- else :
167- # General not implemented case
168- success = result .returncode == 0
169- returncode = result .returncode
147+ if (
148+ "all tests passed!" in stdout_lower
149+ and "success rate: 100.0%" in stdout_lower
150+ ):
151+ success = True
152+ returncode = 0
153+ elif "both operators not implemented" in stdout_lower :
154+ # Both operators not implemented - skipped test
155+ success = False # Not a failure, but skipped
156+ returncode = - 2 # Special code for skipped
157+ elif "one operator not implemented" in stdout_lower :
158+ # One operator not implemented - partial test
159+ success = False # Not fully successful
160+ returncode = - 3 # Special code for partial
170161 else :
171- success = result . returncode == 0
172- returncode = result . returncode
162+ success = False
163+ returncode = - 1
173164
174165 results [test_name ] = (
175166 success ,
@@ -193,10 +184,10 @@ def run_all_op_tests(ops_dir=None, specific_ops=None, extra_args=None):
193184 # Enhanced status display
194185 if returncode == - 2 :
195186 status_icon = "⏭️"
196- status_text = "SKIPPED (operators not implemented) "
187+ status_text = "SKIPPED"
197188 elif returncode == - 3 :
198189 status_icon = "⚠️"
199- status_text = "PARTIAL (one operator not implemented) "
190+ status_text = "PARTIAL"
200191 elif success :
201192 status_icon = "✅"
202193 status_text = "PASSED"
@@ -205,7 +196,7 @@ def run_all_op_tests(ops_dir=None, specific_ops=None, extra_args=None):
205196 status_text = "FAILED"
206197
207198 print (
208- f"{ status_icon } { test_name } : { status_text } (return code: { returncode } )"
199+ f"{ status_icon } { test_name } : { status_text } (return code: { returncode } )"
209200 )
210201
211202 except Exception as e :
@@ -218,7 +209,7 @@ def run_all_op_tests(ops_dir=None, specific_ops=None, extra_args=None):
218209def print_summary (results ):
219210 """Print a comprehensive summary of test results."""
220211 print (f"\n { '=' * 80 } " )
221- print ("TEST SUMMARY" )
212+ print ("CUMULATIVE TEST SUMMARY" )
222213 print (f"{ '=' * 80 } " )
223214
224215 if not results :
@@ -230,16 +221,24 @@ def print_summary(results):
230221 failed = 0
231222 skipped = 0
232223 partial = 0
224+ passed_operators = [] # Store passed operator names
225+ failed_operators = [] # Store failed operator names
226+ skipped_operators = [] # Store skipped operator names
227+ partial_operators = [] # Store partial operator names
233228
234229 for test_name , (success , returncode , stdout , stderr ) in results .items ():
235230 if success :
236231 passed += 1
232+ passed_operators .append (test_name )
237233 elif returncode == - 2 : # Special code for skipped tests
238234 skipped += 1
235+ skipped_operators .append (test_name )
239236 elif returncode == - 3 : # Special code for partial tests
240237 partial += 1
238+ partial_operators .append (test_name )
241239 else :
242240 failed += 1
241+ failed_operators .append (test_name )
243242
244243 total = len (results )
245244
@@ -248,31 +247,59 @@ def print_summary(results):
248247 print (f"Failed: { failed } " )
249248
250249 if skipped > 0 :
251- print (f"Skipped (operators not implemented) : { skipped } " )
250+ print (f"Skipped: { skipped } " )
252251
253252 if partial > 0 :
254- print (f"Partial (one operator not implemented): { partial } " )
253+ print (f"Partial: { partial } " )
254+
255+ # Display passed operators
256+ if passed_operators :
257+ print (f"\n ✅ PASSED OPERATORS ({ len (passed_operators )} ):" )
258+ # Display operators in groups of 10 per line
259+ for i in range (0 , len (passed_operators ), 10 ):
260+ line_ops = passed_operators [i : i + 10 ]
261+ print (" " + ", " .join (line_ops ))
262+ else :
263+ print (f"\n ✅ PASSED OPERATORS: None" )
264+
265+ # Display failed operators (if any)
266+ if failed_operators :
267+ print (f"\n ❌ FAILED OPERATORS ({ len (failed_operators )} ):" )
268+ for i in range (0 , len (failed_operators ), 10 ):
269+ line_ops = failed_operators [i : i + 10 ]
270+ print (" " + ", " .join (line_ops ))
271+
272+ # Display skipped operators (if any)
273+ if skipped_operators :
274+ print (f"\n ⏭️ SKIPPED OPERATORS ({ len (skipped_operators )} ):" )
275+ for i in range (0 , len (skipped_operators ), 10 ):
276+ line_ops = skipped_operators [i : i + 10 ]
277+ print (" " + ", " .join (line_ops ))
278+
279+ # Display partial operators (if any)
280+ if partial_operators :
281+ print (f"\n ⚠️ PARTIAL OPERATORS ({ len (partial_operators )} ):" )
282+ for i in range (0 , len (partial_operators ), 10 ):
283+ line_ops = partial_operators [i : i + 10 ]
284+ print (" " + ", " .join (line_ops ))
255285
256286 if total > 0 :
257287 # Calculate success rate based on executed tests only
258288 executed_tests = passed + failed + partial
259289 if executed_tests > 0 :
260290 success_rate = passed / executed_tests * 100
261- print (f"Success rate: { success_rate :.1f} %" )
291+ print (f"\n Success rate: { success_rate :.1f} %" )
262292
263293 if failed == 0 :
264294 if skipped > 0 or partial > 0 :
265- print (f"\n ⚠️ Tests completed with some operators not implemented" )
295+ print (f"\n ⚠️ Tests completed with some operators not implemented" )
266296 print (f" - { skipped } tests skipped (both operators not implemented)" )
267297 print (f" - { partial } tests partial (one operator not implemented)" )
268298 else :
269299 print (f"\n 🎉 All tests passed!" )
270300 return True
271301 else :
272- print (f"\n ❌ { failed } tests failed:" )
273- for test_name , (success , returncode , stdout , stderr ) in results .items ():
274- if not success and returncode not in [- 2 , - 3 ]: # Not skipped or partial
275- print (f" - { test_name } (return code: { returncode } )" )
302+ print (f"\n ❌ { failed } tests failed" )
276303 return False
277304
278305
@@ -465,7 +492,7 @@ def main():
465492 )
466493
467494 if all_passed and has_missing_implementations :
468- print (f"\n ⚠️ Note: Some operators are not fully implemented" )
495+ print (f"\n ⚠️ Note: Some operators are not fully implemented" )
469496 print (f" Run individual tests for details on missing implementations" )
470497
471498 sys .exit (0 if all_passed else 1 )
0 commit comments