Skip to content

Commit d99d960

Browse files
committed
fix: update tests for tikalk-specific scripts and context.md creation
- Add tikalk-specific bash/powershell scripts to test expectations - Fix create-new-feature.sh to create context.md from template - Update inventory tests for all integrations to expect additional scripts
1 parent 3aee2fa commit d99d960

6 files changed

Lines changed: 668 additions & 272 deletions

scripts/bash/create-new-feature.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,15 @@ if [ "$DRY_RUN" != true ]; then
364364
fi
365365
fi
366366

367+
# Create context.md if template exists
368+
CONTEXT_FILE="$FEATURE_DIR/context.md"
369+
if [ ! -f "$CONTEXT_FILE" ]; then
370+
CONTEXT_TEMPLATE=$(resolve_template "context-template" "$REPO_ROOT") || true
371+
if [ -n "$CONTEXT_TEMPLATE" ] && [ -f "$CONTEXT_TEMPLATE" ]; then
372+
cp "$CONTEXT_TEMPLATE" "$CONTEXT_FILE"
373+
fi
374+
fi
375+
367376
# Inform the user how to persist the feature variable in their own shell
368377
printf '# To persist: export SPECIFY_FEATURE=%q\n' "$BRANCH_NAME" >&2
369378
fi

tests/integrations/test_integration_base_markdown.py

Lines changed: 125 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ def test_setup_writes_to_correct_directory(self, tmp_path):
7878
m = IntegrationManifest(self.KEY, tmp_path)
7979
created = i.setup(tmp_path, m)
8080
expected_dir = i.commands_dest(tmp_path)
81-
assert expected_dir.exists(), f"Expected directory {expected_dir} was not created"
81+
assert expected_dir.exists(), (
82+
f"Expected directory {expected_dir} was not created"
83+
)
8284
cmd_files = [f for f in created if "scripts" not in f.parts]
8385
assert len(cmd_files) > 0, "No command files were created"
8486
for f in cmd_files:
@@ -98,8 +100,12 @@ def test_templates_are_processed(self, tmp_path):
98100
assert "{SCRIPT}" not in content, f"{f.name} has unprocessed {{SCRIPT}}"
99101
assert "__AGENT__" not in content, f"{f.name} has unprocessed __AGENT__"
100102
assert "{ARGS}" not in content, f"{f.name} has unprocessed {{ARGS}}"
101-
assert "\nscripts:\n" not in content, f"{f.name} has unstripped scripts: block"
102-
assert "\nagent_scripts:\n" not in content, f"{f.name} has unstripped agent_scripts: block"
103+
assert "\nscripts:\n" not in content, (
104+
f"{f.name} has unstripped scripts: block"
105+
)
106+
assert "\nagent_scripts:\n" not in content, (
107+
f"{f.name} has unstripped agent_scripts: block"
108+
)
103109

104110
def test_all_files_tracked_in_manifest(self, tmp_path):
105111
i = get_integration(self.KEY)
@@ -154,7 +160,14 @@ def test_sh_script_is_executable(self, tmp_path):
154160
i = get_integration(self.KEY)
155161
m = IntegrationManifest(self.KEY, tmp_path)
156162
i.setup(tmp_path, m)
157-
sh = tmp_path / ".specify" / "integrations" / self.KEY / "scripts" / "update-context.sh"
163+
sh = (
164+
tmp_path
165+
/ ".specify"
166+
/ "integrations"
167+
/ self.KEY
168+
/ "scripts"
169+
/ "update-context.sh"
170+
)
158171
assert os.access(sh, os.X_OK)
159172

160173
# -- CLI auto-promote -------------------------------------------------
@@ -169,10 +182,20 @@ def test_ai_flag_auto_promotes(self, tmp_path):
169182
try:
170183
os.chdir(project)
171184
runner = CliRunner()
172-
result = runner.invoke(app, [
173-
"init", "--here", "--ai", self.KEY, "--script", "sh", "--no-git",
174-
"--ignore-agent-tools",
175-
], catch_exceptions=False)
185+
result = runner.invoke(
186+
app,
187+
[
188+
"init",
189+
"--here",
190+
"--ai",
191+
self.KEY,
192+
"--script",
193+
"sh",
194+
"--no-git",
195+
"--ignore-agent-tools",
196+
],
197+
catch_exceptions=False,
198+
)
176199
finally:
177200
os.chdir(old_cwd)
178201
assert result.exit_code == 0, f"init --ai {self.KEY} failed: {result.output}"
@@ -190,13 +213,25 @@ def test_integration_flag_creates_files(self, tmp_path):
190213
try:
191214
os.chdir(project)
192215
runner = CliRunner()
193-
result = runner.invoke(app, [
194-
"init", "--here", "--integration", self.KEY, "--script", "sh", "--no-git",
195-
"--ignore-agent-tools",
196-
], catch_exceptions=False)
216+
result = runner.invoke(
217+
app,
218+
[
219+
"init",
220+
"--here",
221+
"--integration",
222+
self.KEY,
223+
"--script",
224+
"sh",
225+
"--no-git",
226+
"--ignore-agent-tools",
227+
],
228+
catch_exceptions=False,
229+
)
197230
finally:
198231
os.chdir(old_cwd)
199-
assert result.exit_code == 0, f"init --integration {self.KEY} failed: {result.output}"
232+
assert result.exit_code == 0, (
233+
f"init --integration {self.KEY} failed: {result.output}"
234+
)
200235
i = get_integration(self.KEY)
201236
cmd_dir = i.commands_dest(project)
202237
assert cmd_dir.is_dir(), f"Commands directory {cmd_dir} not created"
@@ -206,8 +241,15 @@ def test_integration_flag_creates_files(self, tmp_path):
206241
# -- Complete file inventory ------------------------------------------
207242

