make run the default action of a test in tester

This commit is contained in:
Arne Döring 2018-11-13 15:21:14 +01:00 • committed by Araq
commit 031bfdec6f
50 changed files with 313 additions and 46 deletions

View file

@ -531,6 +531,7 @@ proc processCategory(r: var TResults, cat: Category, options: string) =
else: else:
var testsRun = 0 var testsRun = 0
for name in os.walkFiles("tests" & DirSep &.? cat.string / "t*.nim"): for name in os.walkFiles("tests" & DirSep &.? cat.string / "t*.nim"):
echo name
testSpec r, makeTest(name, options, cat) testSpec r, makeTest(name, options, cat)
inc testsRun inc testsRun
if testsRun == 0: if testsRun == 0:

View file

@ -10,18 +10,18 @@
import parseutils, strutils, os, osproc, streams, parsecfg import parseutils, strutils, os, osproc, streams, parsecfg
var compilerPrefix* = "compiler" / "nim " var compilerPrefix* = "compiler" / "nim"
let isTravis* = existsEnv("TRAVIS") let isTravis* = existsEnv("TRAVIS")
let isAppVeyor* = existsEnv("APPVEYOR") let isAppVeyor* = existsEnv("APPVEYOR")
proc cmdTemplate*(): string = proc cmdTemplate*(): string =
compilerPrefix & "$target --lib:lib --hints:on -d:testing --nimblePath:tests/deps $options $file" compilerPrefix & " $target --lib:lib --hints:on -d:testing --nimblePath:tests/deps $options $file"
type type
TTestAction* = enum TTestAction* = enum
actionCompile = "compile"
actionRun = "run" actionRun = "run"
actionCompile = "compile"
actionReject = "reject" actionReject = "reject"
actionRunNoSpec = "runNoSpec" actionRunNoSpec = "runNoSpec"
TResultEnum* = enum TResultEnum* = enum
@ -186,7 +186,7 @@ proc parseSpec*(filename: string): TSpec =
raise newException(ValueError, "cannot interpret as a bool: " & e.value) raise newException(ValueError, "cannot interpret as a bool: " & e.value)
of "cmd": of "cmd":
if e.value.startsWith("nim "): if e.value.startsWith("nim "):
result.cmd = compilerPrefix & e.value[4..^1] result.cmd = compilerPrefix & e.value[3..^1]
else: else:
result.cmd = e.value result.cmd = e.value
of "ccodecheck": result.ccodeCheck = e.value of "ccodecheck": result.ccodeCheck = e.value

View file

@ -469,7 +469,7 @@ proc main() =
of "targets": of "targets":
targetsStr = p.val.string targetsStr = p.val.string
targets = parseTargets(targetsStr) targets = parseTargets(targetsStr)
of "nim": compilerPrefix = p.val.string & " " of "nim": compilerPrefix = p.val.string
else: quit Usage else: quit Usage
p.next() p.next()
if p.kind != cmdArgument: quit Usage if p.kind != cmdArgument: quit Usage

View file

@ -63,5 +63,3 @@ when defined(ssl):
assert msgCount == swarmSize * messagesToSend assert msgCount == swarmSize * messagesToSend
echo msgCount echo msgCount

View file

@ -1,3 +1,8 @@
discard """
action: compile
"""
# XXX: action should be run!
import asyncdispatch import asyncdispatch
proc completeOnReturn(fut: FutureVar[string], x: bool) {.async.} = proc completeOnReturn(fut: FutureVar[string], x: bool) {.async.} =
@ -44,4 +49,3 @@ proc main() {.async.} =
waitFor main() waitFor main()

View file

@ -1,3 +1,9 @@
discard """
output: '''
(v: 3)
'''
"""
import typetraits import typetraits
type type
A[T] = ref object A[T] = ref object

View file

@ -1,6 +1,7 @@
discard """ discard """
targets: "c cpp js" targets: "c cpp js"
ccodecheck: "'HELLO'" ccodecheck: "'HELLO'"
action: compile
""" """
when defined(JS): when defined(JS):

View file

@ -1,4 +1,10 @@
discard """
output: '''
2
2
2
'''
"""
# bug 2659 # bug 2659

View file

@ -1,3 +1,7 @@
discard """
action: compile
"""
# bug #2233 # bug #2233
type MalType = object type MalType = object
fun: proc: MalType fun: proc: MalType

View file

@ -1,3 +1,10 @@
discard """
output: '''
123
baz
'''
"""
# bug #5147 # bug #5147
proc foo[T](t: T) = proc foo[T](t: T) =

View file

@ -1,4 +1,9 @@
discard """
output: '''
vidx 18
0,0
'''
"""
# bug #4626 # bug #4626
var foo: (int, array[1, int]) # Tuple must be of length > 1 var foo: (int, array[1, int]) # Tuple must be of length > 1

