Commit Graph
9 Commits
Author SHA1 Message Date
Stephan Bergmann e7a3329fd0 DeInitVCL in PythonTest
After b9757f5cfd "loplugin:useuniqueptr in
vcl/svdata" ASan/UBSan builds started to fail (like
<https://ci.libreoffice.org//job/lo_ubsan/1025/>) at the end of
PythonTest_dbaccess_python (and probably other PythonTests), when during exit
the static utl::ConfigManager instance already happens to be destroyed by the
time the static ImplSVData's mpSettingsConfigItem is destroyed (which would
normally be cleared during DeInitVCL, if PythonTests would call that, and which
in the past had thus simply been leaked in PythonTests when that
mpSettingsConfigItem was a plain pointer instead of std::unique_ptr).

So ensure that PythonTests that initialize VCL also call DeInitVCL, via a new
private_deinitTestEnvironment, complementing the existing
private_initTestEnvironment.

However, while private_initTestEnvironment is called once (typically via
UnoInProcess.setUp, which internally makes sure to only call it once) as soon as
the first executed test needs it, private_deinitTestEnvironment must be called
once after the lasts test needing it has executed.  The only way that I found to
do that is to override unittest.TextTestResult's stopTestRun method, which is
called once after all tests have been executed.  Hence a new test runner setup
in unotest/source/python/org/libreoffice/unittest.py that is now called from
solenv/gbuild/PythonTest.mk.

That revealed a few places in PythonTests that didn't yet close/delete documents
that they had opened, which has now been added.

One remaining problem then is that classes like SwXTextDocument and friends call
Application::GetSolarMutex from their dtors, via sw::UnoImplPtrDeleter (a "Smart
pointer class ensuring that the pointed object is deleted with a locked
SolarMutex", sw/inc/unobaseclass.hxx).  That means that any PyUNO proxies to
such C++ objects that remain alive after private_deinitTestEnvironment will
cause issues at exit, when Python does a final garbage collection of those
objects.  The ultimate fix will be to remove that unhelpful UnoImplPtrDeleter
and its locking of SolarMutex from the dtors of UNO objects; until then, the
Python code is now sprinkled with some HACKs to make sure all those PyUNO
proxies are released in a timely fashion (see the comment in
unotest/source/python/org/libreoffice/unittest.py for details).  (Also, it would
probably help if UnoInProcess didn't keep a local self.xDoc around referencing
(just) the last result of calling one of its open* methods, confusingly making
it the responsibility of UnoInProcess to close that one document while making it
the responsibility of the test code making the other UnoInProcess.open* calls to
close any other documents.)

Change-Id: Ief27c81e2b763e9be20cbf3234b68924315f13be
Reviewed-on: https://gerrit.libreoffice.org/60100
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-09-07 07:31:48 +02:00
Saurav Chirania ada02c5565 tdf#97361 Tests in sw should be more pythonic
The modified files have been made more pythonic
by removing Java-like codes.

Change-Id: I46c121f3bd350b0218ca700ea949616e010f917e
Reviewed-on: https://gerrit.libreoffice.org/47863
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2018-01-16 15:40:43 +01:00
Michael Stahl 01b0d6da7f unotest.py: refactor confusing mess of openDoc functions
Change-Id: I148332c639510c55dea2d09bc7aa695708fbf34c
2017-09-07 21:44:57 +02:00
Edmund Wong 70b70d07ad Fix check_flies.py to be more pythonic
Change-Id: Id5f44aaa97539b7ec97b81b39da30bd8d170c011
Reviewed-on: https://gerrit.libreoffice.org/33139
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
2017-02-07 12:54:46 +00:00
kerem c2e69df364 tdf#97361: Changed method calls in check_flies
Change-Id: I6148ffccd4284cfc72fed2c7f4538054a5aaf24c
Reviewed-on: https://gerrit.libreoffice.org/32358
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
2017-01-03 17:13:52 +00:00
kerem 2fa2e149e4 tdf#97361 Fixed check_flies.py
Change-Id: I8b2090ea714cd9103e1823d2a48f624e6c54fbe1
Reviewed-on: https://gerrit.libreoffice.org/31873
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
2016-12-13 11:56:42 +00:00
ackepenek 79e68375e4 tdf#99145 refactored to pep8
Change-Id: I4896cd0bda97331a8291588e6a4f29a881d1229c
Reviewed-on: https://gerrit.libreoffice.org/23925
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2016-05-11 07:25:11 +00:00
Stephan Bergmann d7e5b95c14 Make test code actually test something
...and calling remove on a list apparently returns None

Change-Id: I7a44d85cfebf17ac89bef0ce2d322a2cfa929899
2015-12-16 15:11:44 +01:00
kadertarlan b71540c198 Java unit tests were converted to Python unit tests
Remark test document not moved, due to other test cases.

Change-Id: I9564b72fae60cceb60121fec06e1ed015add8453
Reviewed-on: https://gerrit.libreoffice.org/20703
Reviewed-by: jan iversen <jani@documentfoundation.org>
Tested-by: jan iversen <jani@documentfoundation.org>
2015-12-15 18:56:59 +00:00