RejectedSoftware Forums

Sign up

Optimized builds for dub test

How do you build an optimized build of the unit tests? That is, I want to do a dub build equivalent to dmd -unittest -O -inline (possibly also -debug).

dub test --build=release and dub test --build=release-debug don't include the -unittest flag, and therefore don't actually run any unit tests. The other build values don't seem relevant or don't optimize.

Re: Optimized builds for dub test

Am 16.10.2017 um 16:21 schrieb Luís Marques:

How do you build an optimized build of the unit tests? That is, I want to do a dub build equivalent to dmd -unittest -O -inline (possibly also -debug).

dub test --build=release and dub test --build=release-debug don't include the -unittest flag, and therefore don't actually run any unit tests. The other build values don't seem relevant or don't optimize.

There are two possibilities. Either define DFLAGS="-unittest -O -inline"
and then run "dub test", or define a custom build type in the package
recipe to either override "unittest", or to define a new
"unittest-release" one (json/sdlang).

Re: Optimized builds for dub test

On Mon, 16 Oct 2017 17:37:32 +0200, Sönke Ludwig wrote:

There are two possibilities. Either define DFLAGS="-unittest -O -inline"
and then run "dub test", or define a custom build type in the package
recipe to either override "unittest", or to define a new
"unittest-release" one ([json][1]/[sdlang][2]).

Mmm, I think this should be possible from the command line, without messing with the package recipe, and without low-level flags override.

BTW, regarding defining various configurations and unit testing, I have a configuration named "benchmark" for which "targetName" works fine. But in my "unittest" configuration the "targetName" seems to be ignored. Is this a bug?

    "configurations":
    [
        {
            "name": "unittest",
            "targetName": "totally-ignored"
        },
        {
            "name": "benchmark",
            "targetName": "some-executable",
            "targetType": "executable"
        },
    ]

Re: Optimized builds for dub test

On 2017-10-16 16:21, Luís Marques wrote:

How do you build an optimized build of the unit tests? That is, I want to do a dub build equivalent to dmd -unittest -O -inline (possibly also -debug).

dub test --build=release and dub test --build=release-debug don't include the -unittest flag, and therefore don't actually run any unit tests. The other build values don't seem relevant or don't optimize.

You can create a configuration named "unittest" to override the default
one that is used when invoking "dub test". But then you would need to
redo everything the default configuration is doing.

/Jacob Carlborg