digitalmars.D - Unit tests in libraries?
- Mike Linford <mike.linford.reg gmail.com> Aug 16 2010
- Walter Bright <newshound2 digitalmars.com> Aug 16 2010
- Mike Linford <mike.linford.reg gmail.com> Aug 16 2010
- Mike Linford <mike.linford.reg gmail.com> Aug 16 2010
- Walter Bright <newshound2 digitalmars.com> Aug 16 2010
- Walter Bright <newshound2 digitalmars.com> Aug 16 2010
- Stephan <spam extrawurst.org> Aug 17 2010
- Mike Linford <mike.linford.reg gmail.com> Aug 16 2010
- Mike Linford <mike.linford.reg gmail.com> Aug 16 2010
- Mike Linford <mike.linford.reg gmail.com> Aug 17 2010
Sorry for the repost, but its been more than 24 hours in
digitalmars.D.learn
Is this a bug? Unit tests do not seem to work in libraries. I'm using dmd
1.062 for linux.
mylib.d :
module mylib;
void blah()
{
}
unittest
{
assert(false);
}
main.d :
module main;
import mylib;
void main()
{
blah();
}
The unit test does not get run when compiled as:
dmd -lib mylib.d
dmd main.d mylib.a
But does get run when compiled as
dmd main.d mylib.d
Is this the intended behavior for unit tests in libraries?
--
Mike Linford
Aug 16 2010
Mike Linford wrote:The unit test does not get run when compiled as: dmd -lib mylib.d dmd main.d mylib.a But does get run when compiled as dmd main.d mylib.d
You need to compile with -unittest to run them.
Aug 16 2010
On Mon, 16 Aug 2010 10:26:46 -0700, Walter Bright wrote:Mike Linford wrote:The unit test does not get run when compiled as: dmd -lib mylib.d dmd main.d mylib.a But does get run when compiled as dmd main.d mylib.d
You need to compile with -unittest to run them.
Sorry, I forgot to include that I DID include -unittest in all compile lines. -- Mike Linford
Aug 16 2010
On Mon, 16 Aug 2010 10:26:46 -0700, Walter Bright wrote:Mike Linford wrote:The unit test does not get run when compiled as: dmd -lib mylib.d dmd main.d mylib.a But does get run when compiled as dmd main.d mylib.d
You need to compile with -unittest to run them.
Also, the following creates a library that does run the unit tests: dmd -c -unittest mylib.d ar -rc mylib.a mylib.o dmd -unittest main.d mylib.a -- Mike Linford
Aug 16 2010
Mike Linford wrote:On Mon, 16 Aug 2010 10:26:46 -0700, Walter Bright wrote:Mike Linford wrote:The unit test does not get run when compiled as: dmd -lib mylib.d dmd main.d mylib.a But does get run when compiled as dmd main.d mylib.d
You need to compile with -unittest to run them.
Also, the following creates a library that does run the unit tests: dmd -c -unittest mylib.d ar -rc mylib.a mylib.o dmd -unittest main.d mylib.a
Right, that's working as it should.
Aug 16 2010
Mike Linford wrote:Is it working as it should by not including the unit tests with: dmd -unittest -lib mylib.d ?
That should work.
Aug 16 2010
Yeah unittests in compiled static librarys do not work as of dmd2048 right now. please file a bug report with that code. On 17.08.2010 04:24, Mike Linford wrote:On Mon, 16 Aug 2010 17:38:28 -0700, Walter Bright wrote:Mike Linford wrote:Is it working as it should by not including the unit tests with: dmd -unittest -lib mylib.d ?
That should work.
Yeah, I'm not sure what I'm doing wrong. Can someone else try this out? mylib.d: 1 module mylib; 2 3 void blah() 4 { 5 } 6 unittest 7 { 8 assert(false); 9 } 10 test.d: 1 module test; 2 3 import mylib; 4 5 void main() 6 { 7 blah(); 8 } 9 Makefile: 1 test : mylib.a test.d 2 dmd -unittest test.d mylib.a 3 4 mylib.a : mylib.d 5 dmd -unittest -lib mylib.d 6 7 clean : 8 rm -f test mylib.a *.o 9
Aug 17 2010
On Mon, 16 Aug 2010 11:22:50 -0700, Walter Bright wrote:Mike Linford wrote:On Mon, 16 Aug 2010 10:26:46 -0700, Walter Bright wrote:Mike Linford wrote:The unit test does not get run when compiled as: dmd -lib mylib.d dmd main.d mylib.a But does get run when compiled as dmd main.d mylib.d
You need to compile with -unittest to run them.
Also, the following creates a library that does run the unit tests: dmd -c -unittest mylib.d ar -rc mylib.a mylib.o dmd -unittest main.d mylib.a
Right, that's working as it should.
Is it working as it should by not including the unit tests with: dmd -unittest -lib mylib.d ? -- Mike Linford
Aug 16 2010
On Mon, 16 Aug 2010 17:38:28 -0700, Walter Bright wrote:Mike Linford wrote:Is it working as it should by not including the unit tests with: dmd -unittest -lib mylib.d ?
That should work.
Yeah, I'm not sure what I'm doing wrong. Can someone else try this out? mylib.d: 1 module mylib; 2 3 void blah() 4 { 5 } 6 unittest 7 { 8 assert(false); 9 } 10 test.d: 1 module test; 2 3 import mylib; 4 5 void main() 6 { 7 blah(); 8 } 9 Makefile: 1 test : mylib.a test.d 2 dmd -unittest test.d mylib.a 3 4 mylib.a : mylib.d 5 dmd -unittest -lib mylib.d 6 7 clean : 8 rm -f test mylib.a *.o 9 -- Mike Linford
Aug 16 2010
On Tue, 17 Aug 2010 12:38:32 +0200, Stephan wrote:Yeah unittests in compiled static librarys do not work as of dmd2048 right now. please file a bug report with that code. On 17.08.2010 04:24, Mike Linford wrote:On Mon, 16 Aug 2010 17:38:28 -0700, Walter Bright wrote:Mike Linford wrote:Is it working as it should by not including the unit tests with: dmd -unittest -lib mylib.d ?
That should work.
Yeah, I'm not sure what I'm doing wrong. Can someone else try this out? mylib.d: 1 module mylib; 2 3 void blah() 4 { 5 } 6 unittest 7 { 8 assert(false); 9 } 10 test.d: 1 module test; 2 3 import mylib; 4 5 void main() 6 { 7 blah(); 8 } 9 Makefile: 1 test : mylib.a test.d 2 dmd -unittest test.d mylib.a 3 4 mylib.a : mylib.d 5 dmd -unittest -lib mylib.d 6 7 clean : 8 rm -f test mylib.a *.o 9
Done. http://d.puremagic.com/issues/show_bug.cgi?id=4669 -- Mike Linford
Aug 17 2010









Mike Linford <mike.linford.reg gmail.com> 