Merge branch 'master' of https://github.com/Nycto/nimble into Nycto-master
This commit is contained in:
commit
6a851f5b87
14 changed files with 110 additions and 10 deletions
|
|
@ -529,6 +529,28 @@ proc execBackend(options: Options) =
|
|||
[backend, args, bin], showOutput = true)
|
||||
display("Success:", "Execution finished", Success, HighPriority)
|
||||
|
||||
proc tempOutArg(file: string): string =
|
||||
## Returns the `--out` argument to pass to the compiler, using a temp file
|
||||
let (_, name, _) = splitFile(file)
|
||||
let dir = getNimbleTempDir() / "tests"
|
||||
createDir(dir)
|
||||
result = "--out:" & (dir / name)
|
||||
|
||||
proc test(options: Options) =
|
||||
## Executes all tests
|
||||
var files = toSeq(walkDir(getCurrentDir() / "tests"))
|
||||
files.sort do (a, b: auto) -> int:
|
||||
result = cmp(a.path, b.path)
|
||||
|
||||
for file in files:
|
||||
if file.path.endsWith(".nim") and file.kind in { pcFile, pcLinkToFile }:
|
||||
var optsCopy = options
|
||||
optsCopy.action.file = file.path
|
||||
optsCopy.action.backend = "c -r"
|
||||
optsCopy.action.compileOptions.add("--path:.")
|
||||
optsCopy.action.compileOptions.add(file.path.tempOutArg)
|
||||
execBackend(optsCopy)
|
||||
|
||||
proc search(options: Options) =
|
||||
## Searches for matches in ``options.action.search``.
|
||||
##
|
||||
|
|
@ -960,6 +982,8 @@ proc doAction(options: Options) =
|
|||
listPaths(options)
|
||||
of actionBuild:
|
||||
build(options)
|
||||
of actionTest:
|
||||
test(options)
|
||||
of actionCompile, actionDoc:
|
||||
execBackend(options)
|
||||
of actionInit:
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ type
|
|||
actionNil, actionRefresh, actionInit, actionDump, actionPublish,
|
||||
actionInstall, actionSearch,
|
||||
actionList, actionBuild, actionPath, actionUninstall, actionCompile,
|
||||
actionDoc, actionCustom, actionTasks, actionDevelop
|
||||
actionDoc, actionCustom, actionTasks, actionDevelop, actionTest
|
||||
|
||||
Action* = object
|
||||
case typ*: ActionType
|
||||
|
|
@ -41,7 +41,7 @@ type
|
|||
search*: seq[string] # Search string.
|
||||
of actionInit, actionDump:
|
||||
projName*: string
|
||||
of actionCompile, actionDoc, actionBuild:
|
||||
of actionCompile, actionDoc, actionBuild, actionTest:
|
||||
file*: string
|
||||
backend*: string
|
||||
compileOptions*: seq[string]
|
||||
|
|
@ -68,6 +68,7 @@ Commands:
|
|||
build Builds a package.
|
||||
c, cc, js [opts, ...] f.nim Builds a file inside a package. Passes options
|
||||
to the Nim compiler.
|
||||
test Compiles and executes tests
|
||||
doc, doc2 [opts, ...] f.nim Builds documentation for a file inside a
|
||||
package. Passes options to the Nim compiler.
|
||||
refresh [url] Refreshes the package list. A package list URL
|
||||
|
|
@ -125,6 +126,8 @@ proc parseActionType*(action: string): ActionType =
|
|||
result = actionPath
|
||||
of "build":
|
||||
result = actionBuild
|
||||
of "test":
|
||||
result = actionTest
|
||||
of "c", "compile", "js", "cpp", "cc":
|
||||
result = actionCompile
|
||||
of "doc", "doc2":
|
||||
|
|
@ -157,7 +160,7 @@ proc initAction*(options: var Options, key: string) =
|
|||
case options.action.typ
|
||||
of actionInstall, actionPath, actionDevelop, actionUninstall:
|
||||
options.action.packages = @[]
|
||||
of actionCompile, actionDoc, actionBuild:
|
||||
of actionCompile, actionDoc, actionBuild, actionTest:
|
||||
options.action.compileOptions = @[]
|
||||
options.action.file = ""
|
||||
if keyNorm == "c" or keyNorm == "compile": options.action.backend = ""
|
||||
|
|
@ -239,7 +242,7 @@ proc parseArgument*(key: string, result: var Options) =
|
|||
result.action.projName = key
|
||||
of actionCompile, actionDoc:
|
||||
result.action.file = key
|
||||
of actionList, actionBuild, actionPublish:
|
||||
of actionList, actionBuild, actionTest, actionPublish:
|
||||
result.showHelp = true
|
||||
of actionCustom:
|
||||
result.action.arguments.add(key)
|
||||
|
|
@ -278,7 +281,7 @@ proc parseFlag*(flag, val: string, result: var Options, kind = cmdLongOption) =
|
|||
result.depsOnly = true
|
||||
else:
|
||||
wasFlagHandled = false
|
||||
of actionCompile, actionDoc, actionBuild:
|
||||
of actionCompile, actionDoc, actionBuild, actionTest:
|
||||
let prefix = if kind == cmdShortOption: "-" else: "--"
|
||||
if val == "":
|
||||
result.action.compileOptions.add(prefix & flag)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue