45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
"""Exercise installer Qt selection without touching host packages."""
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import unittest
|
|
|
|
source = (Path(__file__).parents[1] / 'stage_itscreen/stage_itscreen_install.sh').read_text()
|
|
functions = source[source.index('prepare_qt_gles_stack() {'):source.index('install_qt_video_oes_plugin() {')]
|
|
|
|
class QtStackTest(unittest.TestCase):
|
|
def run_selection(self, existing):
|
|
stubs = '''
|
|
step() { :; }
|
|
log() { :; }
|
|
ldconfig() { :; }
|
|
apt-mark() { echo MUTATE; }
|
|
apt-get() { echo MUTATE; }
|
|
dpkg-query() {
|
|
if [[ "$EXISTING" == 1 ]]; then printf 'install ok installed'; else return 1; fi
|
|
}
|
|
install_packages_best_effort() { printf '%s\\n' "$*"; }
|
|
run_long() { printf '%s\\n' "$*"; }
|
|
'''
|
|
return subprocess.check_output(['bash', '-ec', stubs + functions + '\nprepare_qt_gles_stack\ninstall_qt_packages'],
|
|
env={**os.environ, 'EXISTING': str(existing)}, text=True)
|
|
|
|
def test_existing_desktop_stack_is_preserved(self):
|
|
output = self.run_selection(1)
|
|
self.assertIn('libqt5gui5 libqt5quick5', output)
|
|
self.assertNotIn('libqt5gui5-gles', output)
|
|
self.assertNotIn('MUTATE', output)
|
|
|
|
def test_fresh_image_gets_gles(self):
|
|
self.assertIn('libqt5gui5-gles libqt5quick5-gles', self.run_selection(0))
|
|
|
|
def test_required_player_qml_modules_use_strict_install(self):
|
|
output = self.run_selection(0)
|
|
self.assertIn(
|
|
'apt-get install -y --no-remove qml-module-qtquick-window2 '
|
|
'qml-module-qtquick-layouts qml-module-qtquick-controls',
|
|
output,
|
|
)
|
|
|
|
if __name__ == '__main__': unittest.main()
|