Testament pre parallel (#9137)

* testament: move to root dir (it's not a test)

* osproc: fix process index passed to afterRunEvent for parallel runs

it was passing the index of the process, not index of all commands

* testament: complete file move
This commit is contained in:
Jacek Sieka 2018-10-12 09:27:47 -06:00 • committed by Andreas Rumpf
commit 97738a4f28
18 changed files with 20 additions and 17 deletions

View file

@ -53,8 +53,8 @@ test-windows:
<<: *win_set_path_def <<: *win_set_path_def
script: script:
- call ci\deps.bat - call ci\deps.bat
- nim c --taintMode:on tests\testament\tester - nim c --taintMode:on testament\tester
- tests\testament\tester.exe --pedantic all - testament\tester.exe --pedantic all
tags: tags:
- windows - windows
- fast - fast

View file

@ -42,8 +42,8 @@ script:
#- nimble install sdl1 #- nimble install sdl1
#- nimble install jester@#head -y #- nimble install jester@#head -y
#- nimble install niminst #- nimble install niminst
- nim c --taintMode:on -d:nimCoroutines tests/testament/tester - nim c --taintMode:on -d:nimCoroutines testament/tester
- tests/testament/tester --pedantic all -d:nimCoroutines - testament/tester --pedantic all -d:nimCoroutines
- nim c -o:bin/nimpretty nimpretty/nimpretty.nim - nim c -o:bin/nimpretty nimpretty/nimpretty.nim
- nim c -r nimpretty/tester.nim - nim c -r nimpretty/tester.nim
- ./koch docs --git.commit:devel - ./koch docs --git.commit:devel

View file

@ -53,11 +53,11 @@ build_script:
# - nimble install opengl -y # - nimble install opengl -y
# - nimble install sdl1 -y # - nimble install sdl1 -y
# - nimble install jester@#head -y # - nimble install jester@#head -y
- nim c --taintMode:on -d:nimCoroutines --os:genode -d:posix --compileOnly tests/testament/tester - nim c --taintMode:on -d:nimCoroutines --os:genode -d:posix --compileOnly testament/tester
- nim c --taintMode:on -d:nimCoroutines tests/testament/tester - nim c --taintMode:on -d:nimCoroutines testament/tester
test_script: test_script:
- tests\testament\tester --pedantic all -d:nimCoroutines - testament\tester --pedantic all -d:nimCoroutines
- nim c -r nimdoc\tester - nim c -r nimdoc\tester
# - koch csource # - koch csource
# - koch zip # - koch zip

View file

@ -1,4 +1,4 @@
REM - Run the full testsuite; tests\testament\tester all REM - Run the full testsuite; testament\tester all
REM - Uncomment the list of changes in news.txt REM - Uncomment the list of changes in news.txt
REM - write a news ticker entry REM - write a news ticker entry

View file

@ -109,7 +109,7 @@ only want to see the output of failing tests, go for
You can also run only a single category of tests. A category is a subdirectory You can also run only a single category of tests. A category is a subdirectory
in the ``tests`` directory. There are a couple of special categories; for a in the ``tests`` directory. There are a couple of special categories; for a
list of these, see ``tests/testament/categories.nim``, at the bottom. list of these, see ``testament/categories.nim``, at the bottom.
:: ::

View file

@ -61,7 +61,7 @@ test command
------------ ------------
The `test`:idx: command can also be invoked with the alias ``tests``. This The `test`:idx: command can also be invoked with the alias ``tests``. This
command will compile and run ``tests/testament/tester.nim``, which is the main command will compile and run ``testament/tester.nim``, which is the main
driver of Nim's test suite. You can pass options to the ``test`` command, driver of Nim's test suite. You can pass options to the ``test`` command,
they will be forwarded to the tester. See its source code for available they will be forwarded to the tester. See its source code for available
options. options.

View file

@ -380,11 +380,11 @@ template `|`(a, b): string = (if a.len > 0: a else: b)
proc tests(args: string) = proc tests(args: string) =
# we compile the tester with taintMode:on to have a basic # we compile the tester with taintMode:on to have a basic
# taint mode test :-) # taint mode test :-)
nimexec "cc --taintMode:on --opt:speed tests/testament/tester" nimexec "cc --taintMode:on --opt:speed testament/tester"
# Since tests take a long time (on my machine), and we want to defy Murhpys # Since tests take a long time (on my machine), and we want to defy Murhpys
# law - lets make sure the compiler really is freshly compiled! # law - lets make sure the compiler really is freshly compiled!
nimexec "c --lib:lib -d:release --opt:speed compiler/nim.nim" nimexec "c --lib:lib -d:release --opt:speed compiler/nim.nim"
let tester = quoteShell(getCurrentDir() / "tests/testament/tester".exe) let tester = quoteShell(getCurrentDir() / "testament/tester".exe)
let success = tryExec tester & " " & (args|"all") let success = tryExec tester & " " & (args|"all")
if not existsEnv("TRAVIS") and not existsEnv("APPVEYOR"): if not existsEnv("TRAVIS") and not existsEnv("APPVEYOR"):
exec tester & " html" exec tester & " html"

View file

@ -236,6 +236,7 @@ proc execProcesses*(cmds: openArray[string],
if n > 1: if n > 1:
var i = 0 var i = 0
var q = newSeq[Process](n) var q = newSeq[Process](n)
var idxs = newSeq[int](n) # map process index to cmds index
when defined(windows): when defined(windows):
var w: WOHandleArray var w: WOHandleArray
@ -248,6 +249,7 @@ proc execProcesses*(cmds: openArray[string],
if beforeRunEvent != nil: if beforeRunEvent != nil:
beforeRunEvent(i) beforeRunEvent(i)
q[i] = startProcess(cmds[i], options = options + {poEvalCommand}) q[i] = startProcess(cmds[i], options = options + {poEvalCommand})
idxs[i] = i
when defined(windows): when defined(windows):
w[i] = q[i].fProcessHandle w[i] = q[i].fProcessHandle
inc(i) inc(i)
@ -304,12 +306,13 @@ proc execProcesses*(cmds: openArray[string],
if rexit >= 0: if rexit >= 0:
result = max(result, abs(q[rexit].peekExitCode())) result = max(result, abs(q[rexit].peekExitCode()))
if afterRunEvent != nil: afterRunEvent(rexit, q[rexit]) if afterRunEvent != nil: afterRunEvent(idxs[rexit], q[rexit])
close(q[rexit]) close(q[rexit])
if i < len(cmds): if i < len(cmds):
if beforeRunEvent != nil: beforeRunEvent(i) if beforeRunEvent != nil: beforeRunEvent(i)
q[rexit] = startProcess(cmds[i], q[rexit] = startProcess(cmds[i],
options = options + {poEvalCommand}) options = options + {poEvalCommand})
idxs[rexit] = i
when defined(windows): when defined(windows):
w[rexit] = q[rexit].fProcessHandle w[rexit] = q[rexit].fProcessHandle
inc(i) inc(i)

View file

@ -477,7 +477,7 @@ proc main() =
case action case action
of "all": of "all":
let testsDir = "tests" & DirSep let testsDir = "tests" & DirSep
var myself = quoteShell(findExe("tests" / "testament" / "tester")) var myself = quoteShell(findExe("testament" / "tester"))
if targetsStr.len > 0: if targetsStr.len > 0:
myself &= " " & quoteShell("--targets:" & targetsStr) myself &= " " & quoteShell("--targets:" & targetsStr)
@ -488,7 +488,7 @@ proc main() =
for kind, dir in walkDir(testsDir): for kind, dir in walkDir(testsDir):
assert testsDir.startsWith(testsDir) assert testsDir.startsWith(testsDir)
let cat = dir[testsDir.len .. ^1] let cat = dir[testsDir.len .. ^1]
if kind == pcDir and cat notin ["testament", "testdata", "nimcache"]: if kind == pcDir and cat notin ["testdata", "nimcache"]:
cmds.add(myself & " cat " & quoteShell(cat) & rest) cmds.add(myself & " cat " & quoteShell(cat) & rest)
for cat in AdditionalCategories: for cat in AdditionalCategories:
cmds.add(myself & " cat " & quoteShell(cat) & rest) cmds.add(myself & " cat " & quoteShell(cat) & rest)

View file

@ -10,7 +10,7 @@ execute the compiled binary, you need to specify a spec with an ``action`` key
Each test can contain a spec in a ``discard """ ... """`` block. Each test can contain a spec in a ``discard """ ... """`` block.
**Check out the [``parseSpec`` procedure](https://github.com/nim-lang/Nim/blob/devel/tests/testament/specs.nim#L124) in the ``specs`` module for a full and reliable reference** **Check out the [``parseSpec`` procedure](https://github.com/nim-lang/Nim/blob/devel/testament/specs.nim#L124) in the ``specs`` module for a full and reliable reference**
## action ## action

View file

@ -1,6 +1,6 @@
discard """ discard """
# Since the tests for nre are all bundled together we treat failure in one test as an nre failure # Since the tests for nre are all bundled together we treat failure in one test as an nre failure
# When running 'tests/testament/tester' a failed check() in the test suite will cause the exit # When running 'testament/tester' a failed check() in the test suite will cause the exit
# codes to differ and be reported as a failure # codes to differ and be reported as a failure
output: output: