"""Link the compatibility regression against the existing Release objects.""" import os from pathlib import Path import runpy import subprocess import sys root = Path(__file__).resolve().parents[1] helpers = runpy.run_path(str(root / 'tests/run_theme_shell_test.py')) args, value = helpers['args'], helpers['value'] qt, toolchain = helpers['qt'], helpers['toolchain'] env = dict(os.environ) env['PATH'] = os.pathsep.join((str(toolchain), str(qt / 'bin'), str(root / 'bin/release'), env['PATH'])) env['QT_QPA_PLATFORM'] = 'offscreen' env['QT_QPA_FONTDIR'] = 'C:/Windows/Fonts' output = root / 'build/armcompatibility-test' output.mkdir(parents=True, exist_ok=True) obj, binary = output / 'test.o', output / 'armcompatibility_test.exe' flags = value('CXXFLAGS').replace('$(DEFINES)', value('DEFINES')) subprocess.run([str(toolchain / 'g++.exe'), '-c', *args(flags), *args(value('INCPATH')), '-I' + str(root / 'src'), str(root / 'tests/armcompatibility_test.cpp'), '-o', str(obj)], cwd=root, env=env, check=True) objects = (root / 'object_script.CmvrControlStation.Release').read_text().splitlines() objects = [item for item in objects if not item.replace('\\', '/').endswith('/main.o')] response = output / 'objects.rsp' response.write_text('\n'.join(objects), encoding='utf-8') subprocess.run([str(toolchain / 'g++.exe'), '-mthreads', '-o', str(binary), str(obj), '@' + str(response), *args(value('LIBS'))], cwd=root, env=env, check=True) subprocess.run([str(binary), *sys.argv[1:]], cwd=output, env=env, check=True, timeout=90)