-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_bridges.py
More file actions
116 lines (101 loc) · 3.79 KB
/
Copy pathrun_bridges.py
File metadata and controls
116 lines (101 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# SPDX-License-Identifier: MIT
# Copyright (c) 2026 PiQrypt Inc.
# e-Soleau: DSO2026006483 (19/02/2026) -- DSO2026009143 (12/03/2026)
"""
run_bridges.py - Lance tous les tests bridges depuis piqrypt/
Usage: python run_bridges.py
"""
import subprocess
import sys
import os
from pathlib import Path
ROOT = Path(__file__).resolve().parent
BRIDGES = ROOT / "bridges"
GREEN = "\033[92m"
RED = "\033[91m"
YELLOW = "\033[93m"
CYAN = "\033[96m"
BOLD = "\033[1m"
RESET = "\033[0m"
# Bridges a tester avec leur module principal
BRIDGE_TESTS = [
("langchain", "test_piqrypt_langchain.py"),
("crewai", "test_piqrypt_crewai.py"),
("autogen", "test_piqrypt_autogen.py"),
("openclaw", "test_piqrypt_openclaw.py"),
("session", "test_piqrypt_session.py"),
("mcp", "test_piqrypt_mcp.py"),
("ollama", "test_piqrypt_ollama.py"),
("ros", "test_piqrypt_ros.py"),
("rpi", "test_piqrypt_rpi.py"),
("hermes", "test_piqrypt_hermes.py"),
]
results = {}
print(f"\n{BOLD}{CYAN}PiQrypt v1.7.1 - Bridge Tests{RESET}")
print("=" * 60)
for bridge_name, test_file in BRIDGE_TESTS:
bridge_dir = BRIDGES / bridge_name
test_path = bridge_dir / test_file
if not test_path.exists():
print(f" {YELLOW}SKIP{RESET} {bridge_name} - test file not found")
results[bridge_name] = "SKIP"
continue
# Environnement : injecter le dossier du bridge dans PYTHONPATH
env = os.environ.copy()
env["PYTHONPATH"] = (
str(bridge_dir) + os.pathsep + str(ROOT) + os.pathsep + env.get("PYTHONPATH", "")
)
env["PIQRYPT_SCRYPT_N"] = "16384"
proc = subprocess.run(
[sys.executable, "-m", "pytest", str(test_path), "-v", "--tb=short", "-q"],
capture_output=True,
text=True,
cwd=str(bridge_dir), # Executer DEPUIS le dossier du bridge
env=env,
)
# Parser le resultat
output = proc.stdout + proc.stderr
passed = 0
failed = 0
for line in output.splitlines():
if "passed" in line and ("failed" in line or "passed" in line):
import re
m = re.search(r"(\d+) passed", line)
if m:
passed = int(m.group(1))
m = re.search(r"(\d+) failed", line)
if m:
failed = int(m.group(1))
if "error" in line.lower() and "importerror" in line.lower():
pass
if proc.returncode == 0:
print(f" {GREEN}PASS{RESET} {bridge_name:<12} {passed} tests passed")
results[bridge_name] = f"PASS ({passed})"
elif "ImportError" in output or "ModuleNotFoundError" in output:
# Extraire l'erreur
for line in output.splitlines():
if "ImportError" in line or "ModuleNotFoundError" in line:
err = line.strip()[:60]
break
else:
err = "import error"
print(f" {YELLOW}SKIP{RESET} {bridge_name:<12} {err}")
results[bridge_name] = "SKIP (infra)"
else:
print(f" {RED}FAIL{RESET} {bridge_name:<12} {passed} passed, {failed} failed")
# Afficher les failures
for line in output.splitlines():
if "FAILED" in line:
print(f" {line.strip()}")
results[bridge_name] = f"FAIL ({failed})"
print("\n" + "=" * 60)
print(f"{BOLD}BILAN BRIDGES{RESET}")
print("=" * 60)
total_pass = sum(1 for v in results.values() if v.startswith("PASS"))
total_skip = sum(1 for v in results.values() if v.startswith("SKIP"))
total_fail = sum(1 for v in results.values() if v.startswith("FAIL"))
for bridge, status in results.items():
color = GREEN if status.startswith("PASS") else (YELLOW if status.startswith("SKIP") else RED)
print(f" {color}{status:<20}{RESET} {bridge}")
print(f"\n PASS: {total_pass} SKIP: {total_skip} FAIL: {total_fail}")
print()