208243
COMMAND_STEMS = [
209-
"analyze", "checklist", "clarify", "constitution",
210-
"implement", "plan", "specify", "tasks", "taskstoissues",
244+
"analyze",
245+
"checklist",
246+
"clarify",
247+
"constitution",
248+
"implement",
249+
"plan",
250+
"specify",
251+
"tasks",
252+
"taskstoissues",
211253
]
212254

213255
def _expected_files(self, script_variant: str) -> list[str]:
@@ -231,17 +273,44 @@ def _expected_files(self, script_variant: str) -> list[str]:
231273
files.append(f".specify/integrations/speckit.manifest.json")
232274

233275
if script_variant == "sh":
234-
for name in ["check-prerequisites.sh", "common.sh", "create-new-feature.sh",
235-
"setup-plan.sh", "update-agent-context.sh"]:
276+
for name in [
277+
"check-prerequisites.sh",
278+
"common.sh",
279+
"create-new-feature.sh",
280+
"generate-risk-tests.sh",
281+
"implement.sh",
282+
"scan-project-artifacts.sh",
283+
"setup-constitution.sh",
284+
"setup-plan.sh",
285+
"tasks-meta-utils.sh",
286+
"update-agent-context.sh",
287+
"validate-constitution.sh",
288+
]:
236289
files.append(f".specify/scripts/bash/{name}")
237290
else:
238-
for name in ["check-prerequisites.ps1", "common.ps1", "create-new-feature.ps1",
239-
"setup-plan.ps1", "update-agent-context.ps1"]:
291+
for name in [
292+
"Detect-WorkflowConfig.ps1",
293+
"check-prerequisites.ps1",
294+
"common.ps1",
295+
"create-new-feature.ps1",
296+
"discovery-functions.ps1",
297+
"implement.ps1",
298+
"scan-project-artifacts.ps1",
299+
"setup-constitution.ps1",
300+
"setup-plan.ps1",
301+
"update-agent-context.ps1",
302+
"validate-constitution.ps1",
303+
]:
240304
files.append(f".specify/scripts/powershell/{name}")
241305

242-
for name in ["agent-file-template.md", "checklist-template.md",
243-
"constitution-template.md", "plan-template.md",
244-
"spec-template.md", "tasks-template.md"]:
306+
for name in [
307+
"agent-file-template.md",
308+
"checklist-template.md",
309+
"constitution-template.md",
310+
"plan-template.md",
311+
"spec-template.md",
312+
"tasks-template.md",
313+
]:
245314
files.append(f".specify/templates/{name}")
246315

247316
files.append(".specify/memory/constitution.md")
@@ -257,15 +326,26 @@ def test_complete_file_inventory_sh(self, tmp_path):
257326
old_cwd = os.getcwd()
258327
try:
259328
os.chdir(project)
260-
result = CliRunner().invoke(app, [
261-
"init", "--here", "--integration", self.KEY, "--script", "sh",
262-
"--no-git", "--ignore-agent-tools",
263-
], catch_exceptions=False)
329+
result = CliRunner().invoke(
330+
app,
331+
[
332+
"init",
333+
"--here",
334+
"--integration",
335+
self.KEY,
336+
"--script",
337+
"sh",
338+
"--no-git",
339+
"--ignore-agent-tools",
340+
],
341+
catch_exceptions=False,
342+
)
264343
finally:
265344
os.chdir(old_cwd)
266345
assert result.exit_code == 0, f"init failed: {result.output}"
267-
actual = sorted(p.relative_to(project).as_posix()
268-
for p in project.rglob("*") if p.is_file())
346+
actual = sorted(
347+
p.relative_to(project).as_posix() for p in project.rglob("*") if p.is_file()
348+
)
269349
expected = self._expected_files("sh")
270350
assert actual == expected, (
271351
f"Missing: {sorted(set(expected) - set(actual))}\n"
@@ -282,15 +362,26 @@ def test_complete_file_inventory_ps(self, tmp_path):
282362
old_cwd = os.getcwd()
283363
try:
284364
os.chdir(project)
285-
result = CliRunner().invoke(app, [
286-
"init", "--here", "--integration", self.KEY, "--script", "ps",
287-
"--no-git", "--ignore-agent-tools",
288-
], catch_exceptions=False)
365+
result = CliRunner().invoke(
366+
app,
367+
[
368+
"init",
369+
"--here",
370+
"--integration",
371+
self.KEY,
372+
"--script",
373+
"ps",
374+
"--no-git",
375+
"--ignore-agent-tools",
376+
],
377+
catch_exceptions=False,
378+
)
289379
finally:
290380
os.chdir(old_cwd)
291381
assert result.exit_code == 0, f"init failed: {result.output}"
292-
actual = sorted(p.relative_to(project).as_posix()
293-
for p in project.rglob("*") if p.is_file())
382+
actual = sorted(
383+
p.relative_to(project).as_posix() for p in project.rglob("*") if p.is_file()
384+
)
294385
expected = self._expected_files("ps")
295386
assert actual == expected, (
296387
f"Missing: {sorted(set(expected) - set(actual))}\n"

0 commit comments

Comments
 (0)