View file

@ -1,3 +1,7 @@
discard """
action: compile
"""
# bug #3313 # bug #3313
import unittest, sugar import unittest, sugar
{.experimental: "notnil".} {.experimental: "notnil".}

View file

@ -1,3 +1,7 @@
discard """
action: compile
"""
type type
Byte* = uint8 Byte* = uint8
Bytes* = seq[Byte] Bytes* = seq[Byte]

View file

@ -1,5 +1,7 @@
discard """
output: "16777215A"
"""
import colors import colors
echo int32(colWhite), 'A' echo int32(colWhite), 'A'

View file

@ -1,4 +1,36 @@
# bug #3799 # bug #3799
discard """
output: '''
00000000000000000000000000000000000000000
00000000000001111111111111110000000000000
00000000001111111111111111111110000000000
00000000111111111111111111111111100000000
00000011111222222221111111111111111000000
00000111122222222222221111111111111100000
00001112222333333459432111111111111110000
00011122355544344463533221111111111111000
00111124676667556896443322211111111111100
00111126545561919686543322221111111111100
01111123333346967807554322222211111111110
01111122233334455582015332222221111111110
01111122222333344567275432222222111111110
01111112222222334456075443222222211111110
01111111222222233459965444332222221111110
01111111122222223457486554433322222111110
01111111112222222367899655543333322111110
01111111111122222344573948465444332111110
00111111111112222334467987727667762111100
00111111111111122233474655557836432111100
00011111111111112233 454433334 4321111000
00001111111111111122354333322222211110000
00000111111111111111222222222222111100000
00000001111111111111111122222111110000000
00000000111111111111111111111111100000000
00000000000111111111111111111100000000000
00000000000000111111111111100000000000000
'''
"""
import macros import macros
@ -37,9 +69,9 @@ iterator stepIt[T](start, step: T, iterations: int): T =
let c = (0.36237, 0.32) let c = (0.36237, 0.32)
for y in stepIt(2.0, -0.0375, 107): for y in stepIt(2.0, -0.0375 * 4, 107 div 4):
var row = "" var row = ""
for x in stepIt(-2.0, 0.025, 160): for x in stepIt(-2.0, 0.025 * 4, 160 div 4):
#let n = julia((x, y), c, 4.0, nmax) ### this works #let n = julia((x, y), c, 4.0, nmax) ### this works
let n = dendriteFractal((x, y), 4.0, nmax) let n = dendriteFractal((x, y), 4.0, nmax)
if n < nmax: if n < nmax:

View file

@ -1,6 +1,7 @@
discard """ discard """
file: "tgenscript.nim" file: "tgenscript.nim"
target: "c" target: "c"
action: compile
""" """
echo "--genscript" echo "--genscript"

View file

@ -1,3 +1,6 @@
discard """
action: compile
"""
# bug #3669 # bug #3669
@ -10,4 +13,3 @@ type
var g: G[string] var g: G[string]
echo g.rnodes["foo"] echo g.rnodes["foo"]

View file

@ -1,3 +1,13 @@
discard """
output: '''
312
1000000
1000000
500000
0
'''
"""
import strutils import strutils
type type

View file

@ -1,7 +1,9 @@
discard """
output: 100
"""
var funcs: seq[proc (): int {.nimcall.}] = @[] var funcs: seq[proc (): int {.nimcall.}] = @[]
for i in 0..10: for i in 0..10:
funcs.add((proc (): int = return i * i)) funcs.add((proc (): int = return i * i))
echo(funcs[3]()) echo(funcs[3]())

View file

@ -1,8 +1,14 @@
discard """ discard """
nimout: ''' nimout: '''
t8314.nim(8, 7) Hint: BEGIN [User] t8314.nim(14, 7) Hint: BEGIN [User]
t8314.nim(19, 7) Hint: END [User] t8314.nim(25, 7) Hint: END [User]
''' '''
output: '''
1
1
1
'''
""" """
{.hint: "BEGIN".} {.hint: "BEGIN".}

View file

@ -15,4 +15,4 @@ iterator fields(a = (0,0), b = (h-1,w-1)): auto =
yield (y,x) yield (y,x)
for y,x in fields(): for y,x in fields():
stdout.write disp[univ(x, y)] doAssert disp[univ(x, y)] == disp[Tree]

View file

@ -1,3 +1,16 @@
discard """
output: '''
testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest2!test3?hi
what's
your
name
hi
what's
your
name
'''
"""
# Test the new iterators # Test the new iterators
iterator xrange(fromm, to: int, step = 1): int = iterator xrange(fromm, to: int, step = 1): int =

View file

