← Back to team overview

kicad-developers team mailing list archive

Mocking Kiway

 

Hello,

I try to prepare a test where SIM_PLOT_FRAME() will be used. Constructor of this frame requires Kiway, and I stumbled upon a problem I cannot solve on my own. Could you please answer answer to my questions, so I could move on?

1. There is a Kiway object used in mocks_eeschema.cpp, in PGM_MOCK_EESCHEMA_FRAME::OnPgmExit(). Code compiles fine. 2. I try to use Kiway in test_sch_sheet.cpp, but linking fails (undefined reference to KIWAY Kiway object). 3. It gets linked again when Kiway will be defined in test_sch_sheet.cpp (can be added in mocks_eeschema.cpp as well).

Diff with my changes is attached.

My questions are following:
- why linker doesn't complain in mocks_eeschema.cpp but does in test_sch_sheet.cpp? - why Pgm() or Kiface() can be accessed using function (therefore it is easy to mock them), and Kiway is a static object?

Best regards,
Sylwester


On 07/04/2020 16:58, Wayne Stambaugh wrote:
[1]: https://gitlab.com/kicad/code/kicad/-/issues/4169

On 4/7/20 10:57 AM, Wayne Stambaugh wrote:
Adam,

No problem.  A new macOS crash bug[1] just reared it's ugly head so we
will have get this fixed before we freeze for 5.1.6 so you have some
time to get the OCC switchover completed.  Thanks for working on this
and stay safe.

Cheers,

Wayne

On 4/7/20 10:16 AM, Adam Wolf wrote:
Hi folks!

My KiCad time has been dramatically reduced for the past month due to
schools closing for COVID-19.

I hope to have the OCC switchover complete this week--there were some
fixup_bundle snags again.  (I swear this whole fiasco ends with me
joining the CMake macOS team...)  After the OCC switchover, I need to
debug something weird with the 5.1.5 package, so we're ready for
5.1.6.  At that point, I have one thing to clear up from a project
management (not technical) perspective re the notarization and that
should be able to be setup on our nightlies and releases.

Thanks for your patience as I continue to improve the macOS package :)
  I appreciate bug reports and ideas and PRs but I'm currently only
able to make time to process my KiCad backlog maybe once or twice a
week.

Adam Wolf

_______________________________________________
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


 qa/eeschema/test_sch_sheet.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/qa/eeschema/test_sch_sheet.cpp b/qa/eeschema/test_sch_sheet.cpp
index b6fadcd49..6b8ab8468 100644
--- a/qa/eeschema/test_sch_sheet.cpp
+++ b/qa/eeschema/test_sch_sheet.cpp
@@ -28,6 +28,14 @@
 
 #include <unit_test_utils/unit_test_utils.h>
 
+#include <sim/sim_plot_frame.h>
+#include <pgm_base.h>
+#include <kiway.h>
+
+#if 1
+KIWAY    Kiway( &Pgm(), KFCTL_STANDALONE );
+#endif
+
 // Code under test
 #include <sch_sheet.h>
 
@@ -40,6 +48,7 @@ class TEST_SCH_SHEET_FIXTURE
 public:
     TEST_SCH_SHEET_FIXTURE() : m_sheet(), m_csheet( m_sheet )
     {
+        SIM_PLOT_FRAME* frame = new SIM_PLOT_FRAME( &Kiway, nullptr );
     }
 
     SCH_SHEET m_sheet;

Follow ups

References