Jump to page: 1 2
Thread overview
Phobos Unittest
Sep 03, 2021
Per Nordlöw
Sep 04, 2021
H. S. Teoh
Sep 04, 2021
Paul Backus
Sep 04, 2021
Per Nordlöw
Sep 04, 2021
Dennis
Sep 04, 2021
Per Nordlöw
Sep 04, 2021
Per Nordlöw
Sep 04, 2021
Per Nordlöw
Sep 04, 2021
Per Nordlöw
Sep 04, 2021
Per Nordlöw
Sep 04, 2021
Per Nordlöw
Sep 04, 2021
jfondren
Sep 04, 2021
Johan
Sep 04, 2021
Paul Backus
Sep 07, 2021
Per Nordlöw
September 03, 2021

When is a phobos unittest supposed to be qualified with version (StdUnittest)? Ideally, always? I don't see that their current use is consistenly following a rule. If so, is the purpose of its presence to reduce the burden of the compiler when the application using phobos is compiled with -unittest? (edited).

If we were to put a version (StdUnittest) in front of every unittest in phobos (via an automated refactoring of course) would that speed building large applications or tests-suites with the -unittest flag provide they import many/all phobos libraries via, for instance, import std?

When compiling non-phobos modules with -unittest flag, how are the unittest-blocks in imported phobos modules processed by the compiler? Are they only lexed (and parsed) but nothing else?

September 03, 2021
On Fri, Sep 03, 2021 at 11:39:44PM +0000, Per Nordlöw via Digitalmars-d-learn wrote:
> When is a phobos unittest supposed to be qualified with version `(StdUnittest)`? Ideally, always? I don't see that their current use is consistenly following a rule. If so, is the purpose of its presence to reduce the burden of the compiler when the application using phobos is compiled with -unittest? (edited).
[...]

This is related to the bogonity of the current behaviour of -unittest, which compiles *all* unittests of *all* imported modules, even when you're compiling user code that has no interest in Phobos unittests. StdUnittest is a hack introduced to suppress Phobos unittests in user programs.  Theoretically it's supposed to apply to all unittests, but obviously whoever did it failed to cover every case.

It's still up in the air whether or not this should even be fixed. Ideally, we should be fixing the behaviour of -unittest instead of living with this hack.


T

-- 
I'm still trying to find a pun for "punishment"...
September 04, 2021

On Saturday, 4 September 2021 at 00:09:37 UTC, H. S. Teoh wrote:

>

This is related to the bogonity of the current behaviour of -unittest, which compiles all unittests of all imported modules, even when you're compiling user code that has no interest in Phobos unittests.

Well, no; it compiles all unittests of all compiled modules, not all imported modules. So it does not actually include Phobos unittests.

>

StdUnittest is a hack introduced to suppress Phobos unittests in user programs.

The point of StdUnittest is to suppress

  • version (unittest) blocks in Phobos
  • Phobos unittests in the bodies of templates that are instantiated by user code

As Steven Schveighoffer pointed out, Phobos unittests are never included in user code, regardless of whether StdUnittest is used.

September 04, 2021

On Friday, 3 September 2021 at 23:39:44 UTC, Per Nordlöw wrote:

>

When is a phobos unittest supposed to be qualified with version (StdUnittest)?

Almost never.

version (StdUnittest) should be used in Phobos wherever you would normally use a version (unittest) block. It is not for the tests themselves, but for test fixtures and support code.

September 04, 2021

On Saturday, 4 September 2021 at 03:18:01 UTC, Paul Backus wrote:

>

As Steven Schveighoffer [pointed out][1], Phobos unittests are never included in user code, regardless of whether StdUnittest is used.

Yes, but they are lexed and parsed, right?

September 04, 2021

On Saturday, 4 September 2021 at 03:18:01 UTC, Paul Backus wrote:

>

On Saturday, 4 September 2021 at 00:09:37 UTC, H. S. Teoh wrote:

>

This is related to the bogonity of the current behaviour of -unittest, which compiles all unittests of all imported modules, even when you're compiling user code that has no interest in Phobos unittests.

Well, no; it compiles all unittests of all compiled modules, not all imported modules. So it does not actually include Phobos unittests.

[...]

As Steven Schveighoffer [pointed out][1], Phobos unittests are never included in user code, regardless of whether StdUnittest is used.

The "never" is false, https://d.godbolt.org/z/c4oeYM7rG

Unittests inside template code will be added to user code, unless the compiler has determined that the template is already instantiated in Phobos code (the "template culling" that the frontend does, whose behavior is not easily influenced by the programmer).

-Johan

September 04, 2021

On Saturday, 4 September 2021 at 09:42:46 UTC, Per Nordlöw wrote:

>

Yes, but they are lexed and parsed, right?

Right, but that's the case regardless of version(StdUnittest).

September 04, 2021

On Saturday, 4 September 2021 at 12:31:33 UTC, Dennis wrote:

>

Right, but that's the case regardless of version(StdUnittest).

I don't think so. My guess is that version(StdUnittest) does maximum parsing, maybe only lexing. How can one easily determine if this is the fact? Behaviour of pragma(msg)?

September 04, 2021

On Saturday, 4 September 2021 at 12:31:33 UTC, Dennis wrote:

>

On Saturday, 4 September 2021 at 09:42:46 UTC, Per Nordlöw wrote:

>

Yes, but they are lexed and parsed, right?

Right, but that's the case regardless of version(StdUnittest).

Omg. It really seems like it's motivated to do a benchmark with phobos unittests prefixed with

version(StdUnittest)

then. I can make that refactoring in my favorite choice of editor and see the result differ. In terms of binary size, and speed and memory usage of check, build and link time.

September 04, 2021

On Saturday, 4 September 2021 at 12:40:02 UTC, Per Nordlöw wrote:

>

then. I can make that refactoring in my favorite choice of editor and see the result differ. In terms of binary size, and speed and memory usage of check, build and link time.

Automated that is.

If we want this, shall we format as

version (StdUnittest) [QUALIFIER...] unittest

instead of current

version (StdUnittest)
[QUALIFIER...] unittest

?

« First   ‹ Prev
1 2