Bug 20910 – Default unittest runner reports wrong unittest count

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-06-08T21:42:34Z
Last change time
2020-06-16T12:11:32Z
Keywords
bootcamp
Assigned to
No Owner
Creator
hsteoh

Comments

Comment #0 by hsteoh — 2020-06-08T21:42:34Z
Code: ------- import std.stdio; unittest { writeln("x"); } unittest { writeln("y"); } unittest { writeln("z"); } ------- Compiler invocation: ------- dmd -unittest -main -run test.d ------- Output: ------- x y z 1 unittests passed ------- Clearly, all 3 unittests ran; yet the default test runner reports only 1 unittest. This is misleading, and gives the wrong impression that some unittests were not run. Expected output: -------- x y z 3 unittests passed --------
Comment #1 by moonlightsentinel — 2020-06-09T00:22:39Z
The message is wrong, it shows how many modules were tested, not the number of unittests. That number is probably not available in the current implementation which relies on ModuleInfo, see https://github.com/dlang/druntime/blob/435ae8a21034ef50fa4769e3aaba5778dbc76557/src/core/runtime.d#L602-L617
Comment #2 by dlang-bot — 2020-06-09T00:49:28Z
@quickfur created dlang/druntime pull request #3129 "Fix issue 20910: fix misleading unittest runner messages." mentioning this issue: - Issue 20910: fix misleading unittest runner messages. The number returned by runModuleUnitTests is not the number of tests, but the number of modules tested. https://github.com/dlang/druntime/pull/3129
Comment #3 by dlang-bot — 2020-06-16T12:11:32Z
dlang/druntime pull request #3129 "Fix issue 20910: fix misleading unittest runner messages." was merged into master: - 209ce9b0c18ba27519f900ca31947ee3bf1e0f15 by H. S. Teoh: Fix issue 20910: fix misleading unittest runner messages. The number returned by runModuleUnitTests is not the number of tests, but the number of modules tested. https://github.com/dlang/druntime/pull/3129