I'm trying to write a PowerShell script to quickly generate a lot of tests for a C++ program and also verify its output. main.cpp is the program I'm verifying, brute.cpp is a brute solution I know for sure works and gen.cpp generates tests. Here's the code:
g++ -o gen.exe gen.cpp
g++ -o brute.exe brute.cpp
g++ -o main.exe main.cpp
for ($i = 0; ; $i++) {
Write-Output "$i"
Start-Process .\gen.exe -RedirectStandardOutput ".\cmake-build-debug\in.in" -NoNewWindow -Wait
Start-Process .\brute.exe -RedirectStandardInput ".\cmake-build-debug\in.in" -RedirectStandardOutput ".\cmake-build-debug\out1" -NoNewWindow -Wait
Start-Process .\main.exe -RedirectStandardInput ".\cmake-build-debug\in.in" -RedirectStandardOutput ".\cmake-build-debug\out2" -NoNewWindow -Wait
if ((Get-FileHash ".\cmake-build-debug\out1" ).Hash -ne (Get-FileHash ".\cmake-build-debug\out2").Hash) {
Compare-Object (Get-Content ".\cmake-build-debug\out1") (Get-Content ".\cmake-build-debug\out2")
break
}
}
This works but it every test takes around 6 seconds, I would want something around 50 times faster. (the programs themselves take up a matter of miliseconds.)