RejectedSoftware Forums

Sign up

Question about dub test

Hi,

I checked out vibelog project, and try to play and learn with it.

But dub test does not seem to work there. I added unittest{...} to source/app.d, but they are not run when I use dub test.

Is it because that vibelog project is older?

I tried to dub init a new project, and put unittest{...} code and it works, but with a message which says:

No source files found in configuration 'library'. Falling back to "dub -b unittest".

what does this mean?

Re: Question about dub test

Am 05.03.2014 11:11, schrieb zhaopuming:

Hi,

I checked out vibelog project, and try to play and learn with it.

But dub test does not seem to work there. I added unittest{...} to source/app.d, but they are not run when I use dub test.

Is it because that vibelog project is older?

The source/app.d file (or more specifically, the "mainSourceFile" of
the application) is excluded from the "dub test" build so that the
main function doesn't interfere with the unit test execution. It seems
like a good idea to scan this file for the unittest keyword and issue
a proper warning/explanation in this case.

I tried to dub init a new project, and put unittest{...} code and it works, but with a message which says:

No source files found in configuration 'library'. Falling back to "dub -b unittest".

what does this mean?

This is also a side effect of excluding the "mainSourceFile". Since
there are no other files, it tries to do the best thing possible and
runs the application with the "unittest" build type, in the hope that
main() has a proper version(unittest) block to do the right thing
for unit test builds. Maybe it would be more consistent to simply exit
with a notice that no unit tests were run instead, though...

I'll add two tickets, one for writing proper documentation on how "dub
test" behaves and one to add a warning for the case that unit tests are
found in the "mainSourceFile".

Re: Question about dub test

On Mon, 10 Mar 2014 17:11:17 +0100, Sönke Ludwig wrote:

Am 05.03.2014 11:11, schrieb zhaopuming:

Hi,

I checked out vibelog project, and try to play and learn with it.

But dub test does not seem to work there. I added unittest{...} to source/app.d, but they are not run when I use dub test.

Is it because that vibelog project is older?

The source/app.d file (or more specifically, the "mainSourceFile" of
the application) is excluded from the "dub test" build so that the
main function doesn't interfere with the unit test execution. It seems
like a good idea to scan this file for the unittest keyword and issue
a proper warning/explanation in this case.

Thanks, I'm ok with that.

I tried to dub init a new project, and put unittest{...} code and it works, but with a message which says:

No source files found in configuration 'library'. Falling back to "dub -b unittest".

what does this mean?

This is also a side effect of excluding the "mainSourceFile". Since
there are no other files, it tries to do the best thing possible and
runs the application with the "unittest" build type, in the hope that
main() has a proper version(unittest) block to do the right thing
for unit test builds. Maybe it would be more consistent to simply exit
with a notice that no unit tests were run instead, though...

I'll add two tickets, one for writing proper documentation on how "dub
test" behaves and one to add a warning for the case that unit tests are
found in the "mainSourceFile".