added a test for 'nim doc'
This commit is contained in:
parent
86556ebfdb
commit
b017138c32
10 changed files with 2696 additions and 7 deletions
29
nimdoc/tester.nim
Normal file
29
nimdoc/tester.nim
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Small program that runs the test cases for 'nim doc'.
|
||||
|
||||
import strutils, os
|
||||
|
||||
var
|
||||
failures = 0
|
||||
|
||||
proc test(dir: string; fixup = false) =
|
||||
putEnv("SOURCE_DATE_EPOCH", "100000")
|
||||
if execShellCmd("nim doc --project -o:$1/htmldocs $1/testproject.nim" % dir) != 0:
|
||||
quit("FAILURE: nim doc failed")
|
||||
|
||||
for expected in walkDirRec(dir / "expected/"):
|
||||
let produced = expected.replace("/expected/", "/htmldocs/")
|
||||
if not fileExists(produced):
|
||||
echo "FAILURE: files not found: ", produced
|
||||
inc failures
|
||||
elif readFile(expected) != readFile(produced):
|
||||
echo "FAILURE: files differ: ", produced
|
||||
discard execShellCmd("diff -uNdr " & expected & " " & produced)
|
||||
inc failures
|
||||
if fixup:
|
||||
copyFile(produced, expected)
|
||||
else:
|
||||
echo "SUCCESS: files identical: ", produced
|
||||
removeDir(dir / "htmldocs")
|
||||
|
||||
test("nimdoc/testproject", false)
|
||||
if failures > 0: quit($failures & " failures occurred.")
|
||||
Loading…
Add table
Add a link
Reference in a new issue