← Back to team overview

kicad-developers team mailing list archive

Re: [RFC] [PATCH] simple C++ tests

 

Hey,

I have worked only on one CMake project that uses CTest and that worked like CTest calls the the executable for a test suite and checks the return error code. However if there are multiple tests in a executable it will just show that any of it failed, but not what exactly failed, so it is really not helpful for the developer. Linking an executable per test is imho prohibitive. So my workflow was coding the tests units with google test (or boost.test, whatever fits) and use CTest only as a validation if all tests-suites pass. If any fails I go ahead and run that test from the prompt to get the detailed unit-test-lib output. Another option would be to use extended add_test to run the executables with arguments identifying the specific test to run, but that is not really developer friendly either, right? Does anyone have experience with a nice CTest workflow or an example I could have a look at?

Michael


Am 05.12.2016 um 14:43 schrieb Wayne Stambaugh:
I would be more than happy if you wanted to take on the task of getting
the c++ unit testing framework set up.  Maybe once the infrastructure is
in place, developers would be more likely to write unit tests.  I would
also prefer if you used CTest for running the test suites rather than
using CMake custom targets.  This is what CTest was designed to handle.

On 12/5/2016 8:38 AM, Michael Steinberg wrote:
Thank you Wayne,

I'd be really highly interested in getting unit tests sorted out for the
C++ part. Each time I write something without a set of tests for a
project of this size I feel miserable :( Is there anything I can help
with, sort out, think about?

Michael


Am 05.12.2016 um 14:19 schrieb Wayne Stambaugh:
On 12/4/2016 8:53 AM, Michael Steinberg wrote:
Am 12.09.2016 um 17:14 schrieb Wayne Stambaugh:
On 9/12/2016 11:04 AM, Tomasz Wlostowski wrote:
On 08.09.2016 18:49, Wayne Stambaugh wrote:
Hey Tom,

Here is the patch that fixes the linking as well.  I linked
against the
static libraries.  That shouldn't be an issue.

Hi Wayne,

Thanks for the patch. It looks like the config.h file is generated in
the build directory, not the source one. I was building in-tree so I
didn't notice the problem.

Concerning static linking, I would like to have an option (say,
KICAD_TESTS_USE_KIFACE_DLLL) to avoid it and link directly to the
.kiface DLL. This results in way faster linking times and omits
dependency calculations, which I find very annoying (especially when I
know I didn't change anything that would result in an incompatible DLL
binary).
Linking to the dynamic library in the pcbnew/ build path is
problematic.
    On linux, you would have to run ldconfig, on windows you would
have set
the $PATH environment variable, and I believe osx also has some type of
dynamic library loader that would require configuration otherwise the
tests would fail because the os wont be able to find the dynamic
library.  That's why I statically linked it.  I would think that would
be acceptable for unit testing purposes.
Hello all,

what's the status on this? If I'm rewriting lib stuff I could just as
well go ahead and add unit tests for it. I couldn't find the "tests"
folder that would be added by the patch.

Michael

Michael,

The unit tests are in the qa folder.  As of right now there are only
some python tests using the python unit test framework which means any
code you write would have to be built into the python scripting support
to test it.  We have discussed using the boost unit test framework for
testing c++ code directly so that is an option as well.

Cheers,

Wayne

_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp
_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp



References