summaryrefslogtreecommitdiff
path: root/run_tests.py
blob: e09886e78ab657672b597019a627dd4962ccf399 (plain)
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
#!/usr/bin/env python3
"""Script para executar todos os testes e validar a instalação."""

import subprocess
import sys


def run_command(cmd, description):
    """Executa um comando e mostra o resultado."""
    print(f"\n{'='*60}")
    print(f"{description}")
    print(f"{'='*60}")
    try:
        result = subprocess.run(
            cmd, shell=True, check=True, capture_output=True, text=True
        )
        print(result.stdout)
        if result.stderr:
            print("STDERR:", result.stderr)
        return True
    except subprocess.CalledProcessError as e:
        print(f"ERRO: {e}")
        print("STDOUT:", e.stdout)
        print("STDERR:", e.stderr)
        return False


def main():
    """Executa todos os testes."""
    print("=== PyVyOS Test Suite ===\n")

    steps = [
        ("uv sync", "1. Sincronizando dependências"),
        ("uv run python test_quick.py", "2. Verificação rápida de imports"),
        ("uv run pytest tests/test_shims.py -v", "3. Testes de shims"),
        ("uv run pytest tests/utils/ -v", "4. Testes de utils"),
        ("uv run pytest tests/test_exceptions.py -v", "5. Testes de exceptions"),
        (
            "uv run pytest tests/modules/test_vy_device.py::test_shim_compatibility -v",
            "6. Teste de compatibilidade",
        ),
        ("uv run pytest tests/ -v --tb=short", "7. TODOS os testes"),
    ]

    results = []
    for cmd, desc in steps:
        success = run_command(cmd, desc)
        results.append((desc, success))
        if not success:
            print(f"\n❌ Falha em: {desc}")
            sys.exit(1)

    print(f"\n{'='*60}")
    print("✅ TODOS OS TESTES PASSARAM!")
    print(f"{'='*60}\n")

    for desc, success in results:
        status = "✅" if success else "❌"
        print(f"{status} {desc}")


if __name__ == "__main__":
    main()