MCPcopy
hub / github.com/tanelpoder/0xtools / run

Method run

xtop/tests/test_runner.py:52–116  ·  view source on GitHub ↗

Run all tests in the suite

(self, verbose: bool = False)

Source from the content-addressed store, hash-verified

50 self.test_cases.append(test)
51
52 def run(self, verbose: bool = False) -> bool:
53 """Run all tests in the suite"""
54 print(f"\n{BOLD}Running {self.name}{RESET}")
55 print("-" * 60)
56
57 start_time = time.time()
58 self.passed = 0
59 self.failed = 0
60
61 for test in self.test_cases:
62 test_start = time.time()
63
64 if verbose:
65 print(f" {test.name}: ", end="", flush=True)
66
67 try:
68 result = subprocess.run(
69 test.command,
70 shell=True,
71 capture_output=True,
72 text=True,
73 timeout=30,
74 cwd=Path(__file__).parent
75 )
76
77 test.output = result.stdout
78 test.error = result.stderr
79 test.passed = result.returncode == 0
80
81 # Check for specific error patterns that indicate failure
82 if "ERROR:" in test.output or "ERROR:" in test.error:
83 if "No files found" not in test.error: # Ignore missing file errors in test data
84 test.passed = False
85
86 except subprocess.TimeoutExpired:
87 test.passed = False
88 test.error = "Test timed out after 30 seconds"
89 except Exception as e:
90 test.passed = False
91 test.error = str(e)
92
93 test.duration = time.time() - test_start
94
95 if test.passed:
96 self.passed += 1
97 if verbose:
98 print(f"{GREEN}✓{RESET} ({test.duration:.2f}s)")
99 else:
100 self.failed += 1
101 if verbose:
102 print(f"{RED}✗{RESET} ({test.duration:.2f}s)")
103 if test.error:
104 print(f" Error: {test.error[:200]}")
105
106 self.duration = time.time() - start_time
107
108 # Summary for this suite
109 print(f"\n Results: {GREEN}{self.passed} passed{RESET}, ", end="")

Calls

no outgoing calls

Tested by

no test coverage detected