77import sys
88import argparse
99
10- # --- MODIFIED: Import the analyzer function directly! ---
1110from main import analyze_halting
1211
1312# --- Configuration ---
3837# --- Helper Functions for Corpus Creation ---
3938
4039def create_directory (path : Path ):
41- """Creates a directory if it doesn't exist."""
4240 path .mkdir (parents = True , exist_ok = True )
4341
4442def collect_stdlib ():
4543 create_directory (STDLIB_DEST )
4644 stdlib_path = Path (shutil .__file__ ).parent
4745 print (f"Collecting files from stdlib at: { stdlib_path } " )
48- # ... (rest of function is the same as your previous version)
4946 file_count = 0
5047 for root , _ , files in os .walk (stdlib_path ):
5148 for file in files :
@@ -59,11 +56,10 @@ def collect_stdlib():
5956def download_and_unpack_pypi ():
6057 create_directory (PYPI_DEST )
6158 print ("Downloading PyPI packages..." )
62- # ... (rest of function is the same as your previous version)
6359 try :
6460 subprocess .run ([sys .executable , "-m" , "pip" , "download" , "--no-deps" , "--dest" , str (PYPI_DEST ), * PYPI_PACKAGES ], check = True , capture_output = True )
6561 except subprocess .CalledProcessError as e :
66- print (f"pip download failed: { e .stderr } . Skipping." )
62+ print (f"pip download failed: { e .stderr . decode () } . Skipping." )
6763 return
6864 unpacked_dir = PYPI_DEST / "unpacked"
6965 create_directory (unpacked_dir )
@@ -94,7 +90,6 @@ def download_and_unpack_pypi():
9490 shutil .rmtree (unpacked_dir )
9591 print (f"Collected { file_count } PyPI .py files." )
9692
97-
9893def generate_synthetic_non_halting ():
9994 create_directory (SYNTHETIC_DEST )
10095 for i in range (NUM_SYNTHETIC ):
@@ -123,8 +118,6 @@ def setup_complex():
123118
124119def run_benchmark (force_rebuild = False ):
125120 """Builds the corpus if needed, then runs the analyzer and calculates the score."""
126-
127- # --- Phase 1: Build the corpus (with caching) ---
128121 if force_rebuild and BENCHMARK_DIR .exists ():
129122 print ("--- Force-rebuilding corpus: Deleting existing suite... ---" )
130123 shutil .rmtree (BENCHMARK_DIR )
@@ -141,7 +134,6 @@ def run_benchmark(force_rebuild=False):
141134 print ("--- Phase 1: Found existing benchmark suite. Skipping build. ---" )
142135 print ("(Use --rebuild flag to force a fresh build)" )
143136
144- # --- Phase 2: Run analysis and calculate score ---
145137 print ("\n --- Phase 2: Running Analyzer & Calculating Score ---" )
146138 total_files = 0
147139 correct_predictions = 0
@@ -167,7 +159,7 @@ def run_benchmark(force_rebuild=False):
167159
168160 try :
169161 program_code = file_path .read_text (encoding = 'utf-8' , errors = 'ignore' )
170- analyzer_result = analyze_halting (program_code )
162+ analyzer_result , _ = analyze_halting (program_code ) # Unpack and ignore reason
171163
172164 is_correct = False
173165 if name == "halting" :
@@ -185,22 +177,19 @@ def run_benchmark(force_rebuild=False):
185177
186178 except Exception :
187179 print (" " * len (progress ), end = '\r ' )
188- # Silently fail on individual analysis errors, but count as incorrect
189180 pass
190181
191182 print (" " * 80 , end = '\r ' )
192183
193184 sys .stderr .close ()
194185 sys .stderr = original_stderr
195186
196- # --- Final Score ---
197187 if total_files > 0 :
198188 percentage = (correct_predictions / total_files ) * 100
199189 print (f"\n --- Practical Success Rate: { percentage :.2f} % ({ correct_predictions } of { total_files } files passed) ---" )
200190 else :
201191 print ("\n No files were found in the benchmark suite to analyze." )
202192
203-
204193if __name__ == "__main__" :
205194 parser = argparse .ArgumentParser (description = "Run the Halting Analyzer benchmark." )
206195 parser .add_argument (
0 commit comments