summary refs log tree commit diff stats
path: root/compiler/sem.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/sem.nim')
-rw-r--r--compiler/sem.nim8
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/sem.nim b/compiler/sem.nim
index 0d484d276..2c3fab5a5 100644
--- a/compiler/sem.nim
+++ b/compiler/sem.nim
@@ -608,16 +608,18 @@ proc myProcess(context: PPassContext, n: PNode): PNode =
   rod.storeNode(c.graph, c.module, result)
 
 proc testExamples(c: PContext) =
+  let outputDir = c.config.getNimcacheDir / "runnableExamples"
+  createDir(outputDir)
   let inp = toFullPath(c.config, c.module.info)
-  let outp = inp.changeFileExt"" & "_examples.nim"
+  let outp = outputDir / extractFilename(inp.changeFileExt"" & "_examples.nim")
   let nimcache = outp.changeFileExt"" & "_nimcache"
-  renderModule(c.runnableExamples, inp, outp)
+  renderModule(c.runnableExamples, inp, outp, conf = c.config)
   let backend = if isDefined(c.config, "js"): "js"
                 elif isDefined(c.config, "cpp"): "cpp"
                 elif isDefined(c.config, "objc"): "objc"
                 else: "c"
   if os.execShellCmd(os.getAppFilename() & " " & backend & " --nimcache:" & nimcache & " -r " & outp) != 0:
-    quit "[Examples] failed"
+    quit "[Examples] failed: see " & outp
   else:
     removeFile(outp)
     removeFile(outp.changeFileExt(ExeExt))