digitalmars.D - (compiler+dub) flags to print file:line of the running unnitest
- Dejan Lekic (31/31) Mar 12 This is not really a candidate for DIP so I write it here.
- Dejan Lekic (8/8) Mar 12 On Thursday, 12 March 2026 at 19:47:00 UTC, Dejan Lekic wrote:
- Julian Fondren (12/15) Mar 16 If you're using dub, then the testing library need only be a
- Dejan Lekic (4/15) Mar 17 Yes. I am aware of this. My point is - this should be available
This is not really a candidate for DIP so I write it here.
Many, many times in the past I needed to actually find unittest
that is misbehaving and a simple feature would solve my problems
- to be able to tell compiler to generate for each unittest
output in form of `__FILE__ ~ ":" ~ __LINE__` so that I can
figure out which unittest is taking too much time to execute.
Yes, I could use some third-party package but I do not want to
add a new dependency to the project for something as trivial as
this.
Currently when I need this I replace all my `unittest {` with
```d
unittest {
tt("hunt");
```
Where tt is
```d
void tt(string header, string fileName = __FILE__, int
lineNumber = __LINE__)() {
version (UT_HEADER) {
import std.stdio: writeln;
writeln("(", fileName, ":", lineNumber, ") ", header);
}
}
```
Once I find the culprit and fix or remove it, I then change back
everything to unittests without calls to the `tt` template.
Can we _please_ have something like `dub test
--print-ut-line-numbers` ?! Use whatever name you like instead of
`--print-ut-line-numbers`.
Maybe there already is a way to do this, if there is please
enlighten me!
Mar 12
On Thursday, 12 March 2026 at 19:47:00 UTC, Dejan Lekic wrote:
Apologies I was writing in rush. Here is how the `tt` template is
called:
```d
unittest {
tt!"hunt";
```
Anyway, I should not need this at all...
Mar 12
On Thursday, 12 March 2026 at 19:47:00 UTC, Dejan Lekic wrote:Yes, I could use some third-party package but I do not want to add a new dependency to the project for something as trivial as this.If you're using dub, then the testing library need only be a testing dependency, like ``` configuration "release" { targetType "executable" } configuration "unittest" { targetType "library" dependency "silly" version="~>1.1.1" } ```
Mar 16
On Monday, 16 March 2026 at 23:24:29 UTC, Julian Fondren wrote:
If you're using dub, then the testing library need only be a
testing dependency, like
```
configuration "release" {
targetType "executable"
}
configuration "unittest" {
targetType "library"
dependency "silly" version="~>1.1.1"
}
```
Yes. I am aware of this. My point is - this should be available
to us by default, with the default tooling, without the need for
third-party packages.
Mar 17









Dejan Lekic <dejan.lekic gmail.com> 