davidchisnall / dtc

FreeBSD Device Tree Compiler
18 stars 17 forks source link

Enable tests automatically for debug builds #32

Closed kevans91 closed 6 years ago

kevans91 commented 6 years ago

This has made development much better on my end, only having to remember to enable debug to include the tests. I've made it ignore ENABLE_TESTS since I've not yet found a reason that I'd want a debug build with tests explicitly turned off.

davidchisnall commented 6 years ago

I don't think that this is the correct approach. I'd prefer for the default value of ENABLE_TESTS to be true if we're doing a debug build.

davidchisnall commented 6 years ago

I don't see the cache property on this. Can you confirm that if you do a debug build and disable tests then the next time you run cmake . tests remain disabled?

kevans91 commented 6 years ago

Sorry, just saw this- indeed, the following sequence leaves tests disabled until you explicitly re-enable them:

mkdir dist
cd dist
cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=OFF ..
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake ..
davidchisnall commented 6 years ago

I believe setting the cache attribute on the variable should fix this. Create a DEFAULT_TESTS variable that is true for debug builds and false for release and then initialise a cached ENABLE_TESTS variable with $DEFAULT_TESTS.

kevans91 commented 6 years ago

Wait, fix what? I thought it was supposed to remain disabled until you manually tweaked iy.- which is what it does.

davidchisnall commented 6 years ago

Sorry, I misunderstood. To clarify, what happens if I do:

cmake .. -DCMAKE_BUILD_TYPE=Debug
ccmake . # and toggle ENABLE_TESTS to OFF
cmake .

If ENABLE_TESTS remains off, that's fine and I'll merge.

kevans91 commented 6 years ago

When you say # and toggle ENABLE_TESTS to OFF, do you mean -DENABLE_TESTS=OFF, or toggling it manually in CMakeCache.txt? Either one will result in ENABLE_TESTS staying off while it's still a debug build.

davidchisnall commented 6 years ago

I mean, in the ccmake UI.

kevans91 commented 6 years ago

D'oh, TIL that ccmake is actually the name of a binary and not a typo, and cmake has a UI. =D

Indeed, ENABLE_TESTS remains off with that sequence of events as well.