Skip to content

Commit f944261

Browse files
committed
Add the ability to pass arguments to test command
1 parent 45051b5 commit f944261

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

src/nimble.nim

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,8 +766,12 @@ proc execBackend(pkgInfo: PackageInfo, options: Options) =
766766
display("Generating", ("documentation for $1 (from package $2) using $3 " &
767767
"backend") % [bin, pkgInfo.basicInfo.name, backend], priority = HighPriority)
768768

769-
doCmd(getNimBin(options).quoteShell & " $# --noNimblePath $# $#" %
770-
[backend, join(args, " "), bin.quoteShell])
769+
doCmd("$# $# --noNimblePath $# $# $#" %
770+
[getNimBin(options).quoteShell,
771+
backend,
772+
join(args, " "),
773+
bin.quoteShell,
774+
options.action.additionalArguments.map(quoteShell).join(" ")])
771775

772776
display("Success:", "Execution finished", Success, HighPriority)
773777

@@ -1412,6 +1416,7 @@ proc test(options: Options) =
14121416
var optsCopy = options
14131417
optsCopy.action = Action(typ: actionCompile)
14141418
optsCopy.action.file = file.path
1419+
optsCopy.action.additionalArguments = options.action.arguments
14151420
optsCopy.action.backend = pkgInfo.backend
14161421
optsCopy.getCompilationFlags() = options.getCompilationFlags()
14171422
# treat run flags as compile for default test task

src/nimblepkg/options.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ type
8888
of actionCompile, actionDoc, actionBuild:
8989
file*: string
9090
backend*: string
91+
additionalArguments*: seq[string]
9192
compileOptions: seq[string]
9293
of actionRun:
9394
runFile: Option[string]

tests/testParams/testParams.nimble

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Package
2+
3+
version = "0.1.0"
4+
author = "Ivan Yonchovski"
5+
description = "A new awesome nimble package"
6+
license = "MIT"
7+
srcDir = "src"
8+
bin = @["issue1000"]

tests/testParams/tests/tsimple.nim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import unittest
2+
3+
suite "Trivial tests":
4+
test "Passing test":
5+
check 1 == 1
6+
7+
test "Failing test":
8+
check 1 == 2

tests/tissues.nim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ from nimblepkg/version import newVersion
1010
from nimblepkg/displaymessages import cannotUninstallPkgMsg
1111

1212
suite "issues":
13+
test "test params":
14+
cd "testParams":
15+
let (output, exitCode) = execNimbleYes("test", "Passing test")
16+
17+
check exitCode == QuitSuccess
18+
check output.contains("Passing test")
19+
1320
test "issue 801":
1421
cd "issue801":
1522
let (output, exitCode) = execNimbleYes("test")

0 commit comments

Comments
 (0)