37 lines
2.0 KiB
Python
37 lines
2.0 KiB
Python
"""Catch missing runtime assets and mismatched version identity before release."""
|
|
import ast
|
|
from pathlib import Path
|
|
import tomllib
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def test_release_version_matches_python_and_windows_resources():
|
|
namespace = {}
|
|
exec((ROOT / 'src/dx_productivity/trial_task_center/version.py').read_text(), namespace)
|
|
version = namespace['VERSION']
|
|
assert tomllib.loads((ROOT / 'pyproject.toml').read_text())['project']['version'] == version
|
|
info = (ROOT / 'packaging/windows-version-info.txt').read_text()
|
|
assert f"StringStruct('ProductVersion', '{version}')" in info
|
|
parts = tuple(int(n) for n in version.split('.')) + (0,)
|
|
assert f'filevers={parts}' in info and f'prodvers={parts}' in info
|
|
|
|
|
|
def test_release_spec_includes_all_assets_and_complete_runtime():
|
|
tree = ast.parse((ROOT / 'packaging/DxPartReplace.spec').read_text())
|
|
constants = {node.value for node in ast.walk(tree) if isinstance(node, ast.Constant) and isinstance(node.value, str)}
|
|
assert 'src/dx_productivity/trial_task_center/assets' in constants
|
|
assert not any(isinstance(node, ast.Call) and isinstance(node.func, ast.Name)
|
|
and node.func.id == 'stage_node_modules' for node in ast.walk(tree))
|
|
assert {'dsh-runtime/node_modules', 'dsh-runtime/task-plugin',
|
|
'issue-bootstrap.json', 'PySide6.QtWebEngineCore',
|
|
'PySide6.QtWebEngineWidgets'} <= constants
|
|
analysis = next(node for node in ast.walk(tree) if isinstance(node, ast.Call)
|
|
and isinstance(node.func, ast.Name) and node.func.id == 'Analysis')
|
|
options = {arg.arg: ast.literal_eval(arg.value) for arg in analysis.keywords
|
|
if arg.arg in {'hiddenimports', 'excludes'}}
|
|
web_dependencies = {'PySide6.QtWebChannel', 'PySide6.QtQml', 'PySide6.QtQuick',
|
|
'PySide6.QtOpenGL', 'PySide6.QtOpenGLWidgets'}
|
|
assert web_dependencies <= set(options['hiddenimports'])
|
|
assert web_dependencies.isdisjoint(options['excludes'])
|