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