testament: generic N-fold batching: windows CI 37mn=>16m (#14823)

* testament: run CI faster thanks to batching
* move ta_in, tstdin into existing tosproc
* move ta_out,tafalse,texitcode,tstderr into existing tosproc
* joinable osproc
* move tstdout into existing tosproc
* spec: batchable; fix tests
* fixup
This commit is contained in:
Timothee Cour 2020-06-27 07:51:17 -07:00 • committed by GitHub
commit 90808877c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 172 additions and 181 deletions

View file

@ -1,9 +0,0 @@
discard """
action: compile
"""
# This file is prefixed with an "a", because other tests
# depend on it and it must be compiled first.
import strutils
let x = stdin.readLine()
echo x.parseInt + 5

View file

@ -1,33 +0,0 @@
discard """
output: '''
start ta_out
to stdout
to stdout
to stderr
to stderr
to stdout
to stdout
end ta_out
'''
"""
echo "start ta_out"
# This file is prefixed with an "a", because other tests
# depend on it and it must be compiled first.
stdout.writeLine("to stdout")
stdout.flushFile()
stdout.writeLine("to stdout")
stdout.flushFile()
stderr.writeLine("to stderr")
stderr.flushFile()
stderr.writeLine("to stderr")
stderr.flushFile()
stdout.writeLine("to stdout")
stdout.flushFile()
stdout.writeLine("to stdout")
stdout.flushFile()
echo "end ta_out"

View file

@ -1,7 +0,0 @@
discard """
exitcode: 1
"""
# 'tafalse.nim' to ensure it is compiled before texitcode.nim
import system
quit(QuitFailure)

View file

@ -1,3 +1,7 @@
discard """
joinable: false
"""
import osproc, streams, strutils, os
const NumberOfProcesses = 13

View file

@ -1,26 +0,0 @@
discard """
output: ""
"""
import osproc, os
const filename = when defined(Windows): "tafalse.exe" else: "tafalse"
let dir = getCurrentDir() / "tests" / "osproc"
doAssert fileExists(dir / filename)
var p = startProcess(filename, dir)
doAssert(waitForExit(p) == QuitFailure)
p = startProcess(filename, dir)
var running = true
while running:
running = running(p)
doAssert(waitForExit(p) == QuitFailure)
# make sure that first call to running() after process exit returns false
p = startProcess(filename, dir)
for j in 0..<30: # refs #13449
os.sleep(50)
if not running(p): break
doAssert(not running(p))
doAssert(waitForExit(p) == QuitFailure) # avoid zombies

View file

@ -1,37 +0,0 @@
discard """
output: '''
start tstderr
--------------------------------------
to stderr
to stderr
--------------------------------------
'''
"""
echo "start tstderr"
import osproc, os, streams
const filename = "ta_out".addFileExt(ExeExt)
doAssert fileExists(getCurrentDir() / "tests" / "osproc" / filename)
var p = startProcess(filename, getCurrentDir() / "tests" / "osproc",
options={})
try:
let stdoutStream = p.outputStream
let stderrStream = p.errorStream
var x = newStringOfCap(120)
var output = ""
while stderrStream.readLine(x.TaintedString):
output.add(x & "\n")
echo "--------------------------------------"
stdout.flushFile()
stderr.write output
stderr.flushFile()
echo "--------------------------------------"
stdout.flushFile()
finally:
p.close()

View file

@ -1,17 +0,0 @@
discard """
output: "10"
"""
import osproc, os, streams
const filename = when defined(Windows): "ta_in.exe" else: "ta_in"
doAssert fileExists(getCurrentDir() / "tests" / "osproc" / filename)
var p = startProcess(filename, getCurrentDir() / "tests" / "osproc")
p.inputStream.write("5\n")
p.inputStream.flush()
var line = ""
while p.outputStream.readLine(line.TaintedString):
echo line

View file

@ -1,31 +0,0 @@
discard """
output: '''--------------------------------------
start ta_out
to stdout
to stdout
to stderr
to stderr
to stdout
to stdout
end ta_out
--------------------------------------
'''
"""
import osproc, os, streams
const filename = when defined(Windows): "ta_out.exe" else: "ta_out"
doAssert fileExists(getCurrentDir() / "tests" / "osproc" / filename)
var p = startProcess(filename, getCurrentDir() / "tests" / "osproc",
options={poStdErrToStdOut})
let outputStream = p.outputStream
var x = newStringOfCap(120)
var output = ""
while outputStream.readLine(x.TaintedString):
output.add(x & "\n")
echo "--------------------------------------"
stdout.write output
echo "--------------------------------------"