1+ #!/usr/bin/env python3
2+ """
3+ Test script for documentation generation
4+ Verifies that Doxygen can generate documentation correctly.
5+ """
6+
7+ import os
8+ import subprocess
9+ import sys
10+ from pathlib import Path
11+
12+ def test_doxygen_generation ():
13+ """Test if Doxygen can generate documentation successfully."""
14+ print ("Testing Doxygen documentation generation..." )
15+
16+ # Check if Doxygen is available
17+ try :
18+ result = subprocess .run (['doxygen' , '--version' ],
19+ capture_output = True , text = True , check = True )
20+ print (f"✅ Doxygen version: { result .stdout .strip ()} " )
21+ except (subprocess .CalledProcessError , FileNotFoundError ):
22+ print ("❌ Doxygen not found. Please install Doxygen." )
23+ return False
24+
25+ # Check if Doxyfile exists
26+ doxyfile = Path ("Doxyfile" )
27+ if not doxyfile .exists ():
28+ print ("❌ Doxyfile not found" )
29+ return False
30+
31+ print ("✅ Doxyfile found" )
32+
33+ # Generate documentation
34+ try :
35+ print ("Generating documentation..." )
36+ result = subprocess .run (['doxygen' , 'Doxyfile' ],
37+ capture_output = True , text = True , check = True )
38+ print ("✅ Documentation generation completed successfully" )
39+
40+ # Check if output directory was created
41+ output_dir = Path ("docs/html" )
42+ if output_dir .exists ():
43+ print (f"✅ Output directory created: { output_dir } " )
44+
45+ # Check for key files
46+ index_file = output_dir / "index.html"
47+ if index_file .exists ():
48+ print ("✅ index.html generated" )
49+ else :
50+ print ("⚠️ index.html not found" )
51+
52+ # List some files
53+ files = list (output_dir .glob ("*.html" ))
54+ print (f"✅ Generated { len (files )} HTML files" )
55+
56+ else :
57+ print ("❌ Output directory not created" )
58+ return False
59+
60+ except subprocess .CalledProcessError as e :
61+ print (f"❌ Documentation generation failed:" )
62+ print (f"stdout: { e .stdout } " )
63+ print (f"stderr: { e .stderr } " )
64+ return False
65+
66+ return True
67+
68+ def test_benchmark_scripts ():
69+ """Test if benchmark scripts can be imported."""
70+ print ("\n Testing benchmark scripts..." )
71+
72+ try :
73+ # Test import of benchmark scripts
74+ sys .path .insert (0 , 'scripts' )
75+
76+ import run_benchmarks
77+ print ("✅ run_benchmarks.py imports successfully" )
78+
79+ import compare_benchmarks
80+ print ("✅ compare_benchmarks.py imports successfully" )
81+
82+ except ImportError as e :
83+ print (f"❌ Failed to import benchmark scripts: { e } " )
84+ return False
85+
86+ return True
87+
88+ def main ():
89+ """Run all documentation tests."""
90+ print ("🧪 Running documentation tests...\n " )
91+
92+ success = True
93+
94+ # Test Doxygen generation
95+ if not test_doxygen_generation ():
96+ success = False
97+
98+ # Test benchmark scripts
99+ if not test_benchmark_scripts ():
100+ success = False
101+
102+ print ("\n " + "=" * 50 )
103+ if success :
104+ print ("✅ All documentation tests passed!" )
105+ print ("The CI workflow should work correctly." )
106+ else :
107+ print ("❌ Some documentation tests failed." )
108+ print ("Please fix the issues before pushing to CI." )
109+
110+ return 0 if success else 1
111+
112+ if __name__ == '__main__' :
113+ sys .exit (main ())
0 commit comments