test_windows_remote_entrypoints.py 1.2 KB

123456789101112131415161718192021222324
  1. """Run on Windows: exercise native PowerShell argument and exit-code forwarding."""
  2. from pathlib import Path
  3. import json
  4. import shutil
  5. import subprocess
  6. import pytest
  7. ROOT=Path(__file__).resolve().parents[2]
  8. @pytest.mark.parametrize('entry', ['tools/remote/prod2u-remote.ps1','tools/windows/remote-run.ps1'])
  9. @pytest.mark.parametrize('tail', [[], ['--','python3','-u','-c','print("literal \u4e2d\u6587 $() `quoted`")']])
  10. def test_native_powershell_preserves_child_options_and_failure(tmp_path,entry,tail):
  11. powershell=shutil.which('pwsh')
  12. if not powershell:
  13. pytest.skip('native PowerShell required; run this suite in the Windows build environment')
  14. root=tmp_path/'source \u4e2d\u6587 space';script=root/entry
  15. script.parent.mkdir(parents=True)
  16. shutil.copy2(ROOT/entry,script)
  17. (root/'tools/remote_job.py').write_text('import json,sys\nprint(json.dumps(sys.argv[1:])); raise SystemExit(7)\n',encoding='utf-8')
  18. args=['--ssh-runner','/exact \u4e2d\u6587 space/tools/remote_job.py','submit','run-id','--target','mrdimm-chamber',*tail]
  19. result=subprocess.run([powershell,'-NoProfile','-File',str(script),*args],capture_output=True,encoding='utf-8')
  20. assert result.returncode==7,result.stderr
  21. assert json.loads(result.stdout)==args