Skip to content

Commit

Permalink
Testament pre parallel (nim-lang#9137)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
arnetheduck authored and Araq committed Oct 12, 2018
1 parent c492a7f commit 97738a4
Show file tree
Hide file tree
Showing 18 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ test-windows:
<<: *win_set_path_def
script:
- call ci\deps.bat
- nim c --taintMode:on tests\testament\tester
- tests\testament\tester.exe --pedantic all
- nim c --taintMode:on testament\tester
- testament\tester.exe --pedantic all
tags:
- windows
- fast
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ script:
#- nimble install sdl1
#- nimble install jester@#head -y
#- nimble install niminst
- nim c --taintMode:on -d:nimCoroutines tests/testament/tester
- tests/testament/tester --pedantic all -d:nimCoroutines
- nim c --taintMode:on -d:nimCoroutines testament/tester
- testament/tester --pedantic all -d:nimCoroutines
- nim c -o:bin/nimpretty nimpretty/nimpretty.nim
- nim c -r nimpretty/tester.nim
- ./koch docs --git.commit:devel
Expand Down
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ build_script:
# - nimble install opengl -y
# - nimble install sdl1 -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 tests/testament/tester
- nim c --taintMode:on -d:nimCoroutines --os:genode -d:posix --compileOnly testament/tester
- nim c --taintMode:on -d:nimCoroutines testament/tester

test_script:
- tests\testament\tester --pedantic all -d:nimCoroutines
- testament\tester --pedantic all -d:nimCoroutines
- nim c -r nimdoc\tester
# - koch csource
# - koch zip
Expand Down
2 changes: 1 addition & 1 deletion ci/nsis_build.bat
Original file line number Diff line number Diff line change
@@ -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 - write a news ticker entry
Expand Down
2 changes: 1 addition & 1 deletion doc/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
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.

::

Expand Down
2 changes: 1 addition & 1 deletion doc/koch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ test command
------------

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,
they will be forwarded to the tester. See its source code for available
options.
Expand Down
4 changes: 2 additions & 2 deletions koch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,11 @@ template `|`(a, b): string = (if a.len > 0: a else: b)
proc tests(args: string) =
# we compile the tester with taintMode:on to have a basic
# 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
# law - lets make sure the compiler really is freshly compiled!
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")
if not existsEnv("TRAVIS") and not existsEnv("APPVEYOR"):
exec tester & " html"
Expand Down
5 changes: 4 additions & 1 deletion lib/pure/osproc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ proc execProcesses*(cmds: openArray[string],
if n > 1:
var i = 0
var q = newSeq[Process](n)
var idxs = newSeq[int](n) # map process index to cmds index

when defined(windows):
var w: WOHandleArray
Expand All @@ -248,6 +249,7 @@ proc execProcesses*(cmds: openArray[string],
if beforeRunEvent != nil:
beforeRunEvent(i)
q[i] = startProcess(cmds[i], options = options + {poEvalCommand})
idxs[i] = i
when defined(windows):
w[i] = q[i].fProcessHandle
inc(i)
Expand Down Expand Up @@ -304,12 +306,13 @@ proc execProcesses*(cmds: openArray[string],

if rexit >= 0:
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])
if i < len(cmds):
if beforeRunEvent != nil: beforeRunEvent(i)
q[rexit] = startProcess(cmds[i],
options = options + {poEvalCommand})
idxs[rexit] = i
when defined(windows):
w[rexit] = q[rexit].fProcessHandle
inc(i)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/testament/tester.nim → testament/tester.nim
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ proc main() =
case action
of "all":
let testsDir = "tests" & DirSep
var myself = quoteShell(findExe("tests" / "testament" / "tester"))
var myself = quoteShell(findExe("testament" / "tester"))
if targetsStr.len > 0:
myself &= " " & quoteShell("--targets:" & targetsStr)

Expand All @@ -488,7 +488,7 @@ proc main() =
for kind, dir in walkDir(testsDir):
assert testsDir.startsWith(testsDir)
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)
for cat in AdditionalCategories:
cmds.add(myself & " cat " & quoteShell(cat) & rest)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

**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

Expand Down
2 changes: 1 addition & 1 deletion tests/stdlib/tnre.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
discard """
# 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
output:
Expand Down

0 comments on commit 97738a4

Please sign in to comment.