nimpretty: proper command line handling; added tests; travis ensures these stay green
This commit is contained in:
parent
0c33244c23
commit
837d0c7270
8 changed files with 622 additions and 17 deletions
29
nimpretty/tester.nim
Normal file
29
nimpretty/tester.nim
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Small program that runs the test cases
|
||||
|
||||
import strutils, os
|
||||
|
||||
const
|
||||
dir = "nimpretty/tests/"
|
||||
|
||||
var
|
||||
failures = 0
|
||||
|
||||
proc test(infile, outfile: string) =
|
||||
if execShellCmd("nimpretty -o:$2 --backup:off $1" % [infile, outfile]) != 0:
|
||||
quit("FAILURE")
|
||||
let nimFile = splitFile(infile).name
|
||||
let expected = dir / "expected" / nimFile & ".nim"
|
||||
let produced = dir / nimFile & ".pretty"
|
||||
if strip(readFile(expected)) != strip(readFile(produced)):
|
||||
echo "FAILURE: files differ: ", nimFile
|
||||
discard execShellCmd("diff -uNdr " & produced & " " & expected)
|
||||
failures += 1
|
||||
else:
|
||||
echo "SUCCESS: files identical: ", nimFile
|
||||
|
||||
for t in walkFiles(dir / "*.nim"):
|
||||
let res = t.changeFileExt("pretty")
|
||||
test(t, res)
|
||||
removeFile(res)
|
||||
|
||||
if failures > 0: quit($failures & " failures occurred.")
|
||||
Loading…
Add table
Add a link
Reference in a new issue