diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp index 4bfda6435e..ddceb969b3 100644 --- a/common/pgm_base.cpp +++ b/common/pgm_base.cpp @@ -394,7 +394,7 @@ void PGM_BASE::BuildArgvUtf8() } -bool PGM_BASE::InitPgm( bool aHeadless, bool aSkipPyInit ) +bool PGM_BASE::InitPgm( bool aHeadless, bool aSkipPyInit, bool aIsUnitTest ) { // Just make sure we init precreate any folders early for later code // In particular, the user cache path is the most likely to be hit by startup code @@ -466,6 +466,12 @@ bool PGM_BASE::InitPgm( bool aHeadless, bool aSkipPyInit ) m_settings_manager = std::make_unique( aHeadless ); + // Our unit test mocks break if we continue + // A bug caused InitPgm to terminate early in unit tests and the mocks are...simplistic + // TODO fix the unit tests so this can be removed + if( aIsUnitTest ) + return false; + // Something got in the way of settings load: can't continue if( !m_settings_manager->IsOK() ) return false; diff --git a/include/pgm_base.h b/include/pgm_base.h index 6d149c0787..4380cfb450 100644 --- a/include/pgm_base.h +++ b/include/pgm_base.h @@ -278,7 +278,7 @@ public: * Useful in application that do not use python, to disable python dependency at run time * @return true if success, false if failure and program is to terminate. */ - bool InitPgm( bool aHeadless = false, bool aSkipPyInit = false ); + bool InitPgm( bool aHeadless = false, bool aSkipPyInit = false, bool aIsUnitTest = false ); // The PGM_* classes can have difficulties at termination if they // are not destroyed soon enough. Relying on a static destructor can be diff --git a/qa/unittests/eeschema/test_module.cpp b/qa/unittests/eeschema/test_module.cpp index 4f39b0b0a6..0052337db1 100644 --- a/qa/unittests/eeschema/test_module.cpp +++ b/qa/unittests/eeschema/test_module.cpp @@ -59,7 +59,7 @@ bool init_unit_test() wxSetAssertHandler( &wxAssertThrower ); - Pgm().InitPgm( true, true ); + Pgm().InitPgm( true, true, true ); return ok; }