File tree Expand file tree Collapse file tree
src/specify_cli/integrations Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -644,7 +644,13 @@ def select_script_variant(
644644 platform_variant = (
645645 "ps" if platform .system ().lower ().startswith ("win" ) else "sh"
646646 )
647- for candidate in (platform_variant , "py" ):
647+ secondary_variant = "sh" if platform_variant == "ps" else "ps"
648+ fallbacks = (
649+ (platform_variant , "py" )
650+ if requested == "py"
651+ else (platform_variant , secondary_variant , "py" )
652+ )
653+ for candidate in fallbacks :
648654 if candidate in script_commands :
649655 return candidate
650656
Original file line number Diff line number Diff line change @@ -84,17 +84,35 @@ def test_template_renders_python_invocation(name: str):
8484
8585
8686def test_py_missing_variant_rejects_opposite_shell_only ():
87+ opposite_variant = "sh" if os .name == "nt" else "ps"
88+ opposite_command = (
89+ "scripts/bash/setup-plan.sh --json"
90+ if opposite_variant == "sh"
91+ else "scripts/powershell/setup-plan.ps1 -Json"
92+ )
8793 content = """---
8894scripts:
89- ps: scripts/powershell/setup-plan.ps1 -Json
95+ {variant}: {command}
9096---
91- Run {SCRIPT} now.
92- """
97+ Run {{ SCRIPT} } now.
98+ """ . format ( variant = opposite_variant , command = opposite_command )
9399
94100 with pytest .raises (ValueError , match = "No runnable script variant" ):
95101 IntegrationBase .process_template (content , "agent" , "py" )
96102
97103
104+ def test_missing_script_preference_keeps_available_shell (monkeypatch ):
105+ monkeypatch .setattr (
106+ "specify_cli.integrations.base.platform.system" , lambda : "Windows"
107+ )
108+
109+ selected = IntegrationBase .select_script_variant (
110+ None , {"sh" : "scripts/bash/setup-plan.sh --json" }
111+ )
112+
113+ assert selected == "sh"
114+
115+
98116def test_spaced_python_interpreter_uses_powershell_call_operator (monkeypatch ):
99117 interpreter = r"C:\Program Files\Py$thon's\python.exe"
100118 quoted_interpreter = interpreter .replace ("'" , "''" )
You can’t perform that action at this time.
0 commit comments