Add test target
This commit is contained in:
parent
10a38a3c90
commit
254658ee5d
14 changed files with 111 additions and 9 deletions
|
|
@ -11,7 +11,7 @@ bin = @["nimscript"]
|
|||
|
||||
requires "nim >= 0.12.1"
|
||||
|
||||
task test, "test description":
|
||||
task work, "test description":
|
||||
echo(5+5)
|
||||
|
||||
task c_test, "Testing `setCommand \"c\", \"nimscript.nim\"`":
|
||||
|
|
@ -42,4 +42,4 @@ before hooks2:
|
|||
return false
|
||||
|
||||
task hooks2, "Testing the hooks again":
|
||||
echo("Shouldn't happen")
|
||||
echo("Shouldn't happen")
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ proc execNimble(args: varargs[string]): tuple[output: string, exitCode: int] =
|
|||
quotedArgs = quoted_args.map((x: string) => ("\"" & x & "\""))
|
||||
|
||||
result = execCmdEx(quotedArgs.join(" "))
|
||||
checkpoint(result.output)
|
||||
|
||||
proc processOutput(output: string): seq[string] =
|
||||
output.strip.splitLines().filter((x: string) => (x.len > 0))
|
||||
|
|
@ -220,7 +221,7 @@ test "can install nimscript package":
|
|||
|
||||
test "can execute nimscript tasks":
|
||||
cd "nimscript":
|
||||
let (output, exitCode) = execNimble("--verbose", "test")
|
||||
let (output, exitCode) = execNimble("--verbose", "work")
|
||||
let lines = output.strip.splitLines()
|
||||
check exitCode == QuitSuccess
|
||||
check lines[^1] == "10"
|
||||
|
|
@ -253,7 +254,7 @@ test "can use nimscript with repeated flags (issue #329)":
|
|||
test "can list nimscript tasks":
|
||||
cd "nimscript":
|
||||
let (output, exitCode) = execNimble("tasks")
|
||||
check "test test description".normalize in output.normalize
|
||||
check "work test description".normalize in output.normalize
|
||||
check exitCode == QuitSuccess
|
||||
|
||||
test "can use pre/post hooks":
|
||||
|
|
@ -400,3 +401,22 @@ test "can dump for installed package":
|
|||
let (outp, exitCode) = execNimble("dump", "testdump")
|
||||
check: exitCode == 0
|
||||
check: outp.processOutput.inLines("desc: \"Test package for dump command\"")
|
||||
|
||||
test "Runs passing unit tests":
|
||||
cd "testsPass":
|
||||
let (outp, exitCode) = execNimble("test")
|
||||
check: exitCode == QuitSuccess
|
||||
check: outp.processOutput.inLines("First test")
|
||||
check: outp.processOutput.inLines("Second test")
|
||||
check: outp.processOutput.inLines("Third test")
|
||||
check: outp.processOutput.inLines("Executing my func")
|
||||
|
||||
test "Runs failing unit tests":
|
||||
cd "testsFail":
|
||||
let (outp, exitCode) = execNimble("test")
|
||||
check: exitCode == QuitFailure
|
||||
check: outp.processOutput.inLines("First test")
|
||||
check: outp.processOutput.inLines("Failing Second test")
|
||||
check: not outp.processOutput.inLines("Third test")
|
||||
|
||||
|
||||
|
|
|
|||
4
tests/testsFail/testing123.nim
Normal file
4
tests/testsFail/testing123.nim
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
proc myFunc*() =
|
||||
echo "Executing my func"
|
||||
|
||||
4
tests/testsFail/testing123.nimble
Normal file
4
tests/testsFail/testing123.nimble
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
version = "0.1.0"
|
||||
author = "John Doe"
|
||||
description = "Nimble Test"
|
||||
license = "BSD"
|
||||
6
tests/testsFail/tests/a.nim
Normal file
6
tests/testsFail/tests/a.nim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import testing123, unittest
|
||||
|
||||
test "can compile nimble":
|
||||
echo "First test"
|
||||
myFunc()
|
||||
|
||||
6
tests/testsFail/tests/b.nim
Normal file
6
tests/testsFail/tests/b.nim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import testing123, unittest
|
||||
|
||||
test "can compile nimble":
|
||||
echo "Failing Second test"
|
||||
assert(false)
|
||||
|
||||
7
tests/testsFail/tests/c.nim
Normal file
7
tests/testsFail/tests/c.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import testing123, unittest
|
||||
|
||||
test "can compile nimble":
|
||||
echo "Third test"
|
||||
myFunc()
|
||||
|
||||
|
||||
4
tests/testsPass/testing123.nim
Normal file
4
tests/testsPass/testing123.nim
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
proc myFunc*() =
|
||||
echo "Executing my func"
|
||||
|
||||
4
tests/testsPass/testing123.nimble
Normal file
4
tests/testsPass/testing123.nimble
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
version = "0.1.0"
|
||||
author = "John Doe"
|
||||
description = "Nimble Test"
|
||||
license = "BSD"
|
||||
6
tests/testsPass/tests/one.nim
Normal file
6
tests/testsPass/tests/one.nim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import testing123, unittest
|
||||
|
||||
test "can compile nimble":
|
||||
echo "First test"
|
||||
myFunc()
|
||||
|
||||
7
tests/testsPass/tests/three.nim
Normal file
7
tests/testsPass/tests/three.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import testing123, unittest
|
||||
|
||||
test "can compile nimble":
|
||||
echo "Third test"
|
||||
myFunc()
|
||||
|
||||
|
||||
7
tests/testsPass/tests/two.nim
Normal file
7
tests/testsPass/tests/two.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import testing123, unittest
|
||||
|
||||
test "can compile nimble":
|
||||
echo "Second test"
|
||||
myFunc()
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue