Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit Testing #34

Open
HarveyHunt opened this issue Oct 3, 2014 · 5 comments
Open

Unit Testing #34

HarveyHunt opened this issue Oct 3, 2014 · 5 comments

Comments

@HarveyHunt
Copy link
Owner

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

  • Use minunit, a VERY lightweight unit testing lib.
  • Compile howm into a .so and then use Python's great unit testing framework with the help of ctypes..

Opinions?

@anubhavcodes
Copy link
Contributor

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
Copy link

vimeitor commented Oct 3, 2014

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
Copy link
Owner Author

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
Copy link
Owner Author

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants