Skip to content

unittest2 does not provide correct stack traces on Defect error. #56

@cheatfate

Description

@cheatfate

If you put this source into any module with some name, this module name will never appear in stack trace

Compiler

Nim Compiler Version 2.2.4 [Windows: amd64]
Compiled at 2025-04-23
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: f7145dd26efeeeb6eeae6fff649db244d81b212d
active boot switches: -d:release

Source

when isMainModule:
  import unittest2

  suite "SUITE":
    test "TEST 1":
      const data = [0, 1, 2]
      for index in 0 ..< 4:
        check data[index] == index

Example output on Windows:

SUITE F (0.00s)
======
  A:\Projects\testtrace.exe "SUITE::TEST 1"
------
A:\Projects\nimbus-eth2\vendor\nim-unittest2\unittest2.nim(1170) testtrace
A:\Projects\nimbus-eth2\vendor\nim-unittest2\unittest2.nim(1097) runDirect
A:\Projects\nimbus-eth2\vendor\nim-unittest2\unittest2.nim(1216) runTest`gensym3
A:\Projects\nimbus-eth2\vendor\nimbus-build-system\vendor\Nim\lib\system\fatal.nim(53) sysFatal

    Unhandled defect: index 3 not in 0 .. 2 [IndexDefect]

  [FAILED ] (  0.00s) TEST 1

(0.00s)   SUITE

[Summary] 1 tests run (0.00s): 0 OK, 1 FAILED, 0 SKIPPED
Error: execution of an external program failed: 'A:\Projects\testtrace.exe'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions