Thread overview
Unittests not firing?
Jun 11, 2021
Mike Brown
Jun 11, 2021
rikki cattermole
Jun 11, 2021
Mike Brown
Jun 11, 2021
H. S. Teoh
Jun 11, 2021
Mike Brown
Jun 11, 2021
H. S. Teoh
Jun 11, 2021
H. S. Teoh
Jun 12, 2021
Mike Brown
June 11, 2021

Hi all,

I'm testing the unittest features of D, and having some issues. I only seem able to fire one unittest, e.g.

module test;

unittest {
	assert(0);
}

unittest {
	assert(0);
}

If I run,
rdmd -g -unittest -main "test.d"

It returns,
1/1 unittests FAILED
test.d(4): [unittest] unittest failure

Im using rdmd as I want a simple command that will pull in dependancies to run these tests. Am I right in using rdmd?

I have also tried ldc2 and getting the same results. What am I missing?

Kind regards,
Mike Brown

June 12, 2021
rdmd -main -unittest file.d

```d
import std.stdio;

unittest
{
    writeln("first");
}

unittest
{
    writeln("second");
    assert(0);
}
```

Output:

```
first
second
onlineapp.d(11): [unittest] unittest failure
1/1 modules FAILED unittests
```

The first assert to execute should kill the rest of the unittests.
June 11, 2021
On Friday, 11 June 2021 at 15:13:17 UTC, rikki cattermole wrote:
>
> rdmd -main -unittest file.d
>
> ```d
> import std.stdio;
>
> unittest
> {
>     writeln("first");
> }
>
> unittest
> {
>     writeln("second");
>     assert(0);
> }
> ```
>
> Output:
>
> ```
> first
> second
> onlineapp.d(11): [unittest] unittest failure
> 1/1 modules FAILED unittests
> ```
>
> The first assert to execute should kill the rest of the unittests.

Right OK, mine says 1/1 unittests failed - but this should say Modules?

I will interpret it as Modules, ty!
June 11, 2021
On Fri, Jun 11, 2021 at 03:20:49PM +0000, Mike Brown via Digitalmars-d-learn wrote:
> On Friday, 11 June 2021 at 15:13:17 UTC, rikki cattermole wrote:
[...]
> Right OK, mine says 1/1 unittests failed - but this should say Modules?
> 
> I will interpret it as Modules, ty!

This is a bug that was fixed in more recent versions of druntime. Basically it was a misleading message because the count is the number of modules, not the number of individual tests.


T

-- 
Дерево держится корнями, а человек - друзьями.
June 11, 2021
On Friday, 11 June 2021 at 16:28:48 UTC, H. S. Teoh wrote:
> On Fri, Jun 11, 2021 at 03:20:49PM +0000, Mike Brown via Digitalmars-d-learn wrote:
>> On Friday, 11 June 2021 at 15:13:17 UTC, rikki cattermole wrote:
> [...]
>> Right OK, mine says 1/1 unittests failed - but this should say Modules?
>> 
>> I will interpret it as Modules, ty!
>
> This is a bug that was fixed in more recent versions of druntime. Basically it was a misleading message because the count is the number of modules, not the number of individual tests.
>
>
> T

Hi T,

OK, thank you - Im using LDC 1.27.0-beta1 which looks to be the newest I can find, is there a way to update the druntime manually?

I've problems with exceptions that might be related to me being out of date?

Kind regards,
Mike Brown
June 11, 2021
On Fri, Jun 11, 2021 at 08:30:28PM +0000, Mike Brown via Digitalmars-d-learn wrote:
> On Friday, 11 June 2021 at 16:28:48 UTC, H. S. Teoh wrote:
> > On Fri, Jun 11, 2021 at 03:20:49PM +0000, Mike Brown via Digitalmars-d-learn wrote:
> > > On Friday, 11 June 2021 at 15:13:17 UTC, rikki cattermole wrote:
> > [...]
> > > Right OK, mine says 1/1 unittests failed - but this should say Modules?
> > > 
> > > I will interpret it as Modules, ty!
> > 
> > This is a bug that was fixed in more recent versions of druntime. Basically it was a misleading message because the count is the number of modules, not the number of individual tests.
[...]
> OK, thank you - Im using LDC 1.27.0-beta1 which looks to be the newest I can find, is there a way to update the druntime manually?

Huh, that doesn't look right. This was fixed since June last year, so it *should* have made it into the latest compiler releases already. Unless this one was missed somehow (but I doubt it).


> I've problems with exceptions that might be related to me being out of date?
[...]

Are you sure your druntime is up-to-date with your LDC version?  One thing to beware of is stale copies of druntime lying around that the compiler picked up instead of the latest version.  This may lead to subtle discrepancies that cause strange runtime problems like runtime crashes or other odd behaviours.  (Though generally this shouldn't be a problem with LDC, it's more commonly a problem with DMD installations.)


T

-- 
If the comments and the code disagree, it's likely that *both* are wrong. -- Christopher
June 11, 2021
On Fri, Jun 11, 2021 at 02:05:31PM -0700, H. S. Teoh wrote: [...]
> Huh, that doesn't look right. This was fixed since June last year, so it *should* have made it into the latest compiler releases already. Unless this one was missed somehow (but I doubt it).
[...]

Just checked on LDC 1.26.0, the message has already been fixed.  I seriously doubt the beta would have the fix reverted somehow; this seems to be a sign that your druntime is indeed out-of-sync with your compiler.  You should check your system for stray stale copies of druntime.


T

-- 
Caffeine underflow. Brain dumped.
June 12, 2021
On Friday, 11 June 2021 at 21:10:32 UTC, H. S. Teoh wrote:
> On Fri, Jun 11, 2021 at 02:05:31PM -0700, H. S. Teoh wrote: [...]
>> Huh, that doesn't look right. This was fixed since June last year, so it *should* have made it into the latest compiler releases already. Unless this one was missed somehow (but I doubt it).
> [...]
>
> Just checked on LDC 1.26.0, the message has already been fixed.
>  I seriously doubt the beta would have the fix reverted somehow; this seems to be a sign that your druntime is indeed out-of-sync with your compiler.  You should check your system for stray stale copies of druntime.
>
>
> T

Hi Toeh

Thank you, found the old druntime and this is now fixed. Thanks again!