assertions: fixes #11545 (#11605)

* assertions: properly fix #11545

* tests/assert: enable excessiveStackTrace

* tests/assert: add test case for #11545

* tfailedassert_stacktrace: disable excessiveStackTrace

* assertions: weird workaround for failing tests

This fixes megatest on *nix, but have no idea why

(cherry picked from commit 2c10b246ec)
This commit is contained in:
alaviss
2019-07-01 11:19:07 +00:00
committed by narimiran
parent e6c963259c
commit eb295bbb7d
5 changed files with 22 additions and 7 deletions

View File

@@ -27,13 +27,15 @@ proc failedAssertImpl*(msg: string) {.raises: [], tags: [].} =
Hide(raiseAssert)(msg)
template assertImpl(cond: bool, msg: string, expr: string, enabled: static[bool]) =
const loc = $instantiationInfo(-1, true)
const
loc = instantiationInfo(fullPaths = compileOption("excessiveStackTrace"))
ploc = $loc
bind instantiationInfo
mixin failedAssertImpl
when enabled:
{.line: instantiationInfo(fullPaths = compileOption("excessiveStackTrace")).}:
{.line: loc.}:
if not cond:
failedAssertImpl(loc & " `" & expr & "` " & msg)
failedAssertImpl(ploc & " `" & expr & "` " & msg)
template assert*(cond: untyped, msg = "") =
## Raises ``AssertionError`` with `msg` if `cond` is false. Note