1212import sys
1313import time
1414import datetime
15+ from enum import IntEnum , Enum
1516from pathlib import Path
1617
1718# Make stdout unbuffered to prevent output ordering issues with subprocesses
1819sys .stdout .reconfigure (line_buffering = True )
1920
2021
21- class TestExecutor :
22- """
23- Executes tests and manages build/test workflows
24- """
22+ class ExitCode (IntEnum ):
23+ """Exit codes for processes"""
24+ EXIT_SUCCESS = 0
25+ EXIT_FAILURE = 1
26+ EXIT_TIMEOUT = 124
27+
2528
26- # Test results
29+ class TestResult (str , Enum ):
30+ """Test result statuses"""
2731 RESULT_PASSED = "PASSED"
2832 RESULT_FAILED = "FAILED"
2933 RESULT_TIMEOUT = "TIMEOUT"
3034 RESULT_SKIPPED = "SKIPPED"
3135
36+
37+ class TestExecutor :
38+ """
39+ Executes tests and manages build/test workflows
40+ """
41+
3242 def __init__ (self , config_processor , args ):
3343 """
3444 Initialize TestExecutor
@@ -419,7 +429,7 @@ def run_test(self, test_config, suite_config):
419429 print (f"ERROR: Test binary not found: { test_binary_path } " )
420430 return {
421431 "name" : test_name ,
422- "result" : self .RESULT_FAILED ,
432+ "result" : TestResult .RESULT_FAILED . value ,
423433 "duration" : 0 ,
424434 "error" : f"Binary not found: { test_binary_path } "
425435 }
@@ -556,12 +566,12 @@ def run_test(self, test_config, suite_config):
556566 duration = time .time () - start_time
557567
558568 # Determine result
559- if result .returncode == 0 :
560- test_result = self .RESULT_PASSED
561- elif result .returncode == self .EXIT_TIMEOUT :
562- test_result = self .RESULT_TIMEOUT
569+ if result .returncode == ExitCode . EXIT_SUCCESS :
570+ test_result = TestResult .RESULT_PASSED . value
571+ elif result .returncode == ExitCode .EXIT_TIMEOUT :
572+ test_result = TestResult .RESULT_TIMEOUT . value
563573 else :
564- test_result = self .RESULT_FAILED
574+ test_result = TestResult .RESULT_FAILED . value
565575
566576 if self .args .verbose :
567577 print (f"\n Result: { test_result } ({ duration :.3f} seconds)" )
@@ -576,10 +586,10 @@ def run_test(self, test_config, suite_config):
576586 except subprocess .TimeoutExpired :
577587 duration = time .time () - start_time
578588 if self .args .verbose :
579- print (f"\n Result: { self .RESULT_TIMEOUT } after { timeout } seconds" )
589+ print (f"\n Result: { TestResult .RESULT_TIMEOUT . value } after { timeout } seconds" )
580590 return {
581591 "name" : test_name ,
582- "result" : self .RESULT_TIMEOUT ,
592+ "result" : TestResult .RESULT_TIMEOUT . value ,
583593 "duration" : duration ,
584594 "error" : f"Test timed out after { timeout } seconds"
585595 }
@@ -588,7 +598,7 @@ def run_test(self, test_config, suite_config):
588598 print (f"\n ERROR: { e } " )
589599 return {
590600 "name" : test_name ,
591- "result" : self .RESULT_FAILED ,
601+ "result" : TestResult .RESULT_FAILED . value ,
592602 "duration" : duration ,
593603 "error" : str (e )
594604 }
@@ -636,9 +646,9 @@ def run_test_suite(self, suite_config):
636646 def print_summary (self ):
637647 """Print test execution summary"""
638648 total_tests = len (self .test_results )
639- passed = self .test_results .count (self .RESULT_PASSED )
640- failed = self .test_results .count (self .RESULT_FAILED )
641- timeout = self .test_results .count (self .RESULT_TIMEOUT )
649+ passed = self .test_results .count (TestResult .RESULT_PASSED . value )
650+ failed = self .test_results .count (TestResult .RESULT_FAILED . value )
651+ timeout = self .test_results .count (TestResult .RESULT_TIMEOUT . value )
642652
643653 # Get unique test suites that were run
644654 unique_suites = sorted (set (self .test_suites )) if self .test_suites else []
0 commit comments