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.")
|
||||
1299
nimdoc/testproject/expected/subdir/subdir_b/utils.html
Normal file
1299
nimdoc/testproject/expected/subdir/subdir_b/utils.html
Normal file
File diff suppressed because it is too large
Load diff
1331
nimdoc/testproject/expected/testproject.html
Normal file
1331
nimdoc/testproject/expected/testproject.html
Normal file
File diff suppressed because it is too large
Load diff
7
nimdoc/testproject/subdir/subdir_b/utils.nim
Normal file
7
nimdoc/testproject/subdir/subdir_b/utils.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
type
|
||||
SomeType* = int
|
||||
|
||||
proc someType*(): SomeType =
|
||||
## constructor.
|
||||
SomeType(2)
|
||||
21
nimdoc/testproject/testproject.nim
Normal file
21
nimdoc/testproject/testproject.nim
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
import subdir / subdir_b / utils
|
||||
|
||||
## This is the top level module.
|
||||
runnableExamples:
|
||||
doAssert bar(3, 4) == 7
|
||||
foo(1, 2)
|
||||
|
||||
|
||||
template foo*(a, b: SomeType) =
|
||||
## This does nothing
|
||||
##
|
||||
discard
|
||||
|
||||
proc bar*[T](a, b: T): T =
|
||||
result = a + b
|
||||
|
||||
import std/macros
|
||||
|
||||
macro bar*(): untyped =
|
||||
result = newStmtList()
|
||||
0
nimdoc/testproject/testproject.nimble
Normal file
0
nimdoc/testproject/testproject.nimble
Normal file
Loading…
Add table
Add a link
Reference in a new issue