fix #10731 ; runnableExamples "-b:cpp --run:off": code works (#14384)

* runnableExamples "-b:cpp -r:off": code
This commit is contained in:
Timothee Cour 2020-05-20 00:45:34 -07:00 • committed by GitHub
commit 3d20f14193
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 104 additions and 37 deletions

View file

@ -1,5 +1,5 @@
discard """
cmd: "nim doc $file"
cmd: "nim doc --doccmd:-d:testFooExternal --hints:off $file"
action: "compile"
nimout: '''
foo1
@ -66,6 +66,39 @@ when true: # issue #12746
# specifying Error is culprit
discard
when true: # runnableExamples with rdoccmd
runnableExamples "-d:testFoo -d:testBar":
doAssert defined(testFoo) and defined(testBar)
doAssert defined(testFooExternal)
runnableExamples "-d:testFoo2":
doAssert defined(testFoo2)
doAssert not defined(testFoo) # doesn't get confused by other examples
## all these syntaxes work too
runnableExamples("-d:testFoo2"): discard
runnableExamples(): discard
runnableExamples: discard
runnableExamples "-r:off": # issue #10731
doAssert false ## we compile only (-r:off), so this won't be run
runnableExamples "-b:js":
import std/compilesettings
proc startsWith*(s, prefix: cstring): bool {.noSideEffect, importjs: "#.startsWith(#)".}
doAssert querySetting(backend) == "js"
runnableExamples "-b:cpp":
static: doAssert defined(cpp)
type std_exception {.importcpp: "std::exception", header: "<exception>".} = object
proc fun2*() =
runnableExamples "-d:foo": discard # checks that it also works inside procs
when false: # future work
# passing non-string-litterals (for reuse)
const a = "-b:cpp"
runnableExamples(a): discard
# passing seq (to run with multiple compilation options)
runnableExamples(@["-b:cpp", "-b:js"]): discard
# also check for runnableExamples at module scope
runnableExamples:
block: