-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidation_runner.py
More file actions
36 lines (29 loc) · 1.12 KB
/
Copy pathvalidation_runner.py
File metadata and controls
36 lines (29 loc) · 1.12 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
#!/usr/bin/env python3
import json
import sys
from pathlib import Path
from command_runner import run_command
ROOT = Path(__file__).resolve().parent
def main():
config_path = Path(sys.argv[1]) if len(sys.argv) > 1 else ROOT / 'runtime' / 'config.example.json'
cfg = json.loads(config_path.read_text(encoding='utf-8'))
commands = cfg.get('validation_commands', [])
out_dir = ROOT / 'eval'
out_dir.mkdir(parents=True, exist_ok=True)
summary = []
for idx, cmd in enumerate(commands, start=1):
proc = run_command(cmd, ROOT)
path = out_dir / f'validation-{idx}.txt'
path.write_text(f"""$ {cmd}
STDOUT:
{proc['stdout']}
STDERR:
{proc['stderr']}
""", encoding='utf-8')
summary.append({'command': cmd, 'returncode': proc['returncode'], 'output_file': str(path.relative_to(ROOT))})
(out_dir / 'summary.json').write_text(json.dumps(summary, indent=2) + '\n', encoding='utf-8')
failed = [item for item in summary if item['returncode'] != 0]
print(json.dumps({'ok': not failed, 'failed': failed}, indent=2))
sys.exit(1 if failed else 0)
if __name__ == '__main__':
main()