[Solved] When running unit tests from command line FreeCAD does not shutdown anymore

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
apeltauer
Posts: 207
Joined: Fri Aug 11, 2017 2:19 pm

[Solved] When running unit tests from command line FreeCAD does not shutdown anymore

Postby apeltauer » Fri Aug 31, 2018 1:36 pm

Hi all,

while running the unit tests from command line like "FreeCAD.exe" --run-test 0", FreeCAD does not close anymore. I get this output in FreeCAD:

----------------------------------------------------------------------
Ran 349 tests in 288.675s

OK
Exception (Fri Aug 31 13:23:49 2018): System exit
Debug: DraftGui.todo.doTasks: queue contains a deleted object, skipping


I cant see any errors in the tests.

Any idea why FreeCAD does not close anymore?
It is strange that the execution works with appveyor.

After some debuging i found that PyRun_String in (src\Base\Interpreter.cpp line 235) returns a Null Ptr when running the unit test. (While other calls returning a valid pointer) This throws a SystemExitException with (System exit 0).
The exeption is catched in (src\Gui\MainWindow.cpp line 1040), after this the methode "MainWindow::delayedStartup" will then return. While this is a signal triggered function, the main app still runs.
Some while ago the try catch block was inserted to handle exit codes from the unit tests, but now it does not close the app anymore.

Has anyone a proposel how to solve this?
I know it is strange that the build on appveyor works.

Thanks in advance.

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.14500 (Git)
Build type: Debug
Branch: master
Hash: 022653331fa6c14de235f5aebd48785b774c0ed6
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
Locale: English/Germany (en_DE)
Last edited by apeltauer on Tue Sep 04, 2018 1:59 pm, edited 1 time in total.
wmayer
Site Admin
Posts: 14770
Joined: Thu Feb 19, 2009 10:32 am

Re: When running unit tests from command line FreeCAD does not shutdown anymore

Postby wmayer » Fri Aug 31, 2018 8:24 pm

while running the unit tests from command line like "FreeCAD.exe" --run-test 0", FreeCAD does not close anymore. I get this output in FreeCAD:
The behaviour to run unit tests from the command line in GUI mode is relatively new so I can't say if the application has exited for system exceptions. Anyway: git commit fb1a0be84
User avatar
apeltauer
Posts: 207
Joined: Fri Aug 11, 2017 2:19 pm

Re: When running unit tests from command line FreeCAD does not shutdown anymore

Postby apeltauer » Sat Sep 01, 2018 12:03 pm

Thanks Werner for the fast code change.
I will test your commit on monday morning and will give you quick feedback...

Thanks a lot...
User avatar
apeltauer
Posts: 207
Joined: Fri Aug 11, 2017 2:19 pm

Re: When running unit tests from command line FreeCAD does not shutdown anymore

Postby apeltauer » Mon Sep 03, 2018 5:58 am

Just tested our code change and it works like expected.
If the test returns with no error the exit code of FreeCAD is 0. If a test fails it returns with 1.
Thanks a lot again!
User avatar
Kunda1
Posts: 5458
Joined: Thu Jan 05, 2017 9:03 pm

Re: When running unit tests from command line FreeCAD does not shutdown anymore

Postby Kunda1 » Mon Sep 03, 2018 11:18 am

please mark topic as [Solved]. Thank you
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features