From 3a5e01c44ad6c895dd727c6da0eb0284eba3d2f4 Mon Sep 17 00:00:00 2001 From: John Beard Date: Tue, 2 Apr 2019 13:36:12 +0100 Subject: [PATCH] QA: Enable eeschema tests Redesignate the eagle test as eeschema tests and build more like the other unit tests. Enable as a test in Ctest now that the test executes without crashing. The loading of the file with the hardocded part is still not enabled, as this needs more infrastructure to support it. (cherry picked from commit 4eb30f6b85e801753c818239ad225f68375d35e3) --- eeschema/CMakeLists.txt | 3 + qa/eeschema/CMakeLists.txt | 59 +++++++++++-------- .../{test_basic.cpp => test_eagle_plugin.cpp} | 19 +++--- qa/eeschema/test_module.cpp | 27 +++++++-- 4 files changed, 72 insertions(+), 36 deletions(-) rename qa/eeschema/{test_basic.cpp => test_eagle_plugin.cpp} (79%) diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index c56ac2d9cb..244d25bfd5 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -356,6 +356,9 @@ target_link_libraries( eeschema_kiface ${wxWidgets_LIBRARIES} ${GDI_PLUS_LIBRARIES} ) +target_include_directories( eeschema_kiface PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ) if( KICAD_SPICE ) target_link_libraries( eeschema_kiface diff --git a/qa/eeschema/CMakeLists.txt b/qa/eeschema/CMakeLists.txt index ef837fe7db..b5143bccf8 100644 --- a/qa/eeschema/CMakeLists.txt +++ b/qa/eeschema/CMakeLists.txt @@ -21,31 +21,44 @@ # or you may write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -find_package( Boost COMPONENTS unit_test_framework REQUIRED ) - include_directories( BEFORE ${INC_BEFORE} ) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/eeschema - ${CMAKE_SOURCE_DIR}/common - ${INC_AFTER} +include_directories( AFTER ${INC_AFTER} ) + + +add_executable( qa_eeschema + # A single top to load the pcnew kiface + # ../../common/single_top.cpp + + # stuff from common due to...units? + ../../common/base_units.cpp + ../../common/eda_text.cpp + + # stuff from common which is needed...why? + ../../common/colors.cpp + ../../common/observable.cpp + + # The main test entry points + test_module.cpp + + test_eagle_plugin.cpp ) -add_executable( qa_eagle_plugin - test_module.cpp - test_basic.cpp - ) - -target_compile_definitions( qa_eagle_plugin - PRIVATE -DBOOST_TEST_DYN_LINK ) - -add_dependencies( qa_eagle_plugin common eeschema_kiface ) - -target_link_libraries( qa_eagle_plugin - common +target_link_libraries( qa_eeschema eeschema_kiface - ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} - ${wxWidgets_LIBRARIES} - ) + common + gal + qa_utils + unit_test_utils + ${GDI_PLUS_LIBRARIES} + ${Boost_LIBRARIES} +) + +add_test( NAME eeschema + COMMAND qa_eeschema +) + +# Eeschema tests, so pretend to be eeschema (for units, etc) +target_compile_definitions( qa_eeschema + PUBLIC EESCHEMA +) \ No newline at end of file diff --git a/qa/eeschema/test_basic.cpp b/qa/eeschema/test_eagle_plugin.cpp similarity index 79% rename from qa/eeschema/test_basic.cpp rename to qa/eeschema/test_eagle_plugin.cpp index 5df77c9cbc..13537fec4f 100644 --- a/qa/eeschema/test_basic.cpp +++ b/qa/eeschema/test_eagle_plugin.cpp @@ -22,10 +22,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include #include -#include +#include #include +#include #include @@ -34,16 +34,17 @@ */ BOOST_AUTO_TEST_CASE( FindPlugin ) { - BOOST_CHECK( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_EAGLE ) != NULL ); + BOOST_CHECK_NE( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_EAGLE ), nullptr ); } /** * */ -BOOST_AUTO_TEST_CASE( Load ) -{ - SCH_PLUGIN* pi = SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_EAGLE ); +// BOOST_AUTO_TEST_CASE( Load ) +// { +// SCH_PLUGIN* pi = SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_EAGLE ); - pi->Load("/home/alejandro/Proyectos/kicad/kicad-alejandro/eeschema/qa/data/eagle_schematics/empty.sch", - NULL); -} +// pi->Load( +// "/home/alejandro/Proyectos/kicad/kicad-alejandro/eeschema/qa/data/eagle_schematics/empty.sch", +// NULL ); +// } diff --git a/qa/eeschema/test_module.cpp b/qa/eeschema/test_module.cpp index 50b04dd599..5dbce91ca6 100644 --- a/qa/eeschema/test_module.cpp +++ b/qa/eeschema/test_module.cpp @@ -3,6 +3,7 @@ * * Copyright (C) 2017 CERN * @author Alejandro GarcĂ­a Montoro + * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -23,9 +24,27 @@ */ /** - * Main file for the schematic eagle plugin tests to be compiled + * Main file for the Eeschema tests to be compiled */ - -#define BOOST_TEST_MODULE "Schematic Eagle plugin" - #include + +#include + + +bool init_unit_test() +{ + boost::unit_test::framework::master_test_suite().p_name.value = "Common Eeschema module tests"; + return wxInitialize(); +} + + +int main( int argc, char* argv[] ) +{ + int ret = boost::unit_test::unit_test_main( &init_unit_test, argc, argv ); + + // This causes some glib warnings on GTK3 (http://trac.wxwidgets.org/ticket/18274) + // but without it, Valgrind notices a lot of leaks from WX + wxUninitialize(); + + return ret; +} \ No newline at end of file