The scope of this pull-request is simply to enhance the TestApp.py FreeCAD module to return the TestResult object to the caller, in this specific case, FreeCADTest.py, so it can interrogate the TestResult object to see if all tests passed using the wasSuccessful() method and exit with the proper zero (if all passed) and non-zero (if any tests failed) exit status.
This change provides a clean, cross-platform mechanism to execute the unit test suite from the command-line for continuous integration. With this change, for example, we can change travis configuration from:
Code: Select all
PYTHONPATH=$(pwd)/lib/ python -c "import sys, unittest, FreeCAD, TestApp; sys.exit(0 if unittest.TextTestRunner().run(TestApp.All()).wasSuccessful() else 1)"
Whereby we are running the unit tests within the fully linked executable and follows standard unix exit status conventions that can be leveraged by any script/process that calls FreeCAD. Future travis configs, for most platforms, will be able to run the unit tests against the "installed" executable that more closely mimics an end-user's environment.
Code: Select all
$(pwd)/bin/FreeCAD --run-test 0
Finally, FreeCADTest.py calls os._exit(exitStatusCode) instead of sys.exit(exitStatusCode) because FreeCAD Base::Interpreter:SystemExitException swallows the system exit code so it is not available to the calling try/catch block that currently traps the SystemExitException exception and exits with a 0 status code. Calling os._exit() for this specific use case is the least intrusive change without refactoring Base::Interpreter.
- Pull Request - https://github.com/FreeCAD/FreeCAD/pull/114
- Related Mantis Issue - http://www.freecadweb.org/tracker/view.php?id=2414
- Build Tests Pass - https://travis-ci.org/bblacey/FreeCAD-M ... /114984261