provider_expandall: Don’t skip test if QuickJS provider isn’t built

The commit below changed the unit test so that if the QuickJS provider
isn’t available then the entire test is skipped. Even if the provider is
available, it also changed the check condition so that the test is
skipped if the dummy JavaScript macro was not found. This makes creating
the dummy macro a bit pointless.

The idea of the test is to make sure that all of the script providers
return nodes that can be handled from Python. If the QuickJS provider
isn’t available then it’s still interesting to test the other providers.
If it is available then we want to make sure the dummy script is found
otherwise the test won’t be checking that the nodes returned by the
singleprov code can be handled by Python.

This patch changes the logic so that it will continue the test even if
the QuickJS provider isn’t built but in that case it will skip the
assert that the dummy macro is found.

commit feddb7e827
Author: Christopher Sherlock <chris.sherlock79@gmail.com>
Date:   Sat Jul 25 17:17:33 2026 +1000

    tdf#172532 scripting: fix --without-java builds in provider_expandall.py

Change-Id: I81b83e6b5504d452c7ab05754c1296ff90d364e9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208991
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Neil Roberts
2026-08-06 15:49:05 +02:00
parent a8fbd9095a
commit dbbac9fbfe
+16 -13
View File
@@ -16,6 +16,7 @@ from com.sun.star.uri import UriReferenceFactory
from com.sun.star.container import NoSuchElementException
import uno
import contextlib
import os
import tempfile
@@ -58,17 +59,19 @@ class ProviderExpandAllTest(unittest.TestCase):
except NoSuchElementException:
pass
# Check if JavaScript scripting is supported in this build
try:
js_path = get_user_script_directory(self.context, "JavaScript")
except Exception:
self.skipTest("JavaScript script provider not available in this build")
# Create a dummy JavaScript macro to make sure the JavaScript provider is triggered.
os.makedirs(js_path, exist_ok=True)
with tempfile.TemporaryDirectory(dir=js_path) as js_dir:
with open(os.path.join(js_dir, "dummy_js_script.js"), 'w'):
pass
with contextlib.ExitStack() as stack:
# If the QuickJS-based script provider is available then create a dummy JavaScript macro
# to make sure the provider is triggered.
if ("com.sun.star.script.provider.ScriptProviderForJavaScript"
in self.context.getServiceManager().getAvailableServiceNames()):
have_js_provider = True
js_path = get_user_script_directory(self.context, "JavaScript")
os.makedirs(js_path, exist_ok=True)
js_dir = stack.enter_context(tempfile.TemporaryDirectory(dir=js_path))
with open(os.path.join(js_dir, "dummy_js_script.js"), 'w'):
pass
else:
have_js_provider = False
xMasterProviderFactory = theMasterScriptProviderFactory.get(self.context)
@@ -92,8 +95,8 @@ class ProviderExpandAllTest(unittest.TestCase):
if node.hasChildNodes():
stack.extend(node.getChildNodes())
if not found_js_script:
self.skipTest("No active JavaScript provider found to process .js files")
if have_js_provider:
self.assertTrue(found_js_script)
# vim: set shiftwidth=4 softtabstop=4 expandtab: