HarveyHunt / howm

A lightweight, X11 tiling window manager that behaves like vim
GNU General Public License v2.0
649 stars 24 forks source link

Unit Testing #34

Open HarveyHunt opened 9 years ago

HarveyHunt commented 9 years ago

It would be great if we could get some unit testing into howm. I see two ways of doing it:

Opinions?

anubhavcodes commented 9 years ago

I am unfamiliar with either of them, but since I have just finished learning python, I think that would be great to use here

vimeitor commented 9 years ago

Git uses bash for a lot of the unit testing. Depending on what things you want to test, you might even be able to use it.

HarveyHunt commented 9 years ago

I am rather tempted by using C for unit testing as I don't want to have to start worrying about bindings.

I have spent all day battling with the makefile to make it so that we can run:

make test

Leading to a tests.c file being compiled. The makefile is rather difficult to work with and the original author admits that being unable to exclude a file is one of its limitations. The makefile is here.

Perhaps we could use a preprocessor directive to select which files should be compiled? For example we could have the following in tests.c:

#ifdef TEST

... test code is here ...

#endif

I am not too keen on having to change our code to work around a lacking makefile- opinions?

HarveyHunt commented 9 years ago

I have thought about this a little more and think I have come up with a nice solution.

Store all of the tests in a tests.c file (with the header tests.h). If a compile flag is set (RUN_TESTS or something similar) then we include tests.h and call the function run_tests().

If RUN_TESTS isn't set, we can just write a stub for run_tests(), such as returning success.

I think that testing the interface with the X server will be rather pointless, so run_tests() could occur before the connection is made and then exit the program once the tests are done.

I would love to get some feedback on this idea please. :-)

Anachron commented 8 years ago

Well I'm pretty late but I agree that C tests are probably the way to go. Least work and maximum efficdncy.