diff options
author | Ganesh Viswanathan <dev@genotrance.com> | 2018-09-14 18:34:12 -0500 |
---|---|---|
committer | Ganesh Viswanathan <dev@genotrance.com> | 2018-09-14 18:34:12 -0500 |
commit | 9340885251e7791ee5a03f2b75e168f341e231e5 (patch) | |
tree | 86b4a189f01a1c114f5bb9e48d33e09a731953b0 /nimdoc/tester.nim | |
parent | 4e305c304014c5ef90413d6cab562f5e2b34e573 (diff) | |
parent | b9dc486db15bb1b4b6f3cef7626733b904d377f7 (diff) | |
download | Nim-9340885251e7791ee5a03f2b75e168f341e231e5.tar.gz |
Merge remote-tracking branch 'upstream/devel' into test-7010
Diffstat (limited to 'nimdoc/tester.nim')
-rw-r--r-- | nimdoc/tester.nim | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/nimdoc/tester.nim b/nimdoc/tester.nim new file mode 100644 index 000000000..e0afe6b94 --- /dev/null +++ b/nimdoc/tester.nim @@ -0,0 +1,32 @@ +# 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 --index:on -o:$1/htmldocs $1/testproject.nim" % dir) != 0: + quit("FAILURE: nim doc failed") + + if execShellCmd("nim buildIndex -o:$1/htmldocs/theindex.html $1/htmldocs" % [dir]) != 0: + quit("FAILURE: nim buildIndex failed") + + for expected in walkDirRec(dir / "expected/"): + let produced = expected.replace('\\', '/').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.") |