aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Yakimowich-Payne <jyapayne@gmail.com>2020-04-29 19:15:11 -0600
committergenotrance <dev@genotrance.com>2020-05-04 16:43:07 -0500
commit1e105d34a49469b9c37ecbd38032765dbef96049 (patch)
tree340b3a842a78fee1578b837b2cbf53d4d91ad983
parent31bea0f032adca25bcb836fcbd7f4cb2f00d78ba (diff)
downloadnimterop-1e105d34a49469b9c37ecbd38032765dbef96049.tar.gz
nimterop-1e105d34a49469b9c37ecbd38032765dbef96049.zip
Add docgen runs in tests
Fix paths import Skip docgen for rsa for now
-rw-r--r--nimterop.nimble13
-rw-r--r--nimterop/cimport.nim2
-rw-r--r--nimterop/docs.nim4
-rw-r--r--tests/tnimterop_c.nim4
4 files changed, 16 insertions, 7 deletions
diff --git a/nimterop.nimble b/nimterop.nimble
index a6ece7c..8a47465 100644
--- a/nimterop.nimble
+++ b/nimterop.nimble
@@ -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):
diff --git a/nimterop/cimport.nim b/nimterop/cimport.nim
index e081633..99be1f5 100644
--- a/nimterop/cimport.nim
+++ b/nimterop/cimport.nim
@@ -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
diff --git a/nimterop/docs.nim b/nimterop/docs.nim
index d808535..e0fef39 100644
--- a/nimterop/docs.nim
+++ b/nimterop/docs.nim
@@ -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):
diff --git a/tests/tnimterop_c.nim b/tests/tnimterop_c.nim
index 20c1678..ef814ea 100644
--- a/tests/tnimterop_c.nim
+++ b/tests/tnimterop_c.nim
@@ -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