Skip to content

Commit

Permalink
Add the ability to pass arguments to test command
Browse files Browse the repository at this point in the history
  • Loading branch information
yyoncho committed Jul 14, 2022
1 parent 45051b5 commit 0bdea97
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/nimble.nim
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,12 @@ proc execBackend(pkgInfo: PackageInfo, options: Options) =
display("Generating", ("documentation for $1 (from package $2) using $3 " &
"backend") % [bin, pkgInfo.basicInfo.name, backend], priority = HighPriority)

doCmd(getNimBin(options).quoteShell & " $# --noNimblePath $# $#" %
[backend, join(args, " "), bin.quoteShell])
doCmd("$# $# --noNimblePath $# $# $#" %
[getNimBin(options).quoteShell,
backend,
join(args, " "),
bin.quoteShell,
options.action.additionalArguments.map(quoteShell).join(" ")])

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

Expand Down Expand Up @@ -1412,6 +1416,7 @@ proc test(options: Options) =
var optsCopy = options
optsCopy.action = Action(typ: actionCompile)
optsCopy.action.file = file.path
optsCopy.action.additionalArguments = options.action.arguments
optsCopy.action.backend = pkgInfo.backend
optsCopy.getCompilationFlags() = options.getCompilationFlags()
# treat run flags as compile for default test task
Expand Down
1 change: 1 addition & 0 deletions src/nimblepkg/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type
of actionCompile, actionDoc, actionBuild:
file*: string
backend*: string
additionalArguments*: seq[string]
compileOptions: seq[string]
of actionRun:
runFile: Option[string]
Expand Down
8 changes: 8 additions & 0 deletions tests/testParams/testParams.nimble
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Package

version = "0.1.0"
author = "Ivan Yonchovski"
description = "A new awesome nimble package"
license = "MIT"
srcDir = "src"
bin = @["issue1000"]
8 changes: 8 additions & 0 deletions tests/testParams/tests/tsimple.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import unittest

suite "Trivial tests":
test "Passing test":
check 1 == 1

test "Failing test":
check 1 == 2
9 changes: 8 additions & 1 deletion tests/tissues.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@ from nimblepkg/version import newVersion
from nimblepkg/displaymessages import cannotUninstallPkgMsg

suite "issues":
test "test params":
cd "testParams":
let (output, exitCode) = execNimbleYes("test", "Passing test")

check exitCode == QuitSuccess
check output.contains("Passing test")

test "issue 801":
cd "issue801":
let (output, exitCode) = execNimbleYes("test")
check exitCode == QuitSuccess

# Verify hooks work
check output.contains("before test")
check output.contains("test executed")
check output.contains("after test")

test "issue 799":
Expand Down

0 comments on commit 0bdea97

Please sign in to comment.