megatest can be executed

This commit is contained in:
Arne Döring
2018-12-03 19:12:59 +01:00
committed by Araq
parent fb1f5c62b5
commit 2a4c09ff88
22 changed files with 150 additions and 130 deletions

View File

@@ -559,7 +559,8 @@ proc genParForStmt(p: BProc, t: PNode) =
initLocExpr(p, call.sons[1], rangeA)
initLocExpr(p, call.sons[2], rangeB)
lineF(p, cpsStmts, "#pragma omp $4$n" &
# $n at the beginning because of #9710
lineF(p, cpsStmts, "$n#pragma omp $4$n" &
"for ($1 = $2; $1 <= $3; ++$1)",
[forLoopVar.loc.rdLoc,
rangeA.rdLoc, rangeB.rdLoc,

View File

@@ -553,3 +553,116 @@ proc processCategory(r: var TResults, cat: Category, options: string) =
inc testsRun
if testsRun == 0:
echo "[Warning] - Invalid category specified \"", cat.string, "\", no tests were run"
const specialCategories = [
"async",
"debugger",
"dll",
"examples",
"flags",
"gc",
"io",
"js",
"lib",
"longgc",
"manyloc",
"nimble-all",
"nimble-core",
"nimble-extra",
"niminaction",
"rodfiles",
"threads",
"untestable"
]
# these tests still have bugs. At some point when the bugs are fixd
# this should become empty.
# exclude for various reasons
const specialDisabedTests = [
"tests/dir with space/tspace.nim", # can't import dir with spaces.
"tests/method/tmultim.nim", # (77, 8) Error: method is not a base
"tests/system/talloc2.nim", # too much memory
"tests/collections/ttables.nim", # takes too long
"tests/system/tparams.nim", # executes itself with parameters
"tests/stdlib/tquit.nim", # not testing for obvious reasons
"tests/system/trealloc.nim", # out of memory
"tests/system/t7894.nim", # causes out of memory in later tests
"tests/types/tissues_types.nim", # causes out of memory with --gc:boehm
]
proc parseAllSpecs(): void =
var specs: array[TTestAction, seq[TSpec]]
var specialTests = 0
var ignoredTests = 0
var specsWithCfg: seq[TSpec]
var specsWithCustomCmd: seq[TSpec]
var specsEarlyExit: seq[TSpec]
var specsWithInput: seq[TSpec]
for file in os.walkFiles("tests/*/t*.nim"):
let a = find(file, '/') + 1
let b = find(file, '/', a)
let cat = file[a ..< b]
if cat in specialCategories:
specialTests += 1
continue
if file in specialDisabedTests:
# a special ignore here.
continue
let spec = parseSpec(file)
#echo cat, ": ", file
if fileExists(file & ".cfg"):
specsWithCfg.add spec
continue
if fileExists(parentDir(file) / "nim.cfg"):
specsWithCfg.add spec
continue
if spec.cmd != cmdTemplate():
specsWithCustomCmd.add spec
continue
if spec.err == reIgnored:
ignoredTests += 1
continue
if spec.exitCode != 0:
specsEarlyExit.add spec
continue
if spec.input != "":
specsWithInput.add spec
continue
specs[spec.action].add spec
for action, specs in specs.pairs:
echo action, ": ", specs.len
echo "specsWithCfg: ", specsWithCfg.len
echo "specsWithCustomCmd: ", specsWithCustomCmd.len
echo "earlyExit: ", specsEarlyExit.len
echo "special: ", specialTests
echo "ignored: ", ignoredTests
echo "withInput: ", specsWithInput.len
var megatest: string
for runSpec in specs[actionRun]:
if targetC in runSpec.targets or runSpec.targets == {}:
megatest.add "echo \"------------------------------: "
megatest.add runSpec.file
megatest.add "\"\n"
megatest.add "import \""
megatest.add runSpec.file
megatest.add "\"\n"
writeFile("megatest.nim", megatest)

View File

@@ -22,7 +22,6 @@ type
actionRun = "run"
actionCompile = "compile"
actionReject = "reject"
actionRunNoSpec = "runNoSpec"
TOutputCheck* = enum
ocIgnore = "ignore"

View File

@@ -28,6 +28,7 @@ Command:
c|cat|category <category> run all the tests of a certain category
r|run <test> run single test file
html generate $1 from the database
stats generate statistics about test cases
Arguments:
arguments are passed to the compiler
Options:
@@ -380,7 +381,7 @@ proc testSpec(r: var TResults, test: TTest, targets: set[TTarget] = {}) =
var given = callCompiler(expected.cmd, test.name, test.options, target,
extraOptions=" --stdout --hint[Path]:off --hint[Processing]:off")
compilerOutputTests(test, target, given, expected, r)
of actionRun, actionRunNoSpec:
of actionRun:
# In this branch of code "early return" pattern is clearer than deep
# nested conditionals - the empty rows in between to clarify the "danger"
var given = callCompiler(expected.cmd, test.name, test.options,
@@ -580,6 +581,8 @@ proc main() =
processSingleTest(r, cat, p.cmdLineRest.string, file)
of "html":
generateHtml(resultsFile, optFailing)
of "stats":
parseAllSpecs()
else:
quit Usage

View File

@@ -356,7 +356,7 @@ block troofregression:
echo testStr[testStr.len - 8 .. testStr.len - 1] & "__" & testStr[0 .. testStr.len - pred(rot)]
var
instructions = readFile(getAppDir() / "troofregression2.txt").split(',')
instructions = readFile(parentDir(currentSourcePath) / "troofregression2.txt").split(',')
programs = "abcdefghijklmnop"
proc dance(dancers: string): string =

View File

@@ -53,8 +53,7 @@ proc main() {.async.} =
# Issue #7347
block:
let appDir = getAppDir()
var file = openAsync(appDir & DirSep & "hello.txt")
var file = openAsync( parentDir(currentSourcePath) / "hello.txt")
echo file.getFileSize()
echo await file.readAll()
echo file.getFilePos()

View File

@@ -1,16 +0,0 @@
discard """
output: '''(FirstName: "James", LastName: "Franco")'''
"""
# bug #1547
import tables
type Person* = object
FirstName*: string
LastName*: string
let people = {
"001": Person(FirstName: "James", LastName: "Franco")
}.toTable()
echo people["001"]

View File

@@ -15,7 +15,7 @@ import std / [os]
proc main() =
let std = findNimStdLibCompileTime()
var intr = createInterpreter("myscript.nim", [std, getAppDir()])
var intr = createInterpreter("myscript.nim",[std, parentDir(currentSourcePath)])
intr.implementRoutine("*", "exposed", "addFloats", proc (a: VmArgs) =
setResult(a, getFloat(a, 0) + getFloat(a, 1) + getFloat(a, 2))
)
@@ -51,4 +51,3 @@ block issue9180:
evalString("echo 10+1")
evalString("echo 10+2")

View File

@@ -126,7 +126,7 @@ proc excl*(r: PRadixNode, a: ByteAddress): bool =
proc addLeaf(r: var PRadixNode, a: int): bool =
if r == nil:
# a linear node:
var x = cast[ptr TRadixNodeLinear](alloc(sizeof(TRadixNodeLinear)))
var x = cast[ptr TRadixNodeLinear](alloc0(sizeof(TRadixNodeLinear)))
x.kind = rnLeafLinear
x.len = 1'i8
x.keys[0] = toU8(a)
@@ -162,7 +162,7 @@ proc addInner(r: var PRadixNode, a: int, d: int): bool =
var k = a shr d and 0xff
if r == nil:
# a linear node:
var x = cast[ptr TRadixNodeLinear](alloc(sizeof(TRadixNodeLinear)))
var x = cast[ptr TRadixNodeLinear](alloc0(sizeof(TRadixNodeLinear)))
x.kind = rnLinear
x.len = 1'i8
x.keys[0] = toU8(k)
@@ -246,99 +246,3 @@ proc main() =
for x in elements(r): echo(x)
main()
when false:
proc traverse(r: PRadixNode, prefix: int, d: int) =
if r == nil: return
case r.kind
of rnLeafBits:
assert(d == 0)
var x = cast[ptr TRadixNodeLeafBits](r)
# iterate over any bit:
for i in 0..high(x.b):
if x.b[i] != 0: # test all bits for zero
for j in 0..BitsPerUnit-1:
if testBit(x.b[i], j):
visit(prefix or i*BitsPerUnit+j)
of rnLeafLinear:
assert(d == 0)
var x = cast[ptr TRadixNodeLeafLinear](r)
for i in 0..ze(x.len)-1:
visit(prefix or ze(x.keys[i]))
of rnFull:
var x = cast[ptr TRadixNodeFull](r)
for i in 0..high(r.b):
if r.b[i] != nil:
traverse(r.b[i], prefix or (i shl d), d-8)
of rnLinear:
var x = cast[ptr TRadixNodeLinear](r)
for i in 0..ze(x.len)-1:
traverse(x.vals[i], prefix or (ze(x.keys[i]) shl d), d-8)
type
TRadixIter {.final.} = object
r: PRadixNode
p: int
x: int
proc init(i: var TRadixIter, r: PRadixNode) =
i.r = r
i.x = 0
i.p = 0
proc nextr(i: var TRadixIter): PRadixNode =
if i.r == nil: return nil
case i.r.kind
of rnFull:
var r = cast[ptr TRadixNodeFull](i.r)
while i.x <= high(r.b):
if r.b[i.x] != nil:
i.p = i.x
return r.b[i.x]
inc(i.x)
of rnLinear:
var r = cast[ptr TRadixNodeLinear](i.r)
if i.x < ze(r.len):
i.p = ze(r.keys[i.x])
result = r.vals[i.x]
inc(i.x)
else: assert(false)
proc nexti(i: var TRadixIter): int =
result = -1
case i.r.kind
of rnLeafBits:
var r = cast[ptr TRadixNodeLeafBits](i.r)
# iterate over any bit:
for i in 0..high(r.b):
if x.b[i] != 0: # test all bits for zero
for j in 0..BitsPerUnit-1:
if testBit(x.b[i], j):
visit(prefix or i*BitsPerUnit+j)
of rnLeafLinear:
var r = cast[ptr TRadixNodeLeafLinear](i.r)
if i.x < ze(r.len):
result = ze(r.keys[i.x])
inc(i.x)
iterator elements(r: PRadixNode): ByteAddress {.inline.} =
var
a, b, c, d: TRadixIter
init(a, r)
while true:
var x = nextr(a)
if x != nil:
init(b, x)
while true:
var y = nextr(b)
if y != nil:
init(c, y)
while true:
var z = nextr(c)
if z != nil:
init(d, z)
while true:
var q = nexti(d)
if q != -1:
yield a.p shl 24 or b.p shl 16 or c.p shl 8 or q

View File

@@ -6,7 +6,7 @@ discard """
import parsesql, streams, os
var tree = parseSql(newFileStream(getAppDir() / "somesql.sql"), "somesql")
var tree = parseSql(newFileStream(parentDir(currentSourcePath) / "somesql.sql"), "somesql")
discard renderSql(tree)
echo "true"

View File

@@ -219,7 +219,7 @@ block tsplit2:
block tsqlparser:
# Just check that we can parse 'somesql' and render it without crashes.
var tree = parseSql(newFileStream(getAppDir() / "somesql.sql"), "somesql")
var tree = parseSql(newFileStream( parentDir(currentSourcePath) / "somesql.sql"), "somesql")
discard renderSql(tree)

View File

@@ -1,5 +1,5 @@
discard """
output: ""
output: "DONE: tostring.nim"
"""
doAssert "@[23, 45]" == $(@[23, 45])
@@ -115,3 +115,6 @@ block:
var s: string
s.addQuoted a2
doAssert s == "\"fo\\\"o2\""
echo "DONE: tostring.nim"

View File

@@ -1,10 +1,12 @@
discard """
output: '''(name: "hello")
(-1, 0)'''
output: '''
(name: "hello")
(-1, 0)
(FirstName: "James", LastName: "Franco")
'''
"""
# bug #2774, bug #3195
type Foo = object
name: string
@@ -14,7 +16,6 @@ const fooArray = [
echo fooArray[0]
type
Position = object
x, y: int
@@ -34,3 +35,16 @@ const
]
echo offset[1]
# bug #1547
import tables
type Person* = object
FirstName*: string
LastName*: string
let people = {
"001": Person(FirstName: "James", LastName: "Franco")
}.toTable()
echo people["001"]

View File

@@ -70,7 +70,8 @@ block:
# Tests for VM ops
block:
static:
assert "vm" in getProjectPath()
# for joint test, the project path is different
assert "vm" in getProjectPath() or "Nim" in getProjectPath()
let b = getEnv("UNSETENVVAR")
assert b == ""