tests: add variable to suppress TTS tests

TTS support can be gated on e.g. Gentoo's USE=speech, so we don't want
to run the basic selfcheck of speech support if this is disabled. We do
want to run the general Qt checks, though (and also do a selfcheck of
speech support if the USE=speech is enabled!) -- so add a sneaky
environment variable that we can use to conditionally skip running those
parts.
This commit is contained in:
Eli Schwartz 2024-09-16 23:27:11 -04:00
parent 7792a0c3be
commit 66e847f972
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
2 changed files with 11 additions and 5 deletions

View File

@ -123,6 +123,7 @@ class BuildTest(unittest.TestCase):
from speechd.client import SSIPClient
del SSIPClient
@unittest.skipIf('SKIP_SPEECH_TESTS' in os.environ, 'Speech support is opted out')
def test_piper(self):
import subprocess
@ -322,7 +323,7 @@ class BuildTest(unittest.TestCase):
def test_qt(self):
if is_sanitized:
raise unittest.SkipTest('Skipping Qt build test as sanitizer is enabled')
from qt.core import QApplication, QFontDatabase, QImageReader, QLoggingCategory, QMediaDevices, QNetworkAccessManager, QSslSocket, QTextToSpeech, QTimer
from qt.core import QApplication, QFontDatabase, QImageReader, QLoggingCategory, QNetworkAccessManager, QSslSocket, QTimer
QLoggingCategory.setFilterRules('''qt.webenginecontext.debug=true''')
if hasattr(os, 'geteuid') and os.geteuid() == 0:
# likely a container build, webengine cannot run as root with sandbox
@ -356,12 +357,15 @@ class BuildTest(unittest.TestCase):
try:
ensure_app()
self.assertGreaterEqual(len(QFontDatabase.families()), 5, 'The QPA headless plugin is not able to locate enough system fonts via fontconfig')
available_tts_engines = tuple(x for x in QTextToSpeech.availableEngines() if x != 'mock')
self.assertTrue(available_tts_engines)
QMediaDevices.audioOutputs()
if 'SKIP_SPEECH_TESTS' not in os.environ:
from qt.core import QMediaDevices, QTextToSpeech
available_tts_engines = tuple(x for x in QTextToSpeech.availableEngines() if x != 'mock')
self.assertTrue(available_tts_engines)
QMediaDevices.audioOutputs()
self.assertGreaterEqual
from calibre.ebooks.oeb.transforms.rasterize import rasterize_svg
img = rasterize_svg(as_qimage=True)
self.assertFalse(img.isNull())

View File

@ -190,6 +190,8 @@ class TestImports(unittest.TestCase):
'calibre.utils.linux_trash', 'calibre.utils.open_with.linux',
'calibre.gui2.linux_file_dialogs',
}
if 'SKIP_SPEECH_TESTS' in os.environ:
exclude_packages.add('calibre.gui2.tts')
if not isbsd:
exclude_modules.add('calibre.devices.usbms.hal')
d = os.path.dirname