D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20910 - Default unittest runner reports wrong unittest count
Summary: Default unittest runner reports wrong unittest count
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords: bootcamp
Depends on:
Blocks:
 
Reported: 2020-06-08 21:42 UTC by hsteoh
Modified: 2020-06-16 12:11 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description hsteoh 2020-06-08 21:42:34 UTC
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 moonlightsentinel 2020-06-09 00:22:39 UTC
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 Dlang Bot 2020-06-09 00:49:28 UTC
@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 Dlang Bot 2020-06-16 12:11:32 UTC
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