testing scripts

This commit is contained in:
2026-01-29 14:57:02 +01:00
parent 802e5e34aa
commit 794d05f3d9
2 changed files with 23 additions and 0 deletions

3
test.nu Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env nu
cmake --build build
ls testing/tests -s | get name | each {./util.nu $in} | to text

20
util.nu Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env nu
# Usage: ./util.nu 0-go.txt
def main [testfile: string] {
let test_path = $"testing/tests/($testfile)"
let expected_path = $"testing/expected/($testfile)"
let exec = "./build/ps1"
# Run program and capture output
let actual = (open $test_path | ^$exec | str trim)
let expected = (open $expected_path | str trim)
# Compare outputs
if $actual == $expected {
print $"($testfile) passed"
} else {
print $"($testfile) failed"
}
}