-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate.ps1
More file actions
35 lines (30 loc) · 1.46 KB
/
Copy pathvalidate.ps1
File metadata and controls
35 lines (30 loc) · 1.46 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
param(
[string]$Python = 'C:\Users\Irvin\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe'
)
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
if (-not (Test-Path -LiteralPath $Python)) {
$resolved = Get-Command python -ErrorAction SilentlyContinue
if ($null -eq $resolved) {
throw "Python runtime not found. Pass -Python with a Python 3.10+ executable."
}
$Python = $resolved.Source
}
Push-Location $root
try {
& $Python -m unittest discover -s tests -v
if ($LASTEXITCODE -ne 0) { throw 'Unit tests failed.' }
& $Python -m py_compile gh_log_parser.py tests\test_parser.py
if ($LASTEXITCODE -ne 0) { throw 'Bytecode compilation failed.' }
$actual = & $Python gh_log_parser.py --log-file sample-failed-job.log --job-name 'unit tests'
if ($LASTEXITCODE -ne 0) { throw 'Fixture CLI run failed.' }
$actualJson = ($actual | ConvertFrom-Json | ConvertTo-Json -Compress)
$expectedJson = ((Get-Content sample-output.json -Raw) | ConvertFrom-Json | ConvertTo-Json -Compress)
if ($actualJson -ne $expectedJson) { throw 'Fixture output does not match sample-output.json.' }
Write-Output 'Validation passed: tests, py_compile, and fixture output.'
Get-FileHash -Algorithm SHA256 gh_log_parser.py, README.md, tests\test_parser.py, sample-failed-job.log, sample-output.json |
Select-Object Path, Hash | Format-Table -AutoSize
}
finally {
Pop-Location
}