Kaydet (Commit) d7628186 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Create temp copies of test docs in Python/UITests

...where necessary, so the tests will succeed if SRCDIR is a read-only tree.

Change-Id: Iea4c52d5982d3eba079088ef1670ff557ce30c3f
Reviewed-on: https://gerrit.libreoffice.org/52122Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 20c68009
......@@ -9,7 +9,7 @@ try:
except ImportError:
from urllib import pathname2url
from org.libreoffice.unotest import pyuno, mkPropertyValue
from org.libreoffice.unotest import pyuno, mkPropertyValue, makeCopyFromTDOC
class InsertRemoveCells(unittest.TestCase):
......@@ -29,8 +29,7 @@ class InsertRemoveCells(unittest.TestCase):
('Hidden', True),
('ReadOnly', False)
))
tdoc_dir = getenv('TDOC')
tdoc_path = pathname2url(path.join(tdoc_dir, 'fdo74824.ods'))
tdoc_path = pathname2url(makeCopyFromTDOC('fdo74824.ods'))
if platform.system() == 'Windows':
tdoc_path = re.sub(r'^//(/[A-Za-z]:/)/', r'\1', tdoc_path)
url = 'file://' + tdoc_path
......
......@@ -12,4 +12,9 @@ $(eval $(call gb_UITest_UITest,autofilter))
$(eval $(call gb_UITest_add_modules,autofilter,$(SRCDIR)/sc/qa/uitest,\
autofilter/ \
))
$(eval $(call gb_UITest_set_defs,autofilter, \
TDOC="$(SRCDIR)/sc/qa/uitest/autofilter/data" \
))
# vim: set noet sw=4 ts=4:
......@@ -12,4 +12,9 @@ $(eval $(call gb_UITest_UITest,calc_tests))
$(eval $(call gb_UITest_add_modules,calc_tests,$(SRCDIR)/sc/qa/uitest,\
calc_tests/ \
))
$(eval $(call gb_UITest_set_defs,calc_tests, \
TDOC="$(SRCDIR)/sc/qa/uitest/calc_tests/data" \
))
# vim: set noet sw=4 ts=4:
......@@ -10,12 +10,14 @@ from uitest.uihelper.common import get_state_as_dict
import time
from uitest.debug import sleep
from uitest.uihelper.common import select_pos
from uitest.path import get_srcdir_url
from uitest.uihelper.calc import enter_text_to_cell
from libreoffice.calc.document import get_cell_by_position
import org.libreoffice.unotest
import pathlib
def get_url_for_data_file(file_name):
return get_srcdir_url() + "/sc/qa/uitest/autofilter/data/" + file_name
return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
class autofilter(UITestCase):
......
......@@ -8,14 +8,15 @@
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.framework import UITestCase
from libreoffice.calc.document import get_column
import org.libreoffice.unotest
import pathlib
import time
from uitest.debug import sleep
from uitest.path import get_srcdir_url
from libreoffice.calc.document import get_cell_by_position
from uitest.uihelper.common import get_state_as_dict
def get_url_for_data_file(file_name):
return get_srcdir_url() + "/sc/qa/uitest/calc_tests/data/" + file_name
return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
class mergedRowsColumns(UITestCase):
......
......@@ -8,16 +8,17 @@
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.framework import UITestCase
from libreoffice.calc.document import get_column
from uitest.path import get_srcdir_url
from uitest.uihelper.calc import enter_text_to_cell
from libreoffice.calc.document import get_cell_by_position
from uitest.uihelper.common import select_pos
from uitest.uihelper.common import get_state_as_dict
import org.libreoffice.unotest
import pathlib
import time
from uitest.debug import sleep
def get_url_for_data_file(file_name):
return get_srcdir_url() + "/sc/qa/uitest/calc_tests/data/" + file_name
return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
class Subtotals(UITestCase):
......
......@@ -5,9 +5,10 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
from uitest.framework import UITestCase
import org.libreoffice.unotest
import os
import pathlib
from uitest.uihelper.common import get_state_as_dict
from uitest.path import get_srcdir_url
from libreoffice.calc.document import get_sheet_from_doc
from libreoffice.calc.conditional_format import get_conditional_format_from_sheet
from uitest.debug import sleep
......@@ -18,7 +19,7 @@ from libreoffice.uno.propertyvalue import mkPropertyValues
#numbers and dates the formatting is lost. Undo do not recover the conditional formatting.
def get_url_for_data_file(file_name):
return get_srcdir_url() + "/sc/qa/uitest/calc_tests/data/" + file_name
return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
class tdf62267(UITestCase):
......
......@@ -5,9 +5,10 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
from uitest.framework import UITestCase
import org.libreoffice.unotest
import os
import pathlib
from uitest.uihelper.common import get_state_as_dict
from uitest.path import get_srcdir_url
from libreoffice.calc.document import get_sheet_from_doc
from libreoffice.calc.conditional_format import get_conditional_format_from_sheet
from uitest.debug import sleep
......@@ -15,7 +16,7 @@ from libreoffice.uno.propertyvalue import mkPropertyValues
from libreoffice.calc.document import get_cell_by_position
def get_url_for_data_file(file_name):
return get_srcdir_url() + "/sc/qa/uitest/calc_tests/data/" + file_name
return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
class tdf65856(UITestCase):
......
......@@ -9,12 +9,13 @@ from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.framework import UITestCase
from libreoffice.calc.document import get_column
from uitest.path import get_srcdir_url
from libreoffice.calc.document import get_cell_by_position
import org.libreoffice.unotest
import pathlib
import time
def get_url_for_data_file(file_name):
return get_srcdir_url() + "/sc/qa/uitest/calc_tests/data/" + file_name
return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
class tdf81351(UITestCase):
......
......@@ -5,16 +5,17 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
from uitest.framework import UITestCase
import org.libreoffice.unotest
import os
import pathlib
from uitest.uihelper.common import get_state_as_dict
from uitest.path import get_srcdir_url
from libreoffice.calc.document import get_sheet_from_doc
from libreoffice.calc.conditional_format import get_conditional_format_from_sheet
from uitest.debug import sleep
from libreoffice.uno.propertyvalue import mkPropertyValues
def get_url_for_data_file(file_name):
return get_srcdir_url() + "/sc/qa/uitest/calc_tests/data/" + file_name
return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
class tdf86253(UITestCase):
......
......@@ -10,12 +10,13 @@ from uitest.uihelper.common import get_state_as_dict
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.debug import sleep
from uitest.uihelper.calc import enter_text_to_cell
from uitest.path import get_srcdir_url
from libreoffice.calc.document import get_cell_by_position
import org.libreoffice.unotest
import pathlib
import time
def get_url_for_data_file(file_name):
return get_srcdir_url() + "/sc/qa/uitest/calc_tests/data/" + file_name
return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
class tdf99386(UITestCase):
......
......@@ -91,7 +91,7 @@ endif
# always use udkapi and URE services
define gb_UITest_UITest
$(call gb_UITest_get_target,$(1)) : PYPATH := $(SRCDIR)/uitest$$(gb_CLASSPATHSEP)$(INSTROOT)/$(LIBO_LIB_PYUNO_FOLDER)$(if $(filter-out $(LIBO_LIB_PYUNO_FOLDER),$(LIBO_LIB_FOLDER)),$(gb_CLASSPATHSEP)$(INSTROOT)/$(LIBO_LIB_FOLDER))
$(call gb_UITest_get_target,$(1)) : PYPATH := $(SRCDIR)/uitest$$(gb_CLASSPATHSEP)$(SRCDIR)/unotest/source/python$$(gb_CLASSPATHSEP)$(INSTROOT)/$(LIBO_LIB_PYUNO_FOLDER)$(if $(filter-out $(LIBO_LIB_PYUNO_FOLDER),$(LIBO_LIB_FOLDER)),$(gb_CLASSPATHSEP)$(INSTROOT)/$(LIBO_LIB_FOLDER))
$(call gb_UITest_get_target,$(1)) : MODULES :=
$(eval $(call gb_Module_register_target,$(call gb_UITest_get_target,$(1)),$(call gb_UITest_get_clean_target,$(1))))
......
......@@ -10,3 +10,7 @@ $(eval $(call gb_UITest_UITest,writer_tests))
$(eval $(call gb_UITest_add_modules,writer_tests,$(SRCDIR)/sw/qa/uitest,\
writer_tests/ \
))
$(eval $(call gb_UITest_set_defs,writer_tests, \
TDOC="$(SRCDIR)/sw/qa/uitest/writer_tests/data" \
))
......@@ -7,12 +7,13 @@
from uitest.framework import UITestCase
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.uihelper.common import get_state_as_dict
import org.libreoffice.unotest
import pathlib
import time
from uitest.debug import sleep
from uitest.path import get_srcdir_url
def get_url_for_data_file(file_name):
return get_srcdir_url() + "/sw/qa/uitest/writer_tests/data/" + file_name
return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
class tdf108124(UITestCase):
......
......@@ -6,12 +6,13 @@
from uitest.framework import UITestCase
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.uihelper.common import get_state_as_dict
import org.libreoffice.unotest
import pathlib
import time
from uitest.path import get_srcdir_url
from uitest.debug import sleep
def get_url_for_data_file(file_name):
return get_srcdir_url() + "/sw/qa/uitest/writer_tests/data/" + file_name
return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
class tdf113284(UITestCase):
......
......@@ -12,4 +12,9 @@ $(eval $(call gb_UITest_UITest,manual_tests))
$(eval $(call gb_UITest_add_modules,manual_tests,$(SRCDIR)/uitest,\
manual_tests/ \
))
$(eval $(call gb_UITest_set_defs,manual_tests, \
TDOC="$(SRCDIR)/uitest/manual_tests/data" \
))
# vim: set noet sw=4 ts=4:
......@@ -12,4 +12,9 @@ $(eval $(call gb_UITest_UITest,writer_demo))
$(eval $(call gb_UITest_add_modules,writer_demo,$(SRCDIR)/uitest,\
writer_tests/ \
))
$(eval $(call gb_UITest_set_defs,writer_demo, \
TDOC="$(SRCDIR)/uitest/writer_tests/data" \
))
# vim: set noet sw=4 ts=4:
......@@ -12,12 +12,13 @@ from libreoffice.calc.document import get_cell_by_position
from uitest.uihelper.common import get_state_as_dict, type_text
from uitest.uihelper.calc import enter_text_to_cell
from uitest.path import get_srcdir_url
import org.libreoffice.unotest
import pathlib
import time
def get_url_for_data_file(file_name):
return get_srcdir_url() + "/uitest/manual_tests/data/" + file_name
return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
class ManualCalcTests(UITestCase):
......
......@@ -5,10 +5,12 @@
#
from uitest.framework import UITestCase
from uitest.path import get_srcdir_url
import org.libreoffice.unotest
import pathlib
def get_url_for_data_file(file_name):
return get_srcdir_url() + "/uitest/writer_tests/data/" + file_name
return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
class tdf104649(UITestCase):
......
......@@ -14,6 +14,9 @@ import time
import uuid
import argparse
import os
import shutil
import urllib.parse
import urllib.request
try:
import pyuno
......@@ -210,20 +213,15 @@ class UnoInProcess:
return self.openDocFromTDOC(file, True)
def openDocFromTDOC(self, file, asTemplate = False):
path = os.getenv("TDOC")
if os.name == "nt":
# do not quote drive letter - it must be "X:"
url = "file:///" + path + "/" + quote(file)
else:
url = "file://" + quote(path) + "/" + quote(file)
return self.openDocFromURL(url, asTemplate)
path = makeCopyFromTDOC(file)
return self.openDocFromAbsolutePath(path, asTemplate)
def openDocFromAbsolutePath(self, file):
def openDocFromAbsolutePath(self, file, asTemplate = False):
if os.name == "nt":
url = "file:///" + file
else:
url = "file://" + file
return self.openDocFromURL(url)
return self.openDocFromURL(url, asTemplate)
def openDocFromURL(self, url, asTemplate = False):
props = [("Hidden", True), ("ReadOnly", False), ("AsTemplate", asTemplate)]
......@@ -285,6 +283,28 @@ def runConnectionTests(connection, invoker, tests):
finally:
connection.tearDown()
def makeCopyFromTDOC(file):
src = os.getenv("TDOC")
assert(src is not None)
src = os.path.join(src, file)
dst = os.getenv("TestUserDir")
assert(dst is not None)
uri = urllib.parse.urlparse(dst)
assert(uri.scheme.casefold() == "file")
assert(uri.netloc == "" or uri.netloc.casefold() == "localhost")
assert(uri.params == "")
assert(uri.query == "")
assert(uri.fragment == "")
dst = urllib.request.url2pathname(uri.path)
dst = os.path.join(dst, "tmp", file)
os.makedirs(os.path.dirname(dst), exist_ok=True)
try:
os.remove(dst)
except FileNotFoundError:
pass
shutil.copyfile(src, dst)
return dst
### tests ###
if __name__ == "__main__":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment