Skip to content

Commit

Permalink
test suite: rename tests containing 'fail' for easier search in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq committed Nov 26, 2019
1 parent 72237e2 commit 80b508d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion testament/testament.nim
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ proc `$`(x: TResults): string =
proc addResult(r: var TResults, test: TTest, target: TTarget,
expected, given: string, successOrig: TResultEnum) =
# test.name is easier to find than test.name.extractFilename
# A bit hacky but simple and works with tests/testament/tshouldfail.nim
# A bit hacky but simple and works with tests/testament/tshould_not_work.nim
var name = test.name.replace(DirSep, '/')
name.add " " & $target & test.options

Expand Down
20 changes: 10 additions & 10 deletions tests/assert/tfailedassert.nim → tests/assert/tassert2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test5:ok
test6:ok
test7:ok
-1
tfailedassert.nim
tassert2.nim
test8:ok
test9:ok
test10:ok
Expand All @@ -29,17 +29,17 @@ echo("")
try:
doAssert(false, "msg1") # doAssert test
except AssertionError as e:
checkMsg(e.msg, "tfailedassert.nim(30, 11) `false` msg1", "test1")
checkMsg(e.msg, "tassert2.nim(30, 11) `false` msg1", "test1")

try:
assert false, "msg2" # assert test
except AssertionError as e:
checkMsg(e.msg, "tfailedassert.nim(35, 10) `false` msg2", "test2")
checkMsg(e.msg, "tassert2.nim(35, 10) `false` msg2", "test2")

try:
assert false # assert test with no msg
except AssertionError as e:
checkMsg(e.msg, "tfailedassert.nim(40, 10) `false` ", "test3")
checkMsg(e.msg, "tassert2.nim(40, 10) `false` ", "test3")

try:
let a = 1
Expand Down Expand Up @@ -80,12 +80,12 @@ block:
proc bar: int =
# local overrides that are active only in this proc
onFailedAssert(msg):
checkMsg(msg, "tfailedassert.nim(85, 11) `false` first assertion from bar", "test6")
checkMsg(msg, "tassert2.nim(85, 11) `false` first assertion from bar", "test6")

assert(false, "first assertion from bar")

onFailedAssert(msg):
checkMsg(msg, "tfailedassert.nim(91, 11) `false` second assertion from bar", "test7")
checkMsg(msg, "tassert2.nim(91, 11) `false` second assertion from bar", "test7")
return -1

assert(false, "second assertion from bar")
Expand All @@ -98,7 +98,7 @@ block:
except:
let e = EMyError(getCurrentException())
echo e.lineinfo.filename
checkMsg(e.msg, "tfailedassert.nim(77, 11) `false` assertion from foo", "test8")
checkMsg(e.msg, "tassert2.nim(77, 11) `false` assertion from foo", "test8")

block: ## checks for issue https://github.com/nim-lang/Nim/issues/8518
template fun(a: string): string =
Expand All @@ -109,19 +109,19 @@ block: ## checks for issue https://github.com/nim-lang/Nim/issues/8518
doAssert fun("foo1") == fun("foo2"), "mymsg"
except AssertionError as e:
# used to expand out the template instantiaiton, sometimes filling hundreds of lines
checkMsg(e.msg, """tfailedassert.nim(109, 14) `fun("foo1") == fun("foo2")` mymsg""", "test9")
checkMsg(e.msg, """tassert2.nim(109, 14) `fun("foo1") == fun("foo2")` mymsg""", "test9")

block: ## checks for issue https://github.com/nim-lang/Nim/issues/9301
try:
doAssert 1 + 1 == 3
except AssertionError as e:
# used to const fold as false
checkMsg(e.msg, "tfailedassert.nim(116, 14) `1 + 1 == 3` ", "test10")
checkMsg(e.msg, "tassert2.nim(116, 14) `1 + 1 == 3` ", "test10")

block: ## checks AST isnt' transformed as it used to
let a = 1
try:
doAssert a > 1
except AssertionError as e:
# used to rewrite as `1 < a`
checkMsg(e.msg, "tfailedassert.nim(124, 14) `a > 1` ", "test11")
checkMsg(e.msg, "tassert2.nim(124, 14) `a > 1` ", "test11")
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ discard """
"""

const expected = """
tfailedassert_stacktrace.nim(35) tfailedassert_stacktrace
tfailedassert_stacktrace.nim(34) foo
assertions.nim(*) failedAssertImpl
assertions.nim(*) raiseAssert
fatal.nim(*) sysFatal"""
tassert_c.nim(35) tassert_c
tassert_c.nim(34) foo
assertions.nim(27) failedAssertImpl
assertions.nim(20) raiseAssert
fatal.nim(39) sysFatal"""

proc tmatch(x, p: string): bool =
var i = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ test2:ok
import testhelper

onFailedAssert(msg):
checkMsg(msg, "tfaileddoassert.nim(15, 9) `a == 2` foo", "test1")
checkMsg(msg, "tdoassert.nim(15, 9) `a == 2` foo", "test1")

var a = 1
doAssert(a == 2, "foo")

onFailedAssert(msg):
checkMsg(msg, "tfaileddoassert.nim(20, 10) `a == 3` ", "test2")
checkMsg(msg, "tdoassert.nim(20, 10) `a == 3` ", "test2")

doAssert a == 3
File renamed without changes.
File renamed without changes.

0 comments on commit 80b508d

Please sign in to comment.