RejectedSoftware Forums

Sign up

How to run unittests but compiled with release flags

Hi,

I want to run my unit-tests (std. dlang unit-tests) compiled with the
same flags as a releasebuild. How do I do this with dub using dub.sdl?

Thanks in advance,
Christian

Re: How to run unittests but compiled with release flags

On Sat, 15 Oct 2016 19:30:38 +0200, Christian Köstlin wrote:

Hi,

I want to run my unit-tests (std. dlang unit-tests) compiled with the
same flags as a releasebuild. How do I do this with dub using dub.sdl?

Thanks in advance,
Christian

The easiest way would be to add this:

buildType "unittest" {
  buildOptions "releaseMode" "optimize" "inline" "unittest" "debugInfo"
}

Alternatively, you could also add a build type with a custon name such as "unittest-release" and then run dub test -b unittest-release.

Re: How to run unittests but compiled with release flags

On 16/10/16 11:35, Sönke Ludwig wrote:

buildType "unittest" {

  buildOptions "releaseMode" "optimize" "inline" "unittest" "debugInfo"
}

Thanks Sönke,

this put me on the right path!https://code.dlang.org/package-format?lang=json#build-types I could get
it working! Its tricky to get the buildType and buildOptions right by
spelling. The buildOptions need unittests!

buildType "unittest" {
buildOptions "releaseMode" "optimize" "inline" "unittests"
}

thanks again,
christian