Skip to content

Commit 1a80f15

Browse files
committed
fix(tests): applies copilot feedback, with rename
1 parent fd220cd commit 1a80f15

4 files changed

Lines changed: 35 additions & 35 deletions

File tree

tests/test_check_prerequisites_paths_only.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
CHECK_PREREQS_PS = PROJECT_ROOT / "scripts" / "powershell" / "check-prerequisites.ps1"
1818

1919
HAS_PWSH = shutil.which("pwsh") is not None
20-
_POWERSHELL = (shutil.which("powershell.exe") or shutil.which("powershell")) if os.name == "nt" else None
20+
_WINDOWS_POWERSHELL = (shutil.which("powershell.exe") or shutil.which("powershell")) if os.name == "nt" else None
2121

2222

2323
def _install_bash_scripts(repo: Path) -> None:
@@ -160,14 +160,14 @@ def test_normal_mode_still_validates_branch(prereq_repo: Path) -> None:
160160
# ── PowerShell tests ──────────────────────────────────────────────────────
161161

162162

163-
@pytest.mark.skipif(not (HAS_PWSH or _POWERSHELL), reason="no PowerShell available")
163+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
164164
def test_ps_paths_only_succeeds_on_non_spec_branch(prereq_repo: Path) -> None:
165165
"""-PathsOnly must return paths when feature.json pins the feature dir."""
166166
feat = prereq_repo / "specs" / "001-my-feature"
167167
feat.mkdir(parents=True, exist_ok=True)
168168
_write_feature_json(prereq_repo)
169169
script = prereq_repo / ".specify" / "scripts" / "powershell" / "check-prerequisites.ps1"
170-
exe = "pwsh" if HAS_PWSH else _POWERSHELL
170+
exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL
171171
result = subprocess.run(
172172
[exe, "-NoProfile", "-File", str(script), "-Json", "-PathsOnly"],
173173
cwd=prereq_repo,
@@ -183,7 +183,7 @@ def test_ps_paths_only_succeeds_on_non_spec_branch(prereq_repo: Path) -> None:
183183
assert "FEATURE_DIR" in data
184184

185185

186-
@pytest.mark.skipif(not (HAS_PWSH or _POWERSHELL), reason="no PowerShell available")
186+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
187187
def test_ps_paths_only_succeeds_on_spec_branch(prereq_repo: Path) -> None:
188188
"""-PathsOnly must also work when feature.json and SPECIFY_FEATURE agree."""
189189
subprocess.run(
@@ -195,7 +195,7 @@ def test_ps_paths_only_succeeds_on_spec_branch(prereq_repo: Path) -> None:
195195
feat.mkdir(parents=True, exist_ok=True)
196196
_write_feature_json(prereq_repo)
197197
script = prereq_repo / ".specify" / "scripts" / "powershell" / "check-prerequisites.ps1"
198-
exe = "pwsh" if HAS_PWSH else _POWERSHELL
198+
exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL
199199
env = _clean_env()
200200
env["SPECIFY_FEATURE"] = "001-my-feature"
201201
result = subprocess.run(
@@ -211,11 +211,11 @@ def test_ps_paths_only_succeeds_on_spec_branch(prereq_repo: Path) -> None:
211211
assert "FEATURE_DIR" in data
212212

213213

214-
@pytest.mark.skipif(not (HAS_PWSH or _POWERSHELL), reason="no PowerShell available")
214+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
215215
def test_ps_normal_mode_still_validates_branch(prereq_repo: Path) -> None:
216216
"""Without -PathsOnly, feature directory validation must still fail on main."""
217217
script = prereq_repo / ".specify" / "scripts" / "powershell" / "check-prerequisites.ps1"
218-
exe = "pwsh" if HAS_PWSH else _POWERSHELL
218+
exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL
219219
result = subprocess.run(
220220
[exe, "-NoProfile", "-File", str(script), "-Json"],
221221
cwd=prereq_repo,

tests/test_setup_plan_feature_json.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
PLAN_TEMPLATE = PROJECT_ROOT / "templates" / "plan-template.md"
1919

2020
HAS_PWSH = shutil.which("pwsh") is not None
21-
_POWERSHELL = (shutil.which("powershell.exe") or shutil.which("powershell")) if os.name == "nt" else None
21+
_WINDOWS_POWERSHELL = (shutil.which("powershell.exe") or shutil.which("powershell")) if os.name == "nt" else None
2222

2323

2424
def _install_bash_scripts(repo: Path) -> None:
@@ -153,7 +153,7 @@ def test_setup_plan_numbered_branch_works_with_feature_json(
153153
assert (feat / "plan.md").is_file()
154154

155155

156-
@pytest.mark.skipif(not (HAS_PWSH or _POWERSHELL), reason="no PowerShell available")
156+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
157157
def test_setup_plan_ps_passes_custom_branch_when_feature_json_valid(plan_repo: Path) -> None:
158158
subprocess.run(
159159
["git", "checkout", "-q", "-b", "feature/my-feature-branch"],
@@ -165,7 +165,7 @@ def test_setup_plan_ps_passes_custom_branch_when_feature_json_valid(plan_repo: P
165165
(feat / "spec.md").write_text("# spec\n", encoding="utf-8")
166166
_write_feature_json(plan_repo, "specs/001-tiny-notes-app")
167167
script = plan_repo / ".specify" / "scripts" / "powershell" / "setup-plan.ps1"
168-
exe = "pwsh" if HAS_PWSH else _POWERSHELL
168+
exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL
169169
result = subprocess.run(
170170
[exe, "-NoProfile", "-File", str(script)],
171171
cwd=plan_repo,
@@ -178,12 +178,12 @@ def test_setup_plan_ps_passes_custom_branch_when_feature_json_valid(plan_repo: P
178178
assert (feat / "plan.md").is_file()
179179

180180

181-
@pytest.mark.skipif(not (HAS_PWSH or _POWERSHELL), reason="no PowerShell available")
181+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
182182
def test_setup_plan_ps_errors_without_feature_context(
183183
plan_repo: Path,
184184
) -> None:
185185
script = plan_repo / ".specify" / "scripts" / "powershell" / "setup-plan.ps1"
186-
exe = "pwsh" if HAS_PWSH else _POWERSHELL
186+
exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL
187187
result = subprocess.run(
188188
[exe, "-NoProfile", "-File", str(script)],
189189
cwd=plan_repo,

tests/test_setup_plan_no_overwrite.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
PLAN_TEMPLATE = PROJECT_ROOT / "templates" / "plan-template.md"
1919

2020
HAS_PWSH = shutil.which("pwsh") is not None
21-
_POWERSHELL = (shutil.which("powershell.exe") or shutil.which("powershell")) if os.name == "nt" else None
21+
_WINDOWS_POWERSHELL = (shutil.which("powershell.exe") or shutil.which("powershell")) if os.name == "nt" else None
2222

2323

2424
def _install_bash_scripts(repo: Path) -> None:
@@ -178,11 +178,11 @@ def test_setup_plan_json_parseable_on_first_run(plan_repo: Path) -> None:
178178
# ── PowerShell tests ──────────────────────────────────────────────────────
179179

180180

181-
@pytest.mark.skipif(not (HAS_PWSH or _POWERSHELL), reason="no PowerShell available")
181+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
182182
def test_ps_setup_plan_creates_plan_when_missing(plan_repo: Path) -> None:
183183
"""First run must create plan.md from the template."""
184184
script = plan_repo / ".specify" / "scripts" / "powershell" / "setup-plan.ps1"
185-
exe = "pwsh" if HAS_PWSH else _POWERSHELL
185+
exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL
186186
result = subprocess.run(
187187
[exe, "-NoProfile", "-File", str(script), "-Json"],
188188
cwd=plan_repo,
@@ -199,7 +199,7 @@ def test_ps_setup_plan_creates_plan_when_missing(plan_repo: Path) -> None:
199199
assert len(content) > 0
200200

201201

202-
@pytest.mark.skipif(not (HAS_PWSH or _POWERSHELL), reason="no PowerShell available")
202+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
203203
def test_ps_setup_plan_preserves_existing_plan(plan_repo: Path) -> None:
204204
"""Rerun must not overwrite an existing plan.md."""
205205
feat = plan_repo / "specs" / "001-my-feature"
@@ -208,7 +208,7 @@ def test_ps_setup_plan_preserves_existing_plan(plan_repo: Path) -> None:
208208
(feat / "plan.md").write_text(existing_content, encoding="utf-8")
209209

210210
script = plan_repo / ".specify" / "scripts" / "powershell" / "setup-plan.ps1"
211-
exe = "pwsh" if HAS_PWSH else _POWERSHELL
211+
exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL
212212
result = subprocess.run(
213213
[exe, "-NoProfile", "-File", str(script), "-Json"],
214214
cwd=plan_repo,

tests/test_setup_tasks.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
TASKS_TEMPLATE = PROJECT_ROOT / "templates" / "tasks-template.md"
2121

2222
HAS_PWSH = shutil.which("pwsh") is not None
23-
_POWERSHELL = (shutil.which("powershell.exe") or shutil.which("powershell")) if os.name == "nt" else None
23+
_WINDOWS_POWERSHELL = (shutil.which("powershell.exe") or shutil.which("powershell")) if os.name == "nt" else None
2424

2525

2626
# ---------------------------------------------------------------------------
@@ -118,7 +118,7 @@ def _run_bash_format_command(repo: Path, command_name: str) -> subprocess.Comple
118118

119119
def _run_powershell_format_command(repo: Path, command_name: str) -> subprocess.CompletedProcess:
120120
script = repo / ".specify" / "scripts" / "powershell" / "common.ps1"
121-
exe = "pwsh" if HAS_PWSH else _POWERSHELL
121+
exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL
122122
return subprocess.run(
123123
[
124124
exe,
@@ -606,7 +606,7 @@ def test_setup_tasks_bash_errors_without_feature_context(
606606
# POWERSHELL TESTS
607607
# ===========================================================================
608608

609-
@pytest.mark.skipif(not (HAS_PWSH or _POWERSHELL), reason="no PowerShell available")
609+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
610610
def test_setup_tasks_ps_core_template_resolved(tasks_repo: Path) -> None:
611611
"""
612612
When the core tasks-template.md is present and all prerequisites are met,
@@ -615,7 +615,7 @@ def test_setup_tasks_ps_core_template_resolved(tasks_repo: Path) -> None:
615615
"""
616616
_minimal_feature(tasks_repo)
617617
script = tasks_repo / ".specify" / "scripts" / "powershell" / "setup-tasks.ps1"
618-
exe = "pwsh" if HAS_PWSH else _POWERSHELL
618+
exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL
619619

620620
result = subprocess.run(
621621
[exe, "-NoProfile", "-File", str(script), "-Json"],
@@ -635,7 +635,7 @@ def test_setup_tasks_ps_core_template_resolved(tasks_repo: Path) -> None:
635635
assert tasks_tmpl.name == "tasks-template.md"
636636

637637

638-
@pytest.mark.skipif(not (HAS_PWSH or _POWERSHELL), reason="no PowerShell available")
638+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
639639
def test_setup_tasks_ps_override_wins(tasks_repo: Path) -> None:
640640
"""
641641
When an override exists at .specify/templates/overrides/tasks-template.md,
@@ -649,7 +649,7 @@ def test_setup_tasks_ps_override_wins(tasks_repo: Path) -> None:
649649
override_file.write_text("# override tasks template\n", encoding="utf-8")
650650

651651
script = tasks_repo / ".specify" / "scripts" / "powershell" / "setup-tasks.ps1"
652-
exe = "pwsh" if HAS_PWSH else _POWERSHELL
652+
exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL
653653

654654
result = subprocess.run(
655655
[exe, "-NoProfile", "-File", str(script), "-Json"],
@@ -671,7 +671,7 @@ def test_setup_tasks_ps_override_wins(tasks_repo: Path) -> None:
671671
)
672672

673673

674-
@pytest.mark.skipif(not (HAS_PWSH or _POWERSHELL), reason="no PowerShell available")
674+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
675675
def test_setup_tasks_ps_missing_template_errors(tasks_repo: Path) -> None:
676676
"""
677677
When tasks-template.md is absent from all locations, setup-tasks.ps1 must
@@ -683,7 +683,7 @@ def test_setup_tasks_ps_missing_template_errors(tasks_repo: Path) -> None:
683683
core.unlink()
684684

685685
script = tasks_repo / ".specify" / "scripts" / "powershell" / "setup-tasks.ps1"
686-
exe = "pwsh" if HAS_PWSH else _POWERSHELL
686+
exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL
687687

688688
result = subprocess.run(
689689
[exe, "-NoProfile", "-File", str(script), "-Json"],
@@ -698,7 +698,7 @@ def test_setup_tasks_ps_missing_template_errors(tasks_repo: Path) -> None:
698698
assert "tasks-template" in result.stderr.lower() or "tasks-template" in result.stdout.lower()
699699

700700

701-
@pytest.mark.skipif(not (HAS_PWSH or _POWERSHELL), reason="no PowerShell available")
701+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
702702
def test_powershell_command_hint_normalizes_mixed_separators(
703703
tasks_repo: Path,
704704
) -> None:
@@ -717,7 +717,7 @@ def test_powershell_command_hint_normalizes_mixed_separators(
717717
assert result.stdout.strip() == "/speckit-git-commit"
718718

719719

720-
@pytest.mark.skipif(not (HAS_PWSH or _POWERSHELL), reason="no PowerShell available")
720+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
721721
def test_powershell_command_hint_preserves_hyphens_inside_segments(
722722
tasks_repo: Path,
723723
) -> None:
@@ -729,7 +729,7 @@ def test_powershell_command_hint_preserves_hyphens_inside_segments(
729729
assert result.stdout.strip() == "/speckit.jira.sync-status"
730730

731731

732-
@pytest.mark.skipif(not (HAS_PWSH or _POWERSHELL), reason="no PowerShell available")
732+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
733733
def test_setup_tasks_ps_uses_invoke_separator_in_plan_hint(tasks_repo: Path) -> None:
734734
_write_integration_state(tasks_repo, "claude", "-")
735735
feat = tasks_repo / "specs" / "001-my-feature"
@@ -738,7 +738,7 @@ def test_setup_tasks_ps_uses_invoke_separator_in_plan_hint(tasks_repo: Path) ->
738738
_write_feature_json(tasks_repo)
739739

740740
script = tasks_repo / ".specify" / "scripts" / "powershell" / "setup-tasks.ps1"
741-
exe = "pwsh" if HAS_PWSH else _POWERSHELL
741+
exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL
742742

743743
result = subprocess.run(
744744
[exe, "-NoProfile", "-File", str(script), "-Json"],
@@ -755,15 +755,15 @@ def test_setup_tasks_ps_uses_invoke_separator_in_plan_hint(tasks_repo: Path) ->
755755
assert "/speckit.plan" not in output
756756

757757

758-
@pytest.mark.skipif(not (HAS_PWSH or _POWERSHELL), reason="no PowerShell available")
758+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
759759
def test_check_prerequisites_ps_uses_invoke_separator_in_tasks_hint(
760760
tasks_repo: Path,
761761
) -> None:
762762
_write_integration_state(tasks_repo, "claude", "-")
763763
_minimal_feature(tasks_repo)
764764

765765
script = tasks_repo / ".specify" / "scripts" / "powershell" / "check-prerequisites.ps1"
766-
exe = "pwsh" if HAS_PWSH else _POWERSHELL
766+
exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL
767767

768768
result = subprocess.run(
769769
[exe, "-NoProfile", "-File", str(script), "-RequireTasks"],
@@ -780,7 +780,7 @@ def test_check_prerequisites_ps_uses_invoke_separator_in_tasks_hint(
780780
assert "/speckit.tasks" not in output
781781

782782

783-
@pytest.mark.skipif(not (HAS_PWSH or _POWERSHELL), reason="no PowerShell available")
783+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
784784
def test_setup_tasks_ps_passes_custom_branch_when_feature_json_valid(
785785
tasks_repo: Path,
786786
) -> None:
@@ -801,7 +801,7 @@ def test_setup_tasks_ps_passes_custom_branch_when_feature_json_valid(
801801
_write_feature_json(tasks_repo)
802802

803803
script = tasks_repo / ".specify" / "scripts" / "powershell" / "setup-tasks.ps1"
804-
exe = "pwsh" if HAS_PWSH else _POWERSHELL
804+
exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL
805805

806806
result = subprocess.run(
807807
[exe, "-NoProfile", "-File", str(script), "-Json"],
@@ -815,7 +815,7 @@ def test_setup_tasks_ps_passes_custom_branch_when_feature_json_valid(
815815
assert result.returncode == 0, result.stderr + result.stdout
816816

817817

818-
@pytest.mark.skipif(not (HAS_PWSH or _POWERSHELL), reason="no PowerShell available")
818+
@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")
819819
def test_setup_tasks_ps_errors_without_feature_context(
820820
tasks_repo: Path,
821821
) -> None:
@@ -826,7 +826,7 @@ def test_setup_tasks_ps_errors_without_feature_context(
826826
(main_feat / "plan.md").write_text("# plan\n", encoding="utf-8")
827827

828828
script = tasks_repo / ".specify" / "scripts" / "powershell" / "setup-tasks.ps1"
829-
exe = "pwsh" if HAS_PWSH else _POWERSHELL
829+
exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL
830830

831831
result = subprocess.run(
832832
[exe, "-NoProfile", "-File", str(script), "-Json"],

0 commit comments

Comments
 (0)