Skip to content

Instantly share code, notes, and snippets.

@cgmb
Last active August 29, 2015 14:14
Show Gist options
  • Save cgmb/682eac86dd921f3ce003 to your computer and use it in GitHub Desktop.
Save cgmb/682eac86dd921f3ce003 to your computer and use it in GitHub Desktop.
An end-to-end test implemented in powershell
# call this script like so:
# .\acceptance_test.ps1 -order random -size 1000 -algorithm merge
# call our program
java Assign1 $order $size $algorithm output.txt
# read our output file, convert each line to an integer, then sort, and output to an ascii text file
get-content output.txt | foreach-object { [Int] $_ } | sort-object | out-file -encoding ascii sorted.txt
# unfortunately, compare-object does not care about order, so it can't check the sort
# that is to say, this doesn't work:
# compare-object (get-content output.txt) (get-content sorted.txt)
# instead, use the 'fc' program to compare files like we did in the MS-DOS days
# its output is very noisy, though. Let's hide it and just print pass or fail ourselves.
fc.exe output.txt sorted.txt | out-null
# check the exit code of our last call
if ($?) {
write-host "pass" -foreground "green"
} else {
write-host "fail" -foreground "red"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment