Initial import of DxDesigner part replacement tool (r21)
This commit is contained in:
commit
ffe066cb1e
151 files changed
+58745
No files matched your search
@@ -0,0 +1,90 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def test_build_files_target_only_repository_local_dx_part_replace_outputs() -> None:
|
||||
"""Broad cleanup in the release script could delete a user's unrelated build output."""
|
||||
root = Path(__file__).resolve().parents[2]
|
||||
spec = root / "packaging" / "DxPartReplace.spec"
|
||||
script = root / "packaging" / "Build-DxPartReplace.ps1"
|
||||
|
||||
assert spec.is_file()
|
||||
assert script.is_file()
|
||||
spec_text = spec.read_text(encoding="utf-8")
|
||||
script_text = script.read_text(encoding="utf-8")
|
||||
assert "name='DxPartReplace'" in spec_text
|
||||
assert "console=False" in spec_text
|
||||
assert "Resolve-Path -LiteralPath" in script_text
|
||||
assert "build\\DxPartReplace" in script_text
|
||||
assert "dist\\DxPartReplace" in script_text
|
||||
assert "Remove-Item -LiteralPath" in script_text
|
||||
assert "DxPartReplace.exe" in script_text
|
||||
assert "QuickPartReplace.vbs" in spec_text
|
||||
assert "legacy-runtime/dxdesigner795" in spec_text
|
||||
assert '"viewdraw_api"' in spec_text
|
||||
assert '"win32com.client"' in spec_text
|
||||
assert '"pywinauto.controls.uiawrapper"' in spec_text
|
||||
assert 'collect_data_files("PySide6")' not in spec_text
|
||||
assert 'collect_dynamic_libs("PySide6")' not in spec_text
|
||||
assert '"PySide6.QtWebEngineCore"' in spec_text
|
||||
assert '"qt6quick.dll"' in spec_text
|
||||
assert '"qpdf.dll"' in spec_text
|
||||
assert "Get-FileHash" in script_text
|
||||
assert "QuickPartReplace.vbs" in script_text
|
||||
assert "packaged QuickPartReplace.vbs" in script_text
|
||||
assert "--smoke-test" in script_text
|
||||
assert "--data-root" in script_text
|
||||
assert "DxPartReplace-smoke-" in script_text
|
||||
assert "application_start" in script_text
|
||||
assert "application_clean_shutdown" in script_text
|
||||
assert "Start-Process -FilePath $executable" in script_text
|
||||
assert "-Wait" in script_text
|
||||
assert "-PassThru" in script_text
|
||||
assert "-WindowStyle Hidden" in script_text
|
||||
assert "$smokeProcess.ExitCode" in script_text
|
||||
assert "$quotedSmokeRoot = '\"' + $smokeRoot + '\"'" in script_text
|
||||
assert '"--data-root", $quotedSmokeRoot' in script_text
|
||||
assert ".venv\\Scripts\\python.exe" in script_text
|
||||
assert "DxPartReplace-preserved-data" in script_text
|
||||
assert "Move-Item -LiteralPath $distData" in script_text
|
||||
assert 'Join-Path (Split-Path -Parent $executable) "data"' in script_text
|
||||
|
||||
|
||||
def test_start_process_argument_probe_preserves_a_spaced_data_root(tmp_path: Path) -> None:
|
||||
"""Start-Process joins ArgumentList values, so the data-root value must carry its own quotes."""
|
||||
probe = tmp_path / "probe.py"
|
||||
output = tmp_path / "arguments.json"
|
||||
smoke_root = tmp_path / "smoke root"
|
||||
probe.write_text(
|
||||
"import json, sys\nfrom pathlib import Path\nPath(sys.argv[1]).write_text(json.dumps(sys.argv[2:]))\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
environment = os.environ | {
|
||||
"SMOKE_ROOT": str(smoke_root),
|
||||
"PROBE_SCRIPT": str(probe),
|
||||
"PROBE_OUTPUT": str(output),
|
||||
"PYTHON_EXE": sys.executable,
|
||||
}
|
||||
script = """
|
||||
$quotedSmokeRoot = '"' + $env:SMOKE_ROOT + '"'
|
||||
$quotedProbe = '"' + $env:PROBE_SCRIPT + '"'
|
||||
$quotedOutput = '"' + $env:PROBE_OUTPUT + '"'
|
||||
$probeProcess = Start-Process -FilePath $env:PYTHON_EXE -ArgumentList @($quotedProbe, $quotedOutput, "--data-root", $quotedSmokeRoot) -Wait -PassThru
|
||||
exit $probeProcess.ExitCode
|
||||
"""
|
||||
|
||||
completed = subprocess.run(
|
||||
["powershell.exe", "-NoProfile", "-Command", script],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
env=environment,
|
||||
check=False,
|
||||
)
|
||||
|
||||
assert completed.returncode == 0, completed.stderr
|
||||
assert json.loads(output.read_text(encoding="utf-8")) == ["--data-root", str(smoke_root)]
|
||||
Reference in new issue
Block a user