@ -1,3 +1,18 @@
discard """
output: '''
3 4
4 5
5 6
6 7
7 8
(x: 3, y: 4)
(x: 4, y: 5)
(x: 5, y: 6)
(x: 6, y: 7)
(x: 7, y: 8)
'''
"""
iterator xrange(fromm, to: int, step = 1): tuple[x, y: int] = iterator xrange(fromm, to: int, step = 1): tuple[x, y: int] =
var a = fromm var a = fromm
@ -10,4 +25,3 @@ for a, b in xrange(3, 7):
for tup in xrange(3, 7): for tup in xrange(3, 7):
echo tup echo tup

View file

@ -11,6 +11,3 @@ iterator iterAndZero(a: var openArray[int]): int =
var x = [[1, 2, 3], [4, 5, 6]] var x = [[1, 2, 3], [4, 5, 6]]
for y in iterAndZero(x[0]): write(stdout, $y) for y in iterAndZero(x[0]): write(stdout, $y)
#OUT 123 #OUT 123

View file

@ -1,3 +1,14 @@
discard """
output: '''
@[@[1.0, 2.0], @[3.0, 4.0]]
perm: 10.0 det: -2.0
@[@[1.0, 2.0, 3.0, 4.0], @[4.0, 5.0, 6.0, 7.0], @[7.0, 8.0, 9.0, 10.0], @[10.0, 11.0, 12.0, 13.0]]
perm: 29556.0 det: 0.0
@[@[0.0, 1.0, 2.0, 3.0, 4.0], @[5.0, 6.0, 7.0, 8.0, 9.0], @[10.0, 11.0, 12.0, 13.0, 14.0], @[15.0, 16.0, 17.0, 18.0, 19.0], @[20.0, 21.0, 22.0, 23.0, 24.0]]
perm: 6778800.0 det: 0.0
'''
"""
import sequtils, sugar import sequtils, sugar

View file

@ -1,5 +1,9 @@
discard """ discard """
ccodecheck: "!@('{' \\s* 'NI HEX3Astate;' \\s* '}')" ccodecheck: "!@('{' \\s* 'NI HEX3Astate;' \\s* '}')"
output: '''
a1 10
a1 9
'''
""" """
# bug #1803 # bug #1803
@ -26,6 +30,6 @@ var
z: TaskFn z: TaskFn
discard x() discard x()
z = x #shallowCopy(z, x) shallowCopy(z, x)
z = y #shallowCopy(z, y) shallowCopy(z, y)
discard x() discard x()

View file

@ -1,5 +1,6 @@
discard """
action: compile
"""
import os import os

View file

@ -1,6 +1,8 @@
discard """ discard """
msg: '''ObjectTy(Sym(Model), RecList(Sym(name), Sym(password))) output: '''
BracketExpr(Sym(typeDesc), Sym(User))''' (ObjectTy (Empty) (Sym "Model") (RecList (Sym "name") (Sym "password")))
(BracketExpr (Sym "typeDesc") (Sym "User"))
'''
""" """
import strutils, macros import strutils, macros

View file

@ -1,3 +1,35 @@
discard """
output: '''
############
#### gt ####
############
gt(Foo): typeDesc[Foo]
gt(Bar): typeDesc[Bar]
gt(Baz): typeDesc[int]
gt(foo): distinct[int]
gt(bar): distinct[int]
gt(baz): int, int
gt(v): seq[int]
gt(vv): seq[float]
gt(t): distinct[tuple[int, int]]
gt(tt): distinct[tuple[float, float]]
gt(s): distinct[tuple[int, int]]
#############
#### gt2 ####
#############
gt2(Foo): Foo
gt2(Bar): Bar
gt2(Baz): Baz
gt2(foo): Foo
gt2(bar): Bar
gt2(baz): Baz
gt2(v): seq[int]
gt2(vv): seq[float]
gt2(t): MyType[system.int]
gt2(tt): MyType[system.float]
gt2(s): MySimpleType
'''
"""
import macros, typetraits import macros, typetraits

View file

@ -1,3 +1,11 @@
discard """
output: '''
123
Hallo Welt
Hallo Welt
'''
"""
import macros import macros
macro mac(): untyped = macro mac(): untyped =

View file

@ -1,4 +1,15 @@
discard """
output:'''
void
(Field0: "string", Field1: "string")
1 mod 7
@[2, 2, 2, 2, 2]
impl 2 called
asd
Foo
Bar
'''
"""
import typetraits, macros import typetraits, macros
@ -145,6 +156,3 @@ block t3338:
var t2 = Bar[int32]() var t2 = Bar[int32]()
t2.add() t2.add()
doAssert t2.x == 5 doAssert t2.x == 5

View file

@ -1,3 +1,13 @@
discard """
output: '''
proc Base
proc Child
method Base
yield Base
yield Child
'''
"""
import typetraits import typetraits
type type

View file

@ -1,3 +0,0 @@
# test the new endian magic
writeLine(stdout, repr(system.cpuEndian))

View file

