diff --git a/benchmark/test_real_execution.py b/benchmark/test_real_execution.py new file mode 100644 index 0000000000..a1dd024005 --- /dev/null +++ b/benchmark/test_real_execution.py @@ -0,0 +1,143 @@ +#!/usr/bin/env python3 +"""Test real command execution functionality.""" + +import subprocess +import sys +import json +import time +from pathlib import Path + + +def test_real_command_structure(): + """Test that real command structure is working.""" + print("๐Ÿ”ง Testing real command structure...") + + # Test real command group help + result = subprocess.run([ + "swarm-benchmark", "real", "--help" + ], capture_output=True, text=True) + + if result.returncode != 0: + print(f"โŒ Real command group failed: {result.stderr}") + return False + + if "Real claude-flow command execution" not in result.stdout: + print("โŒ Real command group help text missing") + return False + + # Test real swarm subcommand help + result = subprocess.run([ + "swarm-benchmark", "real", "swarm", "--help" + ], capture_output=True, text=True) + + if result.returncode != 0: + print(f"โŒ Real swarm command failed: {result.stderr}") + return False + + if "OBJECTIVE:" not in result.stdout: + print("โŒ Real swarm command help text missing") + return False + + print("โœ… Real command structure working correctly") + return True + + +def test_global_options(): + """Test that global options are working.""" + print("๐ŸŒ Testing global options...") + + # Test with global options + result = subprocess.run([ + "swarm-benchmark", + "--verbose", + "--real", + "--claude-flow-path", "/custom/path", + "--timeout", "10", + "--no-stream", + "list", + "--limit", "1" + ], capture_output=True, text=True) + + if result.returncode != 0: + print(f"โŒ Global options test failed: {result.stderr}") + return False + + print("โœ… Global options working correctly") + return True + + +def test_real_execution_dry_run(): + """Test real execution in dry-run mode.""" + print("๐Ÿงช Testing real execution (mock mode)...") + + try: + # Import and test the CLI directly to avoid actual execution + sys.path.insert(0, str(Path(__file__).parent / "src")) + from swarm_benchmark.cli.main import cli + from click.testing import CliRunner + from unittest.mock import patch + + runner = CliRunner() + + # Mock the real benchmark engine to avoid actual execution + with patch('swarm_benchmark.cli.main._run_real_benchmark') as mock_run: + mock_run.return_value = { + 'summary': 'Mock real execution completed', + 'status': 'success' + } + + result = runner.invoke(cli, [ + 'real', 'swarm', 'Simple test task', + '--strategy', 'auto', + '--max-agents', '1', + '--timeout', '1' + ]) + + if result.exit_code != 0: + print(f"โŒ Real execution test failed: {result.output}") + return False + + if 'Real benchmark completed successfully' not in result.output: + print(f"โŒ Expected success message not found: {result.output}") + return False + + print("โœ… Real execution dry-run working correctly") + return True + + except Exception as e: + print(f"โŒ Real execution test failed with exception: {e}") + return False + + +def main(): + """Main test function.""" + print("๐Ÿš€ Testing Real Command Execution") + print("=" * 50) + + success = True + + # Test 1: Command structure + if not test_real_command_structure(): + success = False + + # Test 2: Global options + if not test_global_options(): + success = False + + # Test 3: Real execution dry-run + if not test_real_execution_dry_run(): + success = False + + print("\n" + "=" * 50) + + if success: + print("๐ŸŽ‰ ALL REAL EXECUTION TESTS PASSED!") + return 0 + else: + print("โŒ SOME REAL EXECUTION TESTS FAILED!") + return 1 + + +if __name__ == "__main__": + exit_code = main() + sys.exit(exit_code) \ No newline at end of file diff --git a/benchmark/tests/.claude/checkpoints/1754448133.json b/benchmark/tests/.claude/checkpoints/1754448133.json new file mode 100644 index 0000000000..92264a2ec6 --- /dev/null +++ b/benchmark/tests/.claude/checkpoints/1754448133.json @@ -0,0 +1 @@ +{"branch": "checkpoint/pre-edit-20250806-024213", "file": "/workspaces/claude-code-flow/benchmark/OPTIMIZATION_WARNING_FIX_REPORT.md", "timestamp": "2025-08-06T02:42:13Z", "type": "pre-edit", "original_branch": "alpha-88"} diff --git a/benchmark/tests/.claude/checkpoints/1754448135.json b/benchmark/tests/.claude/checkpoints/1754448135.json new file mode 100644 index 0000000000..3f3a4129eb --- /dev/null +++ b/benchmark/tests/.claude/checkpoints/1754448135.json @@ -0,0 +1 @@ +{"tag": "checkpoint-20250806-024215", "file": "/workspaces/claude-code-flow/benchmark/OPTIMIZATION_WARNING_FIX_REPORT.md", "timestamp": "2025-08-06T02:42:15Z", "type": "post-edit", "branch": "alpha-88", "diff_summary": " .claude-flow/metrics/system-metrics.json | 180 +++++++++++++++++++++ benchmark/.claude-flow/metrics/performance.json | 2 +- benchmark/.claude-flow/metrics/task-metrics.json | 6 +- benchmark/OPTIMIZATION_WARNING_FIX_REPORT.md | 152 +++++++++++++++++ .../cli/__pycache__/main.cpython-312.pyc | Bin 21009 -> 22009 bytes .../optimized_benchmark_engine.cpython-312.pyc | Bin 15770 -> 15428 bytes .../__pycache__/engine.cpython-312.pyc | Bin 32449 -> 33620 bytes benchmark/test_optimization_fix.py | 167 ------------------- .../tests/.claude-flow/metrics/performance.json | 2 +- .../tests/.claude-flow/metrics/task-metrics.json | 6 +- .../tests/.claude/checkpoints/1754448093.json | 1 + .../tests/.claude/checkpoints/1754448094.json | 1 + claude-flow-wiki | 0 13 files changed, 342 insertions(+), 175 deletions(-) "}