discard """ targets: "c cpp" joinable: false """ ## tests that don't quite fit the mold and are easier to handle via `execCmdEx` ## A few others could be added to here to simplify code. ## Note: this test is a bit slow but tests a lot of things; please don't disable. import std/[strformat,os,osproc,unittest] from std/sequtils import toSeq,mapIt from std/algorithm import sorted import stdtest/[specialpaths, unittest_light] import "$lib/../compiler/nimpaths" const nim = getCurrentCompilerExe() mode = when defined(c): "c" elif defined(cpp): "cpp" else: static: doAssert false nimcache = buildDir / "nimcacheTrunner" # instead of `querySetting(nimcacheDir)`, avoids stomping on other parallel tests proc runCmd(file, options = ""): auto = let fileabs = testsDir / file.unixToNativePath doAssert fileabs.existsFile, fileabs let cmd = fmt"{nim} {mode} {options} --hints:off {fileabs}" result = execCmdEx(cmd) when false: echo result[0] & "\n" & result[1] # for debugging when defined(nimTrunnerFfi): block: # mevalffi when defined(openbsd): #[ openbsd defines `#define stderr (&__sF[2])` which makes it cumbersome for dlopen'ing inside `importcSymbol`. Instead of adding special rules inside `importcSymbol` to handle this, we disable just the part that's not working and will provide a more general, clean fix in future PR. ]# var opt = "-d:nimEvalffiStderrWorkaround" let prefix = "" else: var opt = "" let prefix = """ hello world stderr hi stderr """ let (output, exitCode) = runCmd("vm/mevalffi.nim", fmt"{opt} --experimental:compiletimeFFI") let expected = fmt""" {prefix}foo foo:100 foo:101 foo:102:103 foo:102:103:104 foo:0.03:asdf:103:105 ret=[s1:foobar s2:foobar age:25 pi:3.14] """ doAssert output == expected, output doAssert exitCode == 0 else: # don't run twice the same test import std/[strutils] template check2(msg) = doAssert msg in output, output block: # tests with various options `nim doc --project --index --docroot` # regression tests for issues and PRS: #14376 #13223 #6583 ##13647 let file = testsDir / "nimdoc/sub/mmain.nim" let mainFname = "mmain.html" let htmldocsDirCustom = nimcache / "htmldocsCustom" let docroot = testsDir / "nimdoc" let options = [ 0: "--project", 1: "--project --docroot", 2: "", 3: fmt"--outDir:{htmldocsDirCustom}", 4: fmt"--docroot:{docroot}", 5: "--project --useNimcache", 6: "--index:off", ] for i in 0..