| |
| """ |
| Verification script for Directory Structure Analysis Task |
| """ |
|
|
| import sys |
| from pathlib import Path |
| import os |
|
|
| def get_test_directory() -> Path: |
| """Get the test directory from FILESYSTEM_TEST_DIR env var.""" |
| test_root = os.environ.get("FILESYSTEM_TEST_DIR") |
| if not test_root: |
| raise ValueError("FILESYSTEM_TEST_DIR environment variable is required") |
| return Path(test_root) |
|
|
| def verify_structure_analysis_file_exists(test_dir: Path) -> bool: |
| """Verify that the structure_analysis.txt file exists.""" |
| analysis_file = test_dir / "structure_analysis.txt" |
| |
| if not analysis_file.exists(): |
| print("β File 'structure_analysis.txt' not found") |
| return False |
| |
| print("β
structure_analysis.txt file found") |
| return True |
|
|
| def verify_structure_analysis_content(test_dir: Path) -> bool: |
| """Verify that the structure_analysis.txt file contains the correct count.""" |
| analysis_file = test_dir / "structure_analysis.txt" |
| |
| try: |
| content = analysis_file.read_text().strip() |
| |
| if not content: |
| print("β structure_analysis.txt file is empty") |
| return False |
| |
| |
| expected_count = 1 |
| |
| |
| if content != str(expected_count): |
| print(f"β Expected '{expected_count}', but found: '{content}'") |
| return False |
| |
| print(f"β
Python file count is correct: {content}") |
| return True |
| |
| except Exception as e: |
| print(f"β Error reading structure_analysis.txt file: {e}") |
| return False |
|
|
| def main(): |
| """Main verification function.""" |
| try: |
| test_dir = get_test_directory() |
| print(f"π Verifying Directory Structure Analysis Task in: {test_dir}") |
| print() |
| |
| |
| verification_steps = [ |
| ("Structure Analysis File Exists", verify_structure_analysis_file_exists), |
| ("Python File Count is Correct", verify_structure_analysis_content), |
| ] |
| |
| |
| all_passed = True |
| for step_name, verify_func in verification_steps: |
| print(f"π {step_name}...") |
| if not verify_func(test_dir): |
| all_passed = False |
| print() |
| |
| |
| if all_passed: |
| print("π All verification checks passed!") |
| sys.exit(0) |
| else: |
| print("β Some verification checks failed!") |
| sys.exit(1) |
| |
| except Exception as e: |
| print(f"β Verification failed with error: {e}") |
| sys.exit(1) |
|
|
| if __name__ == "__main__": |
| main() |
|
|