-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_setup.py
More file actions
82 lines (71 loc) · 2.71 KB
/
Copy pathtest_setup.py
File metadata and controls
82 lines (71 loc) · 2.71 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
#!/usr/bin/env python3
"""
Test script to verify the project setup is working correctly.
"""
import sys
import subprocess
import os
from pathlib import Path
def run_command(cmd, description):
"""Run a command and return the result."""
print(f"🧪 Testing: {description}")
try:
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
if result.returncode == 0:
print(f"✅ {description} - SUCCESS")
return True
else:
print(f"❌ {description} - FAILED")
print(f"Error: {result.stderr}")
return False
except Exception as e:
print(f"❌ {description} - ERROR: {str(e)}")
return False
def main():
"""Main test function."""
print("=" * 60)
print("Human-Text DSL Compiler - Setup Verification")
print("=" * 60)
# Check if we're in the right directory
if not Path("pyproject.toml").exists():
print("❌ ERROR: pyproject.toml not found. Are you in the project root?")
return False
# Check if dsl_compiler package exists
if not Path("dsl_compiler").exists():
print("❌ ERROR: dsl_compiler package not found")
return False
tests = [
("python3 --version", "Python version"),
("which uv", "uv installation"),
("uv --version", "uv version"),
("grep -q '\\[tool\\.uv\\]' pyproject.toml", "uv configuration in pyproject.toml"),
("uv sync --dry-run", "uv sync dry run"),
("curl -I https://pypi.tuna.tsinghua.edu.cn/simple/ | head -1", "Mirror connectivity (Tsinghua)"),
("uv run python -c 'import dsl_compiler; print(\"DSL Compiler import successful\")'", "DSL Compiler import"),
("uv run python -c 'from dsl_compiler import compile, CompilerConfig; print(\"API import successful\")'", "API import"),
("uv run dslc --help", "CLI help"),
]
passed = 0
failed = 0
for cmd, description in tests:
if run_command(cmd, description):
passed += 1
else:
failed += 1
print()
print("=" * 60)
print(f"Test Results: {passed} passed, {failed} failed")
print("=" * 60)
if failed == 0:
print("🎉 All tests passed! The project setup is working correctly.")
print("\nNext steps:")
print("1. Run 'uv sync' to install dependencies")
print("2. Run 'uv run pre-commit install' to set up git hooks")
print("3. Try: 'uv run dslc example/test_input.txt -o output.yaml'")
return True
else:
print(f"⚠️ {failed} test(s) failed. Please check the setup.")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)