www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - version(unittest) in imported modules

reply "Peter Alexander" <peter.alexander.au gmail.com> writes:
dmd -unittest foo.d

Then version(unittest) blocks will be run inside modules that 
`foo` imports, even though the unittests for those modules will 
not run.

Two questions:

1. Is this a bug?

2. If not, how can I tell if unittests are running in *this* 
module?
Mar 02 2014
parent reply "Dicebot" <public dicebot.lv> writes:
On Sunday, 2 March 2014 at 18:07:11 UTC, Peter Alexander wrote:
 dmd -unittest foo.d

 Then version(unittest) blocks will be run inside modules that 
 `foo` imports, even though the unittests for those modules will 
 not run.

 Two questions:

 1. Is this a bug?

 2. If not, how can I tell if unittests are running in *this* 
 module?
Works as intended I say. With `rdmd -unittest foo.d` all test from imported modules will be run, it just happens that raw dmd does not compile imports automatically. So your second question does not really make sense - all tests are always run everywhere.
Mar 02 2014
parent reply "Peter Alexander" <peter.alexander.au gmail.com> writes:
On Sunday, 2 March 2014 at 18:36:16 UTC, Dicebot wrote:
 On Sunday, 2 March 2014 at 18:07:11 UTC, Peter Alexander wrote:
 dmd -unittest foo.d

 Then version(unittest) blocks will be run inside modules that 
 `foo` imports, even though the unittests for those modules 
 will not run.

 Two questions:

 1. Is this a bug?

 2. If not, how can I tell if unittests are running in *this* 
 module?
Works as intended I say. With `rdmd -unittest foo.d` all test from imported modules will be run, it just happens that raw dmd does not compile imports automatically. So your second question does not really make sense - all tests are always run everywhere.
Tests on imported modules are not always run otherwise everyone would be constantly running phobos tests. rdmd is special in that automatically compiles imports.
Mar 02 2014
parent reply "Dicebot" <public dicebot.lv> writes:
On Sunday, 2 March 2014 at 19:37:47 UTC, Peter Alexander wrote:
 Tests on imported modules are not always run otherwise everyone 
 would be constantly running phobos tests. rdmd is special in 
 that automatically compiles imports.
Hm, I am surprised to find that you are right. That does not make sense. static asserts from Phobos should trigger.
Mar 02 2014
parent reply "Ivan Kazmenko" <gassa mail.ru> writes:
On Sunday, 2 March 2014 at 21:03:12 UTC, Dicebot wrote:
 On Sunday, 2 March 2014 at 19:37:47 UTC, Peter Alexander wrote:
 Tests on imported modules are not always run otherwise 
 everyone would be constantly running phobos tests. rdmd is 
 special in that automatically compiles imports.
Hm, I am surprised to find that you are right. That does not make sense. static asserts from Phobos should trigger.
Somewhat off topic, but this makes me wonder, what is the intended way of resolving these issues? (My guess is that they are what triggered the discussion anyway.) https://d.puremagic.com/issues/show_bug.cgi?id=12245 (BinaryHeap exhibits quadratic performance in debug mode) https://d.puremagic.com/issues/show_bug.cgi?id=12246 (RedBlackTree exhibits quadratic performance with -unittest command line option) Basically, when dealing with containers, a programmer can wish for two mutually exclusive ways: 1. (normal operation) The containers show the advertised asymptotic. 2. (paranoia) The containers are checking their integrity after each operation. This could help e.g. when then comparison function is flawed in some non-obvious way (is not transitive). A "-debug=BinaryHeap" seems like a good way to give 2. Perhaps the same can be done for RedBlackTree? Such checks are not exactly unit tests, they vary from one application of a container to another. Ivan Kazmenko.
Mar 02 2014
parent "Peter Alexander" <peter.alexander.au gmail.com> writes:
On Monday, 3 March 2014 at 07:29:10 UTC, Ivan Kazmenko wrote:
 On Sunday, 2 March 2014 at 21:03:12 UTC, Dicebot wrote:
 On Sunday, 2 March 2014 at 19:37:47 UTC, Peter Alexander wrote:
 Tests on imported modules are not always run otherwise 
 everyone would be constantly running phobos tests. rdmd is 
 special in that automatically compiles imports.
Hm, I am surprised to find that you are right. That does not make sense. static asserts from Phobos should trigger.
Somewhat off topic, but this makes me wonder, what is the intended way of resolving these issues? (My guess is that they are what triggered the discussion anyway.)
Yes, that is what triggered the discussion :-) I'd like to run those tests only when phobos unit tests are running but I can't think of any way to conditionally enable the tests.
Mar 03 2014