()
| 23 | |
| 24 | |
| 25 | def validate_all(): |
| 26 | base_dir = Path("yaml_instance") |
| 27 | if not base_dir.exists(): |
| 28 | print(f"Directory {base_dir} not found.") |
| 29 | sys.exit(1) |
| 30 | |
| 31 | # Recursive search for all .yaml files |
| 32 | files = sorted(list(base_dir.rglob("*.yaml"))) |
| 33 | |
| 34 | if not files: |
| 35 | print("No YAML files found.") |
| 36 | return |
| 37 | |
| 38 | print( |
| 39 | f"Found {len(files)} YAML files. Running FULL validation via check.check...\n" |
| 40 | ) |
| 41 | |
| 42 | passed = 0 |
| 43 | failed = 0 |
| 44 | failed_files = [] |
| 45 | |
| 46 | for yaml_file in files: |
| 47 | # Use relative path for cleaner output |
| 48 | try: |
| 49 | rel_path = yaml_file.relative_to(Path.cwd()) |
| 50 | except ValueError: |
| 51 | rel_path = yaml_file |
| 52 | |
| 53 | # NOW we run check.check, which we just patched to have a main() |
| 54 | # This performs the stricter load_config() validation |
| 55 | cmd = [sys.executable, "-m", "check.check", "--path", str(yaml_file)] |
| 56 | |
| 57 | try: |
| 58 | result = subprocess.run(cmd, capture_output=True, text=True) |
| 59 | |
| 60 | if result.returncode == 0: |
| 61 | print(f"{rel_path}") |
| 62 | passed += 1 |
| 63 | else: |
| 64 | print(f"{rel_path}") |
| 65 | # Indent error output |
| 66 | if result.stdout: |
| 67 | print(" stdout:", result.stdout.strip().replace("\n", "\n ")) |
| 68 | # Validation errors usually print to stdout/stderr depending on impl |
| 69 | # Our new main prints to stdout for success/failure message |
| 70 | failed += 1 |
| 71 | failed_files.append(str(rel_path)) |
| 72 | except Exception as e: |
| 73 | print(f"{rel_path} (Execution Failed)") |
| 74 | print(f" Error: {e}") |
| 75 | failed += 1 |
| 76 | failed_files.append(str(rel_path)) |
| 77 | |
| 78 | print("\n" + "=" * 40) |
| 79 | print(f"YAML Validation Summary") |
| 80 | print("=" * 40) |
| 81 | print(f"Total Files: {len(files)}") |
| 82 | print(f"Passed: {passed}") |
no test coverage detected