← Back to team overview

kicad-developers team mailing list archive

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

 

Tom,

Here's a patch against your patch that fixes the compile and some of the
link issues.  It linker still cannot find some of the PNS_NODE code.  I
thought PNS_NODE was in the libpcbcommon.a library but apparently not.
I'm calling it a night.  I'll see if I can get it to build tomorrow.

Cheers,

Wayne

On 9/7/2016 5:39 PM, Tomasz Wlostowski wrote:
> On 07.09.2016 21:24, Wayne Stambaugh wrote:
>> Tom,
>>
>> I also forgot to mention there were tabs in the CMakeLists.txt file.
>>
> Hi Wayne,
> 
> Here's a (hopefully) fixed version.
> 
> Cheers,
> Tom
> 
>> Cheers,
>>
>> Wayne
>>
>> On 9/7/2016 12:17 PM, Tomasz Wlostowski wrote:
>>> Hi,
>>>
>>> This patch adds possibility to build C++ tests for pcbnew, using
>>> Boost.Test framework. I intended it primarily to make tests for the P&S,
>>> which I used to develop out-of-tree before.
>>>
>>> Since Kicad's codebase is rather monolithic, testing/refactoring
>>> anything drags in pretty much everything else in the code as a
>>> dependency.  This causes long rebuild and linking times, which I find
>>> very annoying. Also, while developing new features, most of the time is
>>> spent linking pcbnew and clicking in the GUI to trigger the particular
>>> feature.
>>>
>>> For that reason I decided to link all the test cases directly to the
>>> _pcbnew_kiface library and skip pcbnew's dependency scanning when
>>> building tests. I'm also preparing a bare PCB test window for verifying
>>> interactive/graphical operations without rebuilding pcbnew as a whole app.
>>>
>>> I've attached the patch (set the KICAD_BUILD_TESTS=ON option to enable).
>>> There's one trivial unit test included as an example. Let me know if
>>> such solution would be acceptable.
>>>
>>> Cheers,
>>> Tom
>>>
>>>
>>>
>>> _______________________________________________
>>> 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
>>
> 

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 6a3abea..cc1254c 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,15 +1,21 @@
-include_directories ( 
-    ${CMAKE_SOURCE_DIR} 
+include_directories(
+    ${CMAKE_BINARY_DIR}
+    ${CMAKE_SOURCE_DIR}
     ${CMAKE_SOURCE_DIR}/polygon
     ${CMAKE_SOURCE_DIR}/include
     ${CMAKE_SOURCE_DIR}/pcbnew
-    ${CMAKE_SOURCE_DIR}/pcbnew/router )
+    ${CMAKE_SOURCE_DIR}/pcbnew/router
+)
 
-link_directories ( ${CMAKE_BINARY_DIR}/pcbnew )
+link_directories( ${CMAKE_BINARY_DIR}/pcbnew )
 
 function( add_test_case name )
-    add_executable ( ${name} ${name}.cpp )
-    target_link_libraries ( ${name} ${wxWidgets_LIBRARIES} _pcbnew_kiface ${Boost_LIBRARIES} )
+    add_executable( ${name} ${name}.cpp )
+    target_link_libraries( ${name} ${wxWidgets_LIBRARIES}
+        ${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.kiface
+        ${CMAKE_BINARY_DIR}/common/libcommon.a
+        ${CMAKE_BINARY_DIR}/common/libpcbcommon.a
+        ${Boost_LIBRARIES} )
 endfunction( add_test_case )
 
-add_subdirectory ( pns )
+add_subdirectory( pns )
diff --git a/tests/pns/CMakeLists.txt b/tests/pns/CMakeLists.txt
index b305e1e..2da310b 100644
--- a/tests/pns/CMakeLists.txt
+++ b/tests/pns/CMakeLists.txt
@@ -1,3 +1 @@
 add_test_case( test_node )
-
-

References