@ -1,7 +1,6 @@
#
import times, os import times, os
var start = epochTime() var start = epochTime()
os.sleep(1000) os.sleep(1000)
let diff = abs(epochTime() - start - 1.0)
echo epochTime() - start #OUT 1000 doAssert diff < 0.005

View file

@ -1,4 +1,8 @@
# Hallo discard """
action: compile
"""
# noted this seems to be an old test file designed for manual testing.
import import
os, strutils, macros os, strutils, macros

View file

@ -1 +1,5 @@
discard """
action: compile
"""
import treorder import treorder

View file

@ -1,9 +1,16 @@
discard """
output: '''
abc
xyz
B.foo
'''
"""
# bug #1595, #1612 # bug #1595, #1612
import mexport2a import mexport2a
proc main() = proc main() =
echo "Import Test, two lines should follow. One with abc and one with xyz."
printAbc() printAbc()
printXyz() printXyz()

View file

@ -1,3 +1,7 @@
discard """
action: compile
"""
# Covariance is not type safe: # Covariance is not type safe:
type type
@ -14,4 +18,3 @@ proc bp(x: var TB) = x.b[high(x.b)] = -1
var f = cast[proc (x: var TA) {.nimcall.}](bp) var f = cast[proc (x: var TA) {.nimcall.}](bp)
var a: TA var a: TA
f(a) # bp expects a TB, but gets a TA f(a) # bp expects a TB, but gets a TA

View file

@ -1,3 +1,7 @@
discard """
output: "[Suite] object basic methods"
"""
import unittest import unittest
type Obj = object type Obj = object

View file

@ -1,3 +1,15 @@
discard """
sortoutput: true
output: '''
(x: 0.0)
(x: 0.0)
(x: 0.0)
test
test
test
'''
"""
# bug #2257 # bug #2257
import threadpool import threadpool

View file

@ -1,3 +1,11 @@
discard """
output: '''
3
25
40
50
'''
"""
import threadpool, os import threadpool, os

View file

@ -1,3 +1,7 @@
discard """
output: "90"
"""
when false: when false:
template lock(a, b: ptr Lock; body: stmt) = template lock(a, b: ptr Lock; body: stmt) =

View file

@ -1,3 +1,8 @@
discard """
output: '''
done999 999
'''
"""
import threadpool import threadpool

View file

@ -1,5 +1,6 @@
discard """ discard """
ccodeCheck: "\\i @'deepCopy(' .*" ccodeCheck: "\\i @'deepCopy(' .*"
action: compile
""" """
# bug #2286 # bug #2286

View file

@ -1,3 +1,24 @@
discard """
output: '''
Hello 1
Hello 2
Hello 3
Hello 4
Hello 5
Hello 6
0
1
2
3
4
5
6
7
8
9
'''
"""
# bug #2287 # bug #2287
import threadPool import threadPool

View file

@ -1,5 +1,6 @@
discard """ discard """
ccodeCheck: "\\i @'__attribute__((noreturn))' .*" ccodeCheck: "\\i @'__attribute__((noreturn))' .*"
action: compile
""" """
proc noret1*(i: int) {.noreturn.} = proc noret1*(i: int) {.noreturn.} =

View file

@ -1,6 +1,3 @@
discard """
"""
import os import os
import osproc import osproc
import parseopt2 import parseopt2
@ -13,7 +10,6 @@ if argv == @[]:
doAssert execShellCmd(getAppFilename() & " \"foo bar\" --aa:bar=a --a=c:d --ab -c --a[baz]:doo") == 0 doAssert execShellCmd(getAppFilename() & " \"foo bar\" --aa:bar=a --a=c:d --ab -c --a[baz]:doo") == 0
else: else:
let f = toSeq(getopt()) let f = toSeq(getopt())
echo f.repr
doAssert f[0].kind == cmdArgument and f[0].key == "foo bar" and f[0].val == "" doAssert f[0].kind == cmdArgument and f[0].key == "foo bar" and f[0].val == ""
doAssert f[1].kind == cmdLongOption and f[1].key == "aa" and f[1].val == "bar=a" doAssert f[1].kind == cmdLongOption and f[1].key == "aa" and f[1].val == "bar=a"
doAssert f[2].kind == cmdLongOption and f[2].key == "a=c" and f[2].val == "d" doAssert f[2].kind == cmdLongOption and f[2].key == "a=c" and f[2].val == "d"

View file

@ -1,3 +1,10 @@
discard """
output: '''
arg
arg
'''
"""
import sugar import sugar
@ -6,4 +13,3 @@ template tempo(s) =
tempo((s: string)->auto => echo(s)) tempo((s: string)->auto => echo(s))
tempo((s: string) => echo(s)) tempo((s: string) => echo(s))

0
tests/vm/tgorge.sh Normal file → Executable file
View file

0
tests/vm/tgorgeex.sh Normal file → Executable file
View file