1515from rich .table import Table
1616
1717from bugster .analytics import track_command
18- from bugster .clients .http_client import BugsterHTTPClient
1918from bugster .clients .mcp_client import MCPStdioClient
2019from bugster .clients .ws_client import WebSocketClient
2120from bugster .commands .middleware import require_api_key
2423from bugster .libs .services .run_limits_service import (
2524 apply_test_limit ,
2625 count_total_tests ,
27- get_test_limit_from_config ,
26+ get_test_limit_from_config ,
2827)
2928from bugster .libs .services .update_service import DetectAffectedSpecsService
3029from bugster .types import (
3938from bugster .utils .console_messages import RunMessages
4039from bugster .utils .file import (
4140 check_and_update_project_commands ,
42- get_mcp_config_path ,
43- load_always_run_tests ,
44- load_config ,
45- load_test_files ,
46- merge_always_run_with_affected_tests ,
41+ get_mcp_config_path ,
42+ load_config ,
43+ load_test_files ,
44+ load_always_run_tests ,
45+ merge_always_run_with_affected_tests
4746)
4847from bugster .utils .user_config import get_api_key
49-
48+ from bugster .clients .http_client import BugsterHTTPClient
49+
5050console = Console ()
5151# Color palette for parallel test execution
5252TEST_COLORS = [
@@ -715,24 +715,18 @@ async def test_command(
715715 try :
716716 affected_tests = DetectAffectedSpecsService ().run ()
717717 # Merge affected tests with always-run tests
718- test_files = merge_always_run_with_affected_tests (
719- affected_tests , always_run_tests
720- )
718+ test_files = merge_always_run_with_affected_tests (affected_tests , always_run_tests )
721719 except Exception as e :
722720 RunMessages .error (
723721 f"Failed to detect affected specs: { e } . \n Running all tests..."
724722 )
725723 test_files = load_test_files (path )
726724 # Still merge with always-run tests
727- test_files = merge_always_run_with_affected_tests (
728- test_files , always_run_tests
729- )
725+ test_files = merge_always_run_with_affected_tests (test_files , always_run_tests )
730726 else :
731727 test_files = load_test_files (path )
732728 # Merge all tests with always-run tests
733- test_files = merge_always_run_with_affected_tests (
734- test_files , always_run_tests
735- )
729+ test_files = merge_always_run_with_affected_tests (test_files , always_run_tests )
736730
737731 if not test_files :
738732 RunMessages .no_tests_found ()
@@ -741,50 +735,42 @@ async def test_command(
741735 # Separate always-run tests from regular tests
742736 regular_tests = [tf for tf in test_files if not tf .get ("always_run" , False )]
743737 always_run_tests_list = [tf for tf in test_files if tf .get ("always_run" , False )]
744-
738+
745739 # Apply limit only to regular tests (not always-run)
746740 original_count = count_total_tests (regular_tests )
747- limited_regular_tests , folder_distribution = apply_test_limit (
748- regular_tests , max_tests
749- )
741+ limited_regular_tests , folder_distribution = apply_test_limit (regular_tests , max_tests )
750742 selected_count = count_total_tests (limited_regular_tests )
751-
743+
752744 # Combine limited regular tests with always-run tests
753745 final_test_files = always_run_tests_list + limited_regular_tests
754746 total_final_count = count_total_tests (final_test_files )
755-
747+
756748 # Print test limit information if limiting was applied
757749 if int (original_count ) > int (max_tests ):
758750 always_run_count = count_total_tests (always_run_tests_list )
759-
751+
760752 # Calculate folder distribution for always-run tests
761753 always_run_distribution = {}
762754 for test_file in always_run_tests_list :
763755 folder = test_file ["file" ].parent .name
764- always_run_distribution [folder ] = always_run_distribution .get (
765- folder , 0
766- ) + len (test_file ["content" ])
767-
756+ always_run_distribution [folder ] = always_run_distribution .get (folder , 0 ) + len (test_file ["content" ])
757+
768758 console .print (
769759 RunMessages .create_test_limit_panel (
770760 original_count = original_count ,
771761 selected_count = selected_count ,
772762 max_tests = max_tests ,
773763 folder_distribution = folder_distribution ,
774764 always_run_count = always_run_count ,
775- always_run_distribution = always_run_distribution ,
765+ always_run_distribution = always_run_distribution
776766 )
777767 )
778-
768+
779769 # Show always-run information
780770 if always_run_tests_list :
781771 always_run_count = count_total_tests (always_run_tests_list )
782- console .print (
783- f"[dim]Always-run tests: { always_run_count } (additional to limit)[/dim]"
784- )
785- console .print (
786- f"[dim]Total tests to run: { total_final_count } (regular: { selected_count } + always-run: { always_run_count } )[/dim]"
787- )
772+ console .print (f"[dim]Always-run tests: { always_run_count } (additional to limit)[/dim]" )
773+ console .print (f"[dim]Total tests to run: { total_final_count } (regular: { selected_count } + always-run: { always_run_count } )[/dim]" )
788774
789775 # Use the final combined test files for execution
790776 test_files = final_test_files
0 commit comments