Add docgen runs in tests

Fix paths import

Skip docgen for rsa for now
This commit is contained in:
Joey Yakimowich-Payne 2020-04-29 19:15:11 -06:00 • committed by genotrance
commit 1e105d34a4
4 changed files with 16 additions and 7 deletions

View file

@ -12,14 +12,21 @@ installDirs = @["nimterop"]
requires "nim >= 0.20.2", "regex >= 0.14.1", "cligen >= 0.9.45"
import nimterop/docs
import os
proc execCmd(cmd: string) =
exec "tests/timeit " & cmd
proc execTest(test: string, flags = "") =
proc execTest(test: string, flags = "", runDocs = true) =
execCmd "nim c --hints:off -f " & flags & " -r " & test
execCmd "nim cpp --hints:off " & flags & " -r " & test
if runDocs:
let docPath = "build/html_" & test.extractFileName.changeFileExt("") & "_docs"
rmDir docPath
mkDir docPath
buildDocs(@[test], docPath, compilerArgs = flags)
task buildToast, "build toast":
execCmd("nim c --hints:off nimterop/toast.nim")
@ -54,8 +61,8 @@ task test, "Test":
execTest "tests/tpcre.nim", "-d:FLAGS=\"-f:ast2\""
when defined(Linux):
execTest "tests/rsa.nim"
execTest "tests/rsa.nim", "-d:FLAGS=\"-H\""
execTest "tests/rsa.nim", runDocs = false
execTest "tests/rsa.nim", "-d:FLAGS=\"-H\"", runDocs = false
# Platform specific tests
when defined(Windows):

View file

@ -434,7 +434,7 @@ proc cAddSearchDir*(dir: string) {.compileTime.} =
## Add directory `dir` to the search path used in calls to
## `cSearchPath() <cimport.html#cSearchPath,string>`_.
runnableExamples:
import paths, os
import nimterop/paths, os
static:
cAddSearchDir testsIncludeDir()
doAssert cSearchPath("test.h").existsFile

View file

@ -36,7 +36,7 @@ proc execAction(cmd: string): string =
doAssert ret == 0, "Command failed: " & $ret & "\ncmd: " & ccmd & "\nresult:\n" & result
proc buildDocs*(files: openArray[string], path: string, baseDir = getProjectPath() & $DirSep,
defines: openArray[string] = @[]) =
defines: openArray[string] = @[], compilerArgs = "") =
## Generate docs for all specified nim `files` to the specified `path`
##
## `baseDir` is the project path by default and `files` and `path` are relative
@ -70,7 +70,7 @@ proc buildDocs*(files: openArray[string], path: string, baseDir = getProjectPath
defStr
nim = getCurrentCompilerExe()
for file in files:
echo execAction(&"{nim} doc {defStr} -o:{path} --project --index:on {baseDir & file}")
echo execAction(&"{nim} doc {defStr} {compilerArgs} -o:{path} --project --index:on {baseDir & file}")
echo execAction(&"{nim} buildIndex -o:{path}/theindex.html {path}")
when declared(getNimRootDir):

View file

@ -1,4 +1,6 @@
import std/unittest
import os
import macros
import nimterop/cimport
import nimterop/paths
@ -10,7 +12,7 @@ cDefine("FORCE")
cIncludeDir testsIncludeDir()
cCompile cSearchPath("test.c")
cPluginPath("tests/tnimterop_c_plugin.nim")
cPluginPath(getProjectPath() / "tnimterop_c_plugin.nim")
cOverride:
type