Re: unittests, dub and libraries

2018-03-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 28, 2018 21:29:22 Jesse Phillips via Digitalmars-d-learn 
wrote:
> On Wednesday, 28 March 2018 at 03:07:23 UTC, Jonathan M Davis
>
> wrote:
> > Run
> >
> > dub test
> >
> > The problem is that an executable needs a main, and a library
> > doesn't have one, whereas when you're testing a library, you
> > need an executable. So, a main must be inserted - e.g. with the
> > -main flag to dmd. Just building the unittest build doesn't
> > insert one. However, dub test _does_ deal with that for you.
> >
> > - Jonathan M Davis
>
> And a note on the reverse, if you have an executable project $
> dub test won't build in the app.d file since it contains main and
> dub test wants to avoid running your main function.

Yeah. That's really annoying behavior. I keep forgetting that it does that
until I realize that I have tests that should be failing that aren't.

- Jonathan M Davis



Re: unittests, dub and libraries

2018-03-28 Thread Jesse Phillips via Digitalmars-d-learn

On Wednesday, 28 March 2018 at 21:29:22 UTC, Jesse Phillips wrote:
And a note on the reverse, if you have an executable project $ 
dub test won't build in the app.d file since it contains main 
and dub test wants to avoid running your main function.


For reference:

https://github.com/dlang/dub/issues/1118


Re: unittests, dub and libraries

2018-03-28 Thread Jesse Phillips via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 03:07:23 UTC, Jonathan M Davis 
wrote:

Run

dub test

The problem is that an executable needs a main, and a library 
doesn't have one, whereas when you're testing a library, you 
need an executable. So, a main must be inserted - e.g. with the 
-main flag to dmd. Just building the unittest build doesn't 
insert one. However, dub test _does_ deal with that for you.


- Jonathan M Davis


And a note on the reverse, if you have an executable project $ 
dub test won't build in the app.d file since it contains main and 
dub test wants to avoid running your main function.


Re: unittests, dub and libraries

2018-03-27 Thread Joe via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 03:07:23 UTC, Jonathan M Davis 
wrote:

Run

dub test

The problem is that an executable needs a main, and a library 
doesn't have one, whereas when you're testing a library, you 
need an executable. So, a main must be inserted - e.g. with the 
-main flag to dmd. Just building the unittest build doesn't 
insert one. However, dub test _does_ deal with that for you.


Thanks.


Re: unittests, dub and libraries

2018-03-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 28, 2018 02:16:59 Joe via Digitalmars-d-learn wrote:
> I'm trying to build a very simple library. For now it just has a
> single class, constructor, destructor and one method.  I added a
> unit test right after the method, declared the targetType to be
> "library" and a buildType of "unittest" (with options
> "unittests", "debugMode", "debugInfo"). When I run
>
>dub run -b unittest
>
> it builds the library, but then says:
>
>Target is a library. Skipping execution.
>
> If I compile with ldc2 -unittest the linker throws the error:
>
>(.text+0x20): undefined reference to `main'
>
> If I add an empty main function to the source file, ldc2/gcc
> manage to create an executable that can be invoked manually and
> it runs through the unit test.
>
> Is this the best that can be done?

Run

dub test

The problem is that an executable needs a main, and a library doesn't have
one, whereas when you're testing a library, you need an executable. So, a
main must be inserted - e.g. with the -main flag to dmd. Just building the
unittest build doesn't insert one. However, dub test _does_ deal with that
for you.

- Jonathan M Davis



unittests, dub and libraries

2018-03-27 Thread Joe via Digitalmars-d-learn
I'm trying to build a very simple library. For now it just has a 
single class, constructor, destructor and one method.  I added a 
unit test right after the method, declared the targetType to be 
"library" and a buildType of "unittest" (with options 
"unittests", "debugMode", "debugInfo"). When I run


  dub run -b unittest

it builds the library, but then says:

  Target is a library. Skipping execution.

If I compile with ldc2 -unittest the linker throws the error:

  (.text+0x20): undefined reference to `main'

If I add an empty main function to the source file, ldc2/gcc 
manage to create an executable that can be invoked manually and 
it runs through the unit test.


Is this the best that can be done?


Re: Dub and libraries

2018-01-05 Thread Arek via Digitalmars-d-learn

On Thursday, 4 January 2018 at 19:05:59 UTC, Russel Winder wrote:
Is it the case that, for library things on the Dub repository, 
Dub will only create library archives, .a, that it is unable to 
create shared objects and DLLs?


If they have "targetType" set to "dynamicLibrary" dub creates 
shared libraries.



https://code.dlang.org/package-format?lang=sdl#target-types




Re: Dub and libraries

2018-01-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 04, 2018 19:05:59 Russel Winder via Digitalmars-d-learn 
wrote:
> Is it the case that, for library things on the Dub repository, Dub will
> only create library archives, .a, that it is unable to create shared
> objects and DLLs?

Well, you can configure a dub project to be a shared library by making its
target type "dynamicLibrary", in which case, that's all it's going to build
as, so something would be very wrong if it didn't build that way when using
code.dlang.org. However, I expect that most folks simply use "library" for
the target type and not "dynamicLibrary", and in that case, I believe that
it does static by default, and I don't know how you can control that.

If you have more detailed questions, I'd suggest asking on the forum
intended for dub:

http://forum.rejectedsoftware.com/

- Jonathan M Davis



Dub and libraries

2018-01-04 Thread Russel Winder via Digitalmars-d-learn
Is it the case that, for library things on the Dub repository, Dub will
only create library archives, .a, that it is unable to create shared
objects and DLLs?

-- 
Russel.
==
Dr Russel Winder  t: +44 20 7585 2200
41 Buckmaster Roadm: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk


signature.asc
Description: This is a digitally signed message part