cc-devflow 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/CLAUDE.md +83 -0
- package/.claude/agents/architecture-designer.md +443 -0
- package/.claude/agents/bug-analyzer.md +382 -0
- package/.claude/agents/checklist-agent.md +175 -0
- package/.claude/agents/clarify-analyst.md +50 -0
- package/.claude/agents/code-reviewer.md +71 -0
- package/.claude/agents/codex-analyzer.md +39 -0
- package/.claude/agents/compatibility-checker.md +580 -0
- package/.claude/agents/consistency-checker.md +532 -0
- package/.claude/agents/impact-analyzer.md +441 -0
- package/.claude/agents/planner.md +230 -0
- package/.claude/agents/prd-writer.md +320 -0
- package/.claude/agents/project-guidelines-generator.md +1329 -0
- package/.claude/agents/qa-tester.md +313 -0
- package/.claude/agents/release-manager.md +295 -0
- package/.claude/agents/security-reviewer.md +314 -0
- package/.claude/agents/style-guide-generator.md +458 -0
- package/.claude/agents/tech-architect.md +516 -0
- package/.claude/agents/ui-designer.md +485 -0
- package/.claude/commands/code-review-high.md +58 -0
- package/.claude/commands/core-architecture.md +429 -0
- package/.claude/commands/core-guidelines.md +486 -0
- package/.claude/commands/core-roadmap.md +439 -0
- package/.claude/commands/core-style.md +293 -0
- package/.claude/commands/flow-archive.md +245 -0
- package/.claude/commands/flow-checklist.md +260 -0
- package/.claude/commands/flow-clarify.md +136 -0
- package/.claude/commands/flow-constitution.md +82 -0
- package/.claude/commands/flow-dev.md +134 -0
- package/.claude/commands/flow-epic.md +150 -0
- package/.claude/commands/flow-fix.md +104 -0
- package/.claude/commands/flow-ideate.md +214 -0
- package/.claude/commands/flow-init.md +313 -0
- package/.claude/commands/flow-new.md +394 -0
- package/.claude/commands/flow-prd.md +131 -0
- package/.claude/commands/flow-qa.md +93 -0
- package/.claude/commands/flow-release.md +92 -0
- package/.claude/commands/flow-restart.md +98 -0
- package/.claude/commands/flow-status.md +64 -0
- package/.claude/commands/flow-tech.md +142 -0
- package/.claude/commands/flow-ui.md +189 -0
- package/.claude/commands/flow-update.md +111 -0
- package/.claude/commands/flow-upgrade.md +115 -0
- package/.claude/commands/flow-verify.md +96 -0
- package/.claude/commands/problem-analyzer.md +60 -0
- package/.claude/config/quality-rules.yml +161 -0
- package/.claude/docs/SPEC_KIT_CONSTITUTION_ANALYSIS.md +426 -0
- package/.claude/docs/design/consistency-conflict-detection-algorithms.md +658 -0
- package/.claude/docs/design/intent-driven-input-design.md +380 -0
- package/.claude/docs/design/prd-version-management-design.md +437 -0
- package/.claude/docs/guides/INIT_TROUBLESHOOTING.md +117 -0
- package/.claude/docs/guides/NEW_TROUBLESHOOTING.md +151 -0
- package/.claude/docs/guides/ROADMAP_TROUBLESHOOTING.md +188 -0
- package/.claude/docs/guides/TASK_COMPLETION_MARKING.md +338 -0
- package/.claude/docs/templates/ARCHITECTURE_TEMPLATE.md +633 -0
- package/.claude/docs/templates/BACKLOG_TEMPLATE.md +261 -0
- package/.claude/docs/templates/CHECKLIST_TEMPLATE.md +52 -0
- package/.claude/docs/templates/CLARIFICATION_REPORT_TEMPLATE.md +206 -0
- package/.claude/docs/templates/CODE_REVIEW_TEMPLATE.md +71 -0
- package/.claude/docs/templates/EPIC_TEMPLATE.md +805 -0
- package/.claude/docs/templates/INIT_FLOW_TEMPLATE.md +213 -0
- package/.claude/docs/templates/INTENT_CLARIFICATION_TEMPLATE.md +57 -0
- package/.claude/docs/templates/NEW_ORCHESTRATION_TEMPLATE.md +148 -0
- package/.claude/docs/templates/PRD_TEMPLATE.md +562 -0
- package/.claude/docs/templates/RESEARCH_TEMPLATE.md +276 -0
- package/.claude/docs/templates/REVIEW-HIGH.md +57 -0
- package/.claude/docs/templates/ROADMAP_DIALOGUE_TEMPLATE.md +198 -0
- package/.claude/docs/templates/ROADMAP_TEMPLATE.md +310 -0
- package/.claude/docs/templates/STYLE_TEMPLATE.md +1266 -0
- package/.claude/docs/templates/TASKS_TEMPLATE.md +523 -0
- package/.claude/docs/templates/TECH_DESIGN_TEMPLATE.md +1019 -0
- package/.claude/docs/templates/UI_PROTOTYPE_TEMPLATE.md +1436 -0
- package/.claude/guides/agent-guides/agent-coordination-guide.md +459 -0
- package/.claude/guides/project-guidelines-system.md +463 -0
- package/.claude/guides/technical-guides/datetime-handling-guide.md +563 -0
- package/.claude/guides/technical-guides/git-github-guide.md +642 -0
- package/.claude/guides/technical-guides/test-execution-guide.md +618 -0
- package/.claude/guides/workflow-guides/bug-fix-orchestrator.md +217 -0
- package/.claude/guides/workflow-guides/flow-orchestrator.md +282 -0
- package/.claude/hooks/checklist-gate.js +397 -0
- package/.claude/hooks/error-handling-reminder.sh +12 -0
- package/.claude/hooks/error-handling-reminder.ts +459 -0
- package/.claude/hooks/post-tool-use-tracker.sh +280 -0
- package/.claude/hooks/pre-tool-use-guardrail.sh +36 -0
- package/.claude/hooks/pre-tool-use-guardrail.ts +342 -0
- package/.claude/hooks/skill-activation-prompt.sh +36 -0
- package/.claude/hooks/skill-activation-prompt.ts +214 -0
- package/.claude/hooks/state/skills-used-test-guard.json +3 -0
- package/.claude/rules/devflow-conventions.md +305 -0
- package/.claude/rules/project-constitution.md +748 -0
- package/.claude/schemas/constitution.schema.json +43 -0
- package/.claude/scripts/analyze-upgrade-impact.sh +200 -0
- package/.claude/scripts/archive-requirement.sh +351 -0
- package/.claude/scripts/calculate-checklist-completion.sh +243 -0
- package/.claude/scripts/calculate-quarter.sh +206 -0
- package/.claude/scripts/check-dependencies.sh +409 -0
- package/.claude/scripts/check-prerequisites.sh +232 -0
- package/.claude/scripts/check-task-status.sh +264 -0
- package/.claude/scripts/checklist-errors.sh +131 -0
- package/.claude/scripts/common.sh +570 -0
- package/.claude/scripts/consolidate-research.sh +182 -0
- package/.claude/scripts/create-requirement.sh +426 -0
- package/.claude/scripts/export-contracts.sh +117 -0
- package/.claude/scripts/extract-data-model.sh +78 -0
- package/.claude/scripts/generate-clarification-questions.sh +377 -0
- package/.claude/scripts/generate-clarification-report.sh +463 -0
- package/.claude/scripts/generate-quickstart.sh +146 -0
- package/.claude/scripts/generate-research-tasks.sh +157 -0
- package/.claude/scripts/generate-status-report.sh +523 -0
- package/.claude/scripts/generate-tech-analysis.sh +46 -0
- package/.claude/scripts/locate-requirement-in-roadmap.sh +233 -0
- package/.claude/scripts/manage-constitution.sh +602 -0
- package/.claude/scripts/mark-task-complete.sh +198 -0
- package/.claude/scripts/populate-research-tasks.sh +259 -0
- package/.claude/scripts/recover-workflow.sh +460 -0
- package/.claude/scripts/run-clarify-scan.sh +601 -0
- package/.claude/scripts/run-high-review.sh +62 -0
- package/.claude/scripts/run-problem-analysis.sh +68 -0
- package/.claude/scripts/setup-epic.sh +173 -0
- package/.claude/scripts/sync-roadmap-progress.sh +300 -0
- package/.claude/scripts/sync-task-marks.sh +199 -0
- package/.claude/scripts/test-clarify-scan.sh +515 -0
- package/.claude/scripts/update-agent-context.sh +806 -0
- package/.claude/scripts/validate-constitution.sh +567 -0
- package/.claude/scripts/validate-hooks.sh +487 -0
- package/.claude/scripts/validate-research.sh +332 -0
- package/.claude/scripts/validate-scope-boundary.sh +493 -0
- package/.claude/scripts/verify-setup.sh +37 -0
- package/.claude/settings.json +76 -0
- package/.claude/skills/_reference-implementations/README.md +96 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/SKILL.md +302 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/architecture-overview.md +451 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/async-and-errors.md +307 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/complete-examples.md +638 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/configuration.md +275 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/database-patterns.md +224 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/middleware-guide.md +213 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/routing-and-controllers.md +756 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/sentry-and-monitoring.md +336 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/services-and-repositories.md +789 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/testing-guide.md +235 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/validation-patterns.md +754 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/SKILL.md +399 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/common-patterns.md +331 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/complete-examples.md +872 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/component-patterns.md +502 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/data-fetching.md +767 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/file-organization.md +502 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/loading-and-error-states.md +501 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/performance.md +406 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/routing-guide.md +364 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/styling-guide.md +428 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/typescript-standards.md +418 -0
- package/.claude/skills/cc-devflow-orchestrator/SKILL.md +229 -0
- package/.claude/skills/constitution-guardian/SKILL.md +306 -0
- package/.claude/skills/devflow-constitution-quick-ref/SKILL.md +374 -0
- package/.claude/skills/devflow-file-standards/SKILL.md +353 -0
- package/.claude/skills/devflow-tdd-enforcer/SKILL.md +192 -0
- package/.claude/skills/skill-developer/ADVANCED.md +197 -0
- package/.claude/skills/skill-developer/HOOK_MECHANISMS.md +306 -0
- package/.claude/skills/skill-developer/PATTERNS_LIBRARY.md +152 -0
- package/.claude/skills/skill-developer/SKILL.md +426 -0
- package/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md +315 -0
- package/.claude/skills/skill-developer/TRIGGER_TYPES.md +305 -0
- package/.claude/skills/skill-developer/TROUBLESHOOTING.md +514 -0
- package/.claude/skills/skill-rules.json +213 -0
- package/.claude/tests/README.md +300 -0
- package/.claude/tests/TODO.md +69 -0
- package/.claude/tests/__pycache__/test_analyze_upgrade_impact.cpython-311-pytest-7.2.2.pyc +0 -0
- package/.claude/tests/__pycache__/test_consolidate_research.cpython-311-pytest-7.2.2.pyc +0 -0
- package/.claude/tests/__pycache__/test_export_contracts.cpython-311-pytest-7.2.2.pyc +0 -0
- package/.claude/tests/__pycache__/test_extract_data_model.cpython-311-pytest-7.2.2.pyc +0 -0
- package/.claude/tests/__pycache__/test_generate_quickstart.cpython-311-pytest-7.2.2.pyc +0 -0
- package/.claude/tests/__pycache__/test_generate_research_tasks.cpython-311-pytest-7.2.2.pyc +0 -0
- package/.claude/tests/constitution/run_all_constitution_tests.sh +111 -0
- package/.claude/tests/constitution/test_agent_assignment.sh +207 -0
- package/.claude/tests/constitution/test_article_coverage.sh +201 -0
- package/.claude/tests/constitution/test_template_completeness.sh +150 -0
- package/.claude/tests/constitution/test_version_consistency.sh +120 -0
- package/.claude/tests/fixtures/spec_delta_full.md +16 -0
- package/.claude/tests/fixtures/tasks_progress_sample.md +5 -0
- package/.claude/tests/run-all-tests.sh +229 -0
- package/.claude/tests/scripts/run.sh +30 -0
- package/.claude/tests/scripts/test-framework.sh +128 -0
- package/.claude/tests/scripts/test_check_prerequisites.sh +511 -0
- package/.claude/tests/scripts/test_check_prerequisites.sh.bak +504 -0
- package/.claude/tests/scripts/test_check_prerequisites.sh.bak2 +505 -0
- package/.claude/tests/scripts/test_check_prerequisites.sh.bak3 +506 -0
- package/.claude/tests/scripts/test_check_prerequisites.sh.bak4 +507 -0
- package/.claude/tests/scripts/test_check_prerequisites.sh.bak5 +508 -0
- package/.claude/tests/scripts/test_check_task_status.sh +499 -0
- package/.claude/tests/scripts/test_common.sh +244 -0
- package/.claude/tests/scripts/test_generate_status_report.sh +71 -0
- package/.claude/tests/scripts/test_mark_task_complete.sh +441 -0
- package/.claude/tests/scripts/test_mark_task_complete.sh.backup +410 -0
- package/.claude/tests/scripts/test_recover_workflow.sh +304 -0
- package/.claude/tests/scripts/test_setup_epic.sh +437 -0
- package/.claude/tests/scripts/test_sync_task_marks.sh +196 -0
- package/.claude/tests/scripts/test_validate_constitution.sh +74 -0
- package/.claude/tests/scripts/test_validate_research.sh +462 -0
- package/.claude/tests/slugify.bats +82 -0
- package/.claude/tests/test-framework.sh +732 -0
- package/.claude/tests/test_analyze_upgrade_impact.py +34 -0
- package/.claude/tests/test_consolidate_research.py +48 -0
- package/.claude/tests/test_export_contracts.py +43 -0
- package/.claude/tests/test_extract_data_model.py +33 -0
- package/.claude/tests/test_generate_quickstart.py +50 -0
- package/.claude/tests/test_generate_research_tasks.py +52 -0
- package/.claude/tsc-cache/6e64f818-6398-49ca-8623-581a9af85c44/edited-files.log +1 -0
- package/.claude/tsc-cache/795ba6e3-b98a-423b-bab2-51aa62812569/affected-repos.txt +1 -0
- package/.claude/tsc-cache/795ba6e3-b98a-423b-bab2-51aa62812569/edited-files.log +1 -0
- package/.claude/tsc-cache/ae335694-be5a-4ba4-a1a0-b676c09a7906/affected-repos.txt +1 -0
- package/.claude/tsc-cache/ae335694-be5a-4ba4-a1a0-b676c09a7906/edited-files.log +1 -0
- package/CHANGELOG.md +507 -0
- package/LICENSE +21 -0
- package/README.md +534 -0
- package/README.zh-CN.md +530 -0
- package/bin/adapt.js +240 -0
- package/bin/cc-devflow-cli.js +185 -0
- package/bin/cc-devflow.js +78 -0
- package/config/adapters.yml +5 -0
- package/config/schema/adapters.schema.json +44 -0
- package/docs/CLAUDE.md +26 -0
- package/docs/commands/README.md +61 -0
- package/docs/commands/README.zh-CN.md +55 -0
- package/docs/commands/core-roadmap.md +106 -0
- package/docs/commands/core-roadmap.zh-CN.md +102 -0
- package/docs/commands/core-style.md +405 -0
- package/docs/commands/core-style.zh-CN.md +405 -0
- package/docs/commands/flow-init.md +134 -0
- package/docs/commands/flow-init.zh-CN.md +163 -0
- package/docs/commands/flow-new.md +274 -0
- package/docs/commands/flow-new.zh-CN.md +270 -0
- package/docs/guides/getting-started.md +204 -0
- package/docs/guides/getting-started.zh-CN.md +152 -0
- package/lib/adapters/adapter-interface.js +57 -0
- package/lib/adapters/claude-adapter.js +74 -0
- package/lib/adapters/codex-adapter.js +40 -0
- package/lib/adapters/config-validator.js +68 -0
- package/lib/adapters/logger.js +42 -0
- package/lib/adapters/registry.js +153 -0
- package/lib/compiler/CLAUDE.md +92 -0
- package/lib/compiler/__tests__/drift.test.js +215 -0
- package/lib/compiler/__tests__/errors.test.js +184 -0
- package/lib/compiler/__tests__/incremental.test.js +174 -0
- package/lib/compiler/__tests__/integration.test.js +174 -0
- package/lib/compiler/__tests__/manifest.test.js +233 -0
- package/lib/compiler/__tests__/parser.test.js +456 -0
- package/lib/compiler/__tests__/schemas.test.js +301 -0
- package/lib/compiler/__tests__/skills-registry.test.js +125 -0
- package/lib/compiler/__tests__/transformer.test.js +286 -0
- package/lib/compiler/emitters/antigravity-emitter.js +171 -0
- package/lib/compiler/emitters/base-emitter.js +73 -0
- package/lib/compiler/emitters/codex-emitter.js +52 -0
- package/lib/compiler/emitters/cursor-emitter.js +31 -0
- package/lib/compiler/emitters/index.js +50 -0
- package/lib/compiler/emitters/qwen-emitter.js +39 -0
- package/lib/compiler/errors.js +119 -0
- package/lib/compiler/index.js +256 -0
- package/lib/compiler/manifest.js +242 -0
- package/lib/compiler/parser.js +258 -0
- package/lib/compiler/platforms.js +113 -0
- package/lib/compiler/resource-copier.js +320 -0
- package/lib/compiler/rules-emitters/__tests__/antigravity-rules-emitter.test.js +191 -0
- package/lib/compiler/rules-emitters/__tests__/codex-rules-emitter.test.js +109 -0
- package/lib/compiler/rules-emitters/__tests__/cursor-rules-emitter.test.js +123 -0
- package/lib/compiler/rules-emitters/__tests__/qwen-rules-emitter.test.js +123 -0
- package/lib/compiler/rules-emitters/antigravity-rules-emitter.js +253 -0
- package/lib/compiler/rules-emitters/base-rules-emitter.js +83 -0
- package/lib/compiler/rules-emitters/codex-rules-emitter.js +116 -0
- package/lib/compiler/rules-emitters/cursor-rules-emitter.js +98 -0
- package/lib/compiler/rules-emitters/index.js +71 -0
- package/lib/compiler/rules-emitters/qwen-rules-emitter.js +70 -0
- package/lib/compiler/schemas.js +144 -0
- package/lib/compiler/skills-registry.js +225 -0
- package/lib/compiler/transformer.js +236 -0
- package/package.json +50 -0
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# test_mark_task_complete.sh - 测试 mark-task-complete.sh
|
|
3
|
+
|
|
4
|
+
# 加载测试框架
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
source "$SCRIPT_DIR/../test-framework.sh"
|
|
7
|
+
|
|
8
|
+
# 脚本路径
|
|
9
|
+
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
10
|
+
MARK_TASK_SCRIPT="$REPO_ROOT/scripts/mark-task-complete.sh"
|
|
11
|
+
|
|
12
|
+
# ============================================================================
|
|
13
|
+
# 辅助函数
|
|
14
|
+
# ============================================================================
|
|
15
|
+
|
|
16
|
+
# 创建测试专用的 common.sh
|
|
17
|
+
create_test_common() {
|
|
18
|
+
local test_common="$TEST_TMP_DIR/scripts/common.sh"
|
|
19
|
+
mkdir -p "$(dirname "$test_common")"
|
|
20
|
+
|
|
21
|
+
# Use awk instead of sed for proper variable substitution
|
|
22
|
+
awk -v tmpdir="$TEST_TMP_DIR" '
|
|
23
|
+
/^get_repo_root\(\)/ {
|
|
24
|
+
print "get_repo_root() {"
|
|
25
|
+
print " echo \"" tmpdir "\""
|
|
26
|
+
print "}"
|
|
27
|
+
in_function = 1
|
|
28
|
+
next
|
|
29
|
+
}
|
|
30
|
+
in_function && /^}/ {
|
|
31
|
+
in_function = 0
|
|
32
|
+
next
|
|
33
|
+
}
|
|
34
|
+
!in_function {
|
|
35
|
+
print
|
|
36
|
+
}
|
|
37
|
+
' "$REPO_ROOT/scripts/common.sh" > "$test_common.tmp"
|
|
38
|
+
|
|
39
|
+
mv "$test_common.tmp" "$test_common"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# 创建带有任务的需求环境
|
|
43
|
+
setup_requirement_with_tasks() {
|
|
44
|
+
local req_id="$1"
|
|
45
|
+
local req_dir="$TEST_TMP_DIR/.claude/docs/requirements/$req_id"
|
|
46
|
+
|
|
47
|
+
mkdir -p "$req_dir"
|
|
48
|
+
|
|
49
|
+
# 创建 TASKS.md
|
|
50
|
+
cat > "$req_dir/TASKS.md" << 'EOF'
|
|
51
|
+
# Tasks for REQ-001
|
|
52
|
+
|
|
53
|
+
## Task List
|
|
54
|
+
|
|
55
|
+
- [ ] **T001**: Implement user authentication
|
|
56
|
+
- [ ] **T002**: Add password validation
|
|
57
|
+
- [x] **T003**: Setup database schema
|
|
58
|
+
- [ ] **T004**: Create API endpoints
|
|
59
|
+
EOF
|
|
60
|
+
|
|
61
|
+
# 创建 EXECUTION_LOG.md
|
|
62
|
+
echo "# Execution Log" > "$req_dir/EXECUTION_LOG.md"
|
|
63
|
+
|
|
64
|
+
echo "$req_dir"
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
# 运行 mark-task-complete.sh
|
|
68
|
+
run_mark_task() {
|
|
69
|
+
local task_id="$1"
|
|
70
|
+
shift
|
|
71
|
+
local args=("$@")
|
|
72
|
+
|
|
73
|
+
# 设置环境
|
|
74
|
+
export DEVFLOW_REQ_ID="REQ-001"
|
|
75
|
+
|
|
76
|
+
# 创建测试专用的脚本副本
|
|
77
|
+
local test_scripts_dir="$TEST_TMP_DIR/scripts"
|
|
78
|
+
mkdir -p "$test_scripts_dir"
|
|
79
|
+
|
|
80
|
+
# 创建测试专用的 common.sh
|
|
81
|
+
create_test_common
|
|
82
|
+
|
|
83
|
+
# 复制 mark-task-complete.sh 到测试目录
|
|
84
|
+
cp "$MARK_TASK_SCRIPT" "$test_scripts_dir/"
|
|
85
|
+
|
|
86
|
+
# 在测试目录中运行脚本
|
|
87
|
+
(
|
|
88
|
+
cd "$TEST_TMP_DIR"
|
|
89
|
+
bash "$test_scripts_dir/mark-task-complete.sh" "$task_id" "${args[@]}" 2>&1
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# ============================================================================
|
|
94
|
+
# 测试帮助信息
|
|
95
|
+
# ============================================================================
|
|
96
|
+
|
|
97
|
+
test_help_flag() {
|
|
98
|
+
describe "Should show help with --help"
|
|
99
|
+
|
|
100
|
+
# Arrange
|
|
101
|
+
local test_scripts_dir="$TEST_TMP_DIR/scripts"
|
|
102
|
+
mkdir -p "$test_scripts_dir"
|
|
103
|
+
create_test_common
|
|
104
|
+
cp "$MARK_TASK_SCRIPT" "$test_scripts_dir/"
|
|
105
|
+
|
|
106
|
+
# Act
|
|
107
|
+
local output=$(
|
|
108
|
+
cd "$TEST_TMP_DIR"
|
|
109
|
+
bash "$test_scripts_dir/mark-task-complete.sh" --help 2>&1
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
# Assert
|
|
113
|
+
assert_contains "$output" "Usage:" "Should show usage"
|
|
114
|
+
assert_contains "$output" "mark-task-complete.sh" "Should mention script name"
|
|
115
|
+
assert_contains "$output" "TASK_ID" "Should document TASK_ID argument"
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
# ============================================================================
|
|
119
|
+
# 测试参数验证
|
|
120
|
+
# ============================================================================
|
|
121
|
+
|
|
122
|
+
test_no_task_id() {
|
|
123
|
+
describe "Should fail when TASK_ID not provided"
|
|
124
|
+
|
|
125
|
+
# Arrange
|
|
126
|
+
local test_scripts_dir="$TEST_TMP_DIR/scripts"
|
|
127
|
+
mkdir -p "$test_scripts_dir"
|
|
128
|
+
create_test_common
|
|
129
|
+
cp "$MARK_TASK_SCRIPT" "$test_scripts_dir/"
|
|
130
|
+
|
|
131
|
+
# Act - Use temp file pattern to capture exit code
|
|
132
|
+
local output_file="$TEST_TMP_DIR/output.txt"
|
|
133
|
+
local exit_code_file="$TEST_TMP_DIR/exitcode.txt"
|
|
134
|
+
|
|
135
|
+
(
|
|
136
|
+
cd "$TEST_TMP_DIR"
|
|
137
|
+
export DEVFLOW_REQ_ID="REQ-001"
|
|
138
|
+
bash "$test_scripts_dir/mark-task-complete.sh" > "$output_file" 2>&1
|
|
139
|
+
echo $? > "$exit_code_file"
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
local output=$(cat "$output_file")
|
|
143
|
+
local exit_code=$(cat "$exit_code_file")
|
|
144
|
+
|
|
145
|
+
# Assert
|
|
146
|
+
assert_not_equals "$exit_code" "0" "Should fail without TASK_ID"
|
|
147
|
+
assert_contains "$output" "Task ID is required" "Should mention missing TASK_ID"
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
test_invalid_task_id_format() {
|
|
151
|
+
describe "Should fail on invalid TASK_ID format"
|
|
152
|
+
|
|
153
|
+
# Arrange
|
|
154
|
+
setup_requirement_with_tasks "REQ-001"
|
|
155
|
+
|
|
156
|
+
# Act
|
|
157
|
+
local exit_code=0
|
|
158
|
+
local output=$(run_mark_task "INVALID" 2>&1) || exit_code=$?
|
|
159
|
+
|
|
160
|
+
# Assert
|
|
161
|
+
assert_not_equals "$exit_code" "0" "Should fail on invalid format"
|
|
162
|
+
if [[ $exit_code -ne 0 ]]; then
|
|
163
|
+
assert_contains "$output" "Invalid task ID format" "Should mention format error"
|
|
164
|
+
fi
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
test_normalize_task_id_case() {
|
|
168
|
+
describe "Should normalize task ID to uppercase"
|
|
169
|
+
|
|
170
|
+
# Arrange
|
|
171
|
+
local req_dir=$(setup_requirement_with_tasks "REQ-001")
|
|
172
|
+
|
|
173
|
+
# Act - use lowercase task id
|
|
174
|
+
local output=$(run_mark_task "t001" --json 2>&1)
|
|
175
|
+
local exit_code=$?
|
|
176
|
+
|
|
177
|
+
# Assert
|
|
178
|
+
assert_equals "$exit_code" "0" "Should succeed with lowercase"
|
|
179
|
+
assert_contains "$output" "T001" "Should normalize to T001"
|
|
180
|
+
|
|
181
|
+
# Verify checkbox was marked
|
|
182
|
+
local tasks_content=$(cat "$req_dir/TASKS.md")
|
|
183
|
+
assert_contains "$tasks_content" "[x] **T001**" "Should mark T001 as complete"
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
# ============================================================================
|
|
187
|
+
# 测试任务标记
|
|
188
|
+
# ============================================================================
|
|
189
|
+
|
|
190
|
+
test_mark_task_complete() {
|
|
191
|
+
describe "Should mark task as complete"
|
|
192
|
+
|
|
193
|
+
# Arrange
|
|
194
|
+
local req_dir=$(setup_requirement_with_tasks "REQ-001")
|
|
195
|
+
|
|
196
|
+
# Act
|
|
197
|
+
local output=$(run_mark_task "T001" 2>&1)
|
|
198
|
+
local exit_code=$?
|
|
199
|
+
|
|
200
|
+
# Assert
|
|
201
|
+
assert_equals "$exit_code" "0" "Should succeed"
|
|
202
|
+
assert_contains "$output" "✅" "Should show success message"
|
|
203
|
+
|
|
204
|
+
# Verify TASKS.md was updated
|
|
205
|
+
local tasks_content=$(cat "$req_dir/TASKS.md")
|
|
206
|
+
assert_contains "$tasks_content" "[x] **T001**" "Task should be marked complete"
|
|
207
|
+
assert_not_contains "$tasks_content" "[ ] **T001**" "Incomplete checkbox should be removed"
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
test_already_complete_task() {
|
|
211
|
+
describe "Should handle already complete task gracefully"
|
|
212
|
+
|
|
213
|
+
# Arrange
|
|
214
|
+
setup_requirement_with_tasks "REQ-001"
|
|
215
|
+
|
|
216
|
+
# Act - T003 is already marked as complete
|
|
217
|
+
local output=$(run_mark_task "T003" 2>&1)
|
|
218
|
+
local exit_code=$?
|
|
219
|
+
|
|
220
|
+
# Assert
|
|
221
|
+
assert_equals "$exit_code" "0" "Should succeed"
|
|
222
|
+
assert_contains "$output" "already" "Should mention already complete"
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
test_task_not_found() {
|
|
226
|
+
describe "Should fail when task doesn't exist"
|
|
227
|
+
|
|
228
|
+
# Arrange
|
|
229
|
+
setup_requirement_with_tasks "REQ-001"
|
|
230
|
+
|
|
231
|
+
# Act
|
|
232
|
+
local exit_code=0
|
|
233
|
+
local output=$(run_mark_task "T999" 2>&1) || exit_code=$?
|
|
234
|
+
|
|
235
|
+
# Assert
|
|
236
|
+
assert_not_equals "$exit_code" "0" "Should fail"
|
|
237
|
+
if [[ $exit_code -ne 0 ]]; then
|
|
238
|
+
assert_contains "$output" "not found" "Should mention task not found"
|
|
239
|
+
fi
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
# ============================================================================
|
|
243
|
+
# 测试日志功能
|
|
244
|
+
# ============================================================================
|
|
245
|
+
|
|
246
|
+
test_log_to_execution_log() {
|
|
247
|
+
describe "Should log to EXECUTION_LOG.md by default"
|
|
248
|
+
|
|
249
|
+
# Arrange
|
|
250
|
+
local req_dir=$(setup_requirement_with_tasks "REQ-001")
|
|
251
|
+
|
|
252
|
+
# Act
|
|
253
|
+
run_mark_task "T002" 2>&1
|
|
254
|
+
|
|
255
|
+
# Assert
|
|
256
|
+
local log_content=$(cat "$req_dir/EXECUTION_LOG.md")
|
|
257
|
+
assert_contains "$log_content" "T002" "Should log task ID"
|
|
258
|
+
assert_contains "$log_content" "complete" "Should log completion"
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
test_no_log_option() {
|
|
262
|
+
describe "Should skip logging with --no-log"
|
|
263
|
+
|
|
264
|
+
# Arrange
|
|
265
|
+
local req_dir=$(setup_requirement_with_tasks "REQ-001")
|
|
266
|
+
local initial_log=$(cat "$req_dir/EXECUTION_LOG.md")
|
|
267
|
+
|
|
268
|
+
# Act
|
|
269
|
+
run_mark_task "T004" --no-log 2>&1
|
|
270
|
+
|
|
271
|
+
# Assert
|
|
272
|
+
local final_log=$(cat "$req_dir/EXECUTION_LOG.md")
|
|
273
|
+
assert_equals "$initial_log" "$final_log" "Log should not change"
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
# ============================================================================
|
|
277
|
+
# 测试 JSON 输出
|
|
278
|
+
# ============================================================================
|
|
279
|
+
|
|
280
|
+
test_json_output() {
|
|
281
|
+
describe "Should output valid JSON with --json"
|
|
282
|
+
|
|
283
|
+
# Arrange
|
|
284
|
+
setup_requirement_with_tasks "REQ-001"
|
|
285
|
+
|
|
286
|
+
# Act
|
|
287
|
+
local output=$(run_mark_task "T001" --json 2>&1)
|
|
288
|
+
|
|
289
|
+
# Assert
|
|
290
|
+
assert_json_valid "$output" "Should be valid JSON"
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
test_json_output_fields() {
|
|
294
|
+
describe "JSON should include required fields"
|
|
295
|
+
|
|
296
|
+
# Arrange
|
|
297
|
+
setup_requirement_with_tasks "REQ-001"
|
|
298
|
+
|
|
299
|
+
# Act
|
|
300
|
+
local output=$(run_mark_task "T002" --json 2>&1)
|
|
301
|
+
|
|
302
|
+
# Assert
|
|
303
|
+
assert_contains "$output" "\"status\"" "Should have status field"
|
|
304
|
+
assert_contains "$output" "\"task_id\"" "Should have task_id field"
|
|
305
|
+
assert_contains "$output" "\"T002\"" "Should have correct task ID"
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
test_json_already_complete() {
|
|
309
|
+
describe "JSON should indicate already complete status"
|
|
310
|
+
|
|
311
|
+
# Arrange
|
|
312
|
+
setup_requirement_with_tasks "REQ-001"
|
|
313
|
+
|
|
314
|
+
# Act
|
|
315
|
+
local output=$(run_mark_task "T003" --json 2>&1)
|
|
316
|
+
|
|
317
|
+
# Assert
|
|
318
|
+
assert_json_valid "$output" "Should be valid JSON"
|
|
319
|
+
assert_contains "$output" "already_complete" "Should have already_complete status"
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
# ============================================================================
|
|
323
|
+
# 测试进度统计
|
|
324
|
+
# ============================================================================
|
|
325
|
+
|
|
326
|
+
test_show_progress() {
|
|
327
|
+
describe "Should show task progress in text mode"
|
|
328
|
+
|
|
329
|
+
# Arrange
|
|
330
|
+
setup_requirement_with_tasks "REQ-001"
|
|
331
|
+
|
|
332
|
+
# Act
|
|
333
|
+
local output=$(run_mark_task "T001" 2>&1)
|
|
334
|
+
|
|
335
|
+
# Assert
|
|
336
|
+
assert_contains "$output" "Progress:" "Should show progress"
|
|
337
|
+
assert_contains "$output" "completed" "Should show completed count"
|
|
338
|
+
assert_contains "$output" "remaining" "Should show remaining count"
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
# ============================================================================
|
|
342
|
+
# 测试缺失文件错误
|
|
343
|
+
# ============================================================================
|
|
344
|
+
|
|
345
|
+
test_missing_tasks_file() {
|
|
346
|
+
describe "Should fail when TASKS.md doesn't exist"
|
|
347
|
+
|
|
348
|
+
# Arrange - 创建需求目录但不创建 TASKS.md
|
|
349
|
+
local req_id="REQ-001"
|
|
350
|
+
local req_dir="$TEST_TMP_DIR/.claude/docs/requirements/$req_id"
|
|
351
|
+
mkdir -p "$req_dir"
|
|
352
|
+
|
|
353
|
+
# Act
|
|
354
|
+
local exit_code=0
|
|
355
|
+
local output=$(run_mark_task "T001" 2>&1) || exit_code=$?
|
|
356
|
+
|
|
357
|
+
# Assert
|
|
358
|
+
assert_not_equals "$exit_code" "0" "Should fail when TASKS.md missing"
|
|
359
|
+
if [[ $exit_code -ne 0 ]]; then
|
|
360
|
+
assert_contains "$output" "TASKS.md not found" "Should mention missing TASKS.md"
|
|
361
|
+
fi
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
# ============================================================================
|
|
365
|
+
# 测试错误处理
|
|
366
|
+
# ============================================================================
|
|
367
|
+
|
|
368
|
+
test_invalid_option() {
|
|
369
|
+
describe "Should reject invalid options"
|
|
370
|
+
|
|
371
|
+
# Arrange
|
|
372
|
+
local test_scripts_dir="$TEST_TMP_DIR/scripts"
|
|
373
|
+
mkdir -p "$test_scripts_dir"
|
|
374
|
+
create_test_common
|
|
375
|
+
cp "$MARK_TASK_SCRIPT" "$test_scripts_dir/"
|
|
376
|
+
|
|
377
|
+
# Act
|
|
378
|
+
local exit_code=0
|
|
379
|
+
local output=$(
|
|
380
|
+
cd "$TEST_TMP_DIR"
|
|
381
|
+
bash "$test_scripts_dir/mark-task-complete.sh" T001 --invalid-option 2>&1
|
|
382
|
+
) || exit_code=$?
|
|
383
|
+
|
|
384
|
+
# Assert
|
|
385
|
+
assert_not_equals "$exit_code" "0" "Should fail on invalid option"
|
|
386
|
+
if [[ $exit_code -ne 0 ]]; then
|
|
387
|
+
assert_contains "$output" "Unknown option" "Should mention unknown option"
|
|
388
|
+
fi
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
# ============================================================================
|
|
392
|
+
# 运行所有测试
|
|
393
|
+
# ============================================================================
|
|
394
|
+
|
|
395
|
+
run_tests \
|
|
396
|
+
test_help_flag \
|
|
397
|
+
test_no_task_id \
|
|
398
|
+
test_invalid_task_id_format \
|
|
399
|
+
test_normalize_task_id_case \
|
|
400
|
+
test_mark_task_complete \
|
|
401
|
+
test_already_complete_task \
|
|
402
|
+
test_task_not_found \
|
|
403
|
+
test_log_to_execution_log \
|
|
404
|
+
test_no_log_option \
|
|
405
|
+
test_json_output \
|
|
406
|
+
test_json_output_fields \
|
|
407
|
+
test_json_already_complete \
|
|
408
|
+
test_show_progress \
|
|
409
|
+
test_missing_tasks_file \
|
|
410
|
+
test_invalid_option
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# test_recover_workflow.sh - 测试 recover-workflow.sh (基础测试)
|
|
3
|
+
|
|
4
|
+
# 加载测试框架
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
source "$SCRIPT_DIR/../test-framework.sh"
|
|
7
|
+
|
|
8
|
+
# 脚本路径
|
|
9
|
+
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
10
|
+
RECOVER_SCRIPT="$REPO_ROOT/scripts/recover-workflow.sh"
|
|
11
|
+
|
|
12
|
+
# 注意: recover-workflow.sh 依赖真实的仓库环境
|
|
13
|
+
# 这里只测试基本功能和帮助信息
|
|
14
|
+
|
|
15
|
+
# ============================================================================
|
|
16
|
+
# 辅助函数
|
|
17
|
+
# ============================================================================
|
|
18
|
+
|
|
19
|
+
# 创建测试专用的 common.sh
|
|
20
|
+
create_test_common() {
|
|
21
|
+
local test_common="$TEST_TMP_DIR/scripts/common.sh"
|
|
22
|
+
mkdir -p "$(dirname "$test_common")"
|
|
23
|
+
|
|
24
|
+
sed '/^get_repo_root()/,/^}/c\
|
|
25
|
+
get_repo_root() {\
|
|
26
|
+
echo "'"$TEST_TMP_DIR"'"\
|
|
27
|
+
}' "$REPO_ROOT/scripts/common.sh" > "$test_common"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
# 创建需求环境(带状态)
|
|
31
|
+
setup_requirement_with_status() {
|
|
32
|
+
local req_id="$1"
|
|
33
|
+
local status="$2"
|
|
34
|
+
local phase="$3"
|
|
35
|
+
|
|
36
|
+
local req_dir="$TEST_TMP_DIR/devflow/requirements/$req_id"
|
|
37
|
+
mkdir -p "$req_dir"/{research,tasks}
|
|
38
|
+
|
|
39
|
+
# 创建状态文件
|
|
40
|
+
cat > "$req_dir/orchestration_status.json" << EOF
|
|
41
|
+
{
|
|
42
|
+
"reqId": "$req_id",
|
|
43
|
+
"title": "Test Requirement",
|
|
44
|
+
"status": "$status",
|
|
45
|
+
"phase": "$phase",
|
|
46
|
+
"createdAt": "2025-10-01T00:00:00Z",
|
|
47
|
+
"updatedAt": "2025-10-01T00:00:00Z"
|
|
48
|
+
}
|
|
49
|
+
EOF
|
|
50
|
+
|
|
51
|
+
# 创建基础文档
|
|
52
|
+
echo "# PRD" > "$req_dir/PRD.md"
|
|
53
|
+
echo "# Execution Log" > "$req_dir/EXECUTION_LOG.md"
|
|
54
|
+
|
|
55
|
+
echo "$req_dir"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
# 运行 recover-workflow.sh
|
|
59
|
+
run_recover() {
|
|
60
|
+
local req_id="$1"
|
|
61
|
+
shift
|
|
62
|
+
local args=("$@")
|
|
63
|
+
|
|
64
|
+
export DEVFLOW_REQ_ID="$req_id"
|
|
65
|
+
|
|
66
|
+
local test_scripts_dir="$TEST_TMP_DIR/scripts"
|
|
67
|
+
mkdir -p "$test_scripts_dir"
|
|
68
|
+
|
|
69
|
+
create_test_common
|
|
70
|
+
cp "$RECOVER_SCRIPT" "$test_scripts_dir/"
|
|
71
|
+
|
|
72
|
+
(
|
|
73
|
+
cd "$TEST_TMP_DIR"
|
|
74
|
+
bash "$test_scripts_dir/recover-workflow.sh" "${args[@]}" 2>&1
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
# ============================================================================
|
|
79
|
+
# 测试帮助信息
|
|
80
|
+
# ============================================================================
|
|
81
|
+
|
|
82
|
+
test_help_flag() {
|
|
83
|
+
describe "Should show help with --help"
|
|
84
|
+
|
|
85
|
+
# Act - 直接运行脚本
|
|
86
|
+
local output=$(bash "$RECOVER_SCRIPT" --help 2>&1)
|
|
87
|
+
|
|
88
|
+
# Assert
|
|
89
|
+
assert_contains "$output" "用法:" "Should show usage"
|
|
90
|
+
assert_contains "$output" "恢复" "Should mention recovery"
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
test_script_executes() {
|
|
94
|
+
describe "Should execute without critical errors"
|
|
95
|
+
|
|
96
|
+
# Act
|
|
97
|
+
local exit_code=0
|
|
98
|
+
bash "$RECOVER_SCRIPT" --help >/dev/null 2>&1 || exit_code=$?
|
|
99
|
+
|
|
100
|
+
# Assert
|
|
101
|
+
assert_equals "$exit_code" "0" "Script should be executable"
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
test_has_required_options() {
|
|
105
|
+
describe "Help should document required options"
|
|
106
|
+
|
|
107
|
+
# Act
|
|
108
|
+
local output=$(bash "$RECOVER_SCRIPT" --help 2>&1)
|
|
109
|
+
|
|
110
|
+
# Assert
|
|
111
|
+
assert_contains "$output" "--from" "Should have --from option"
|
|
112
|
+
assert_contains "$output" "--dry-run" "Should have --dry-run option"
|
|
113
|
+
assert_contains "$output" "--force" "Should have --force option"
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
# ============================================================================
|
|
117
|
+
# 测试状态检测
|
|
118
|
+
# ============================================================================
|
|
119
|
+
|
|
120
|
+
test_detect_workflow_status() {
|
|
121
|
+
describe "Should detect workflow status correctly"
|
|
122
|
+
|
|
123
|
+
# Arrange
|
|
124
|
+
setup_requirement_with_status "REQ-001" "prd_complete" "epic_planning"
|
|
125
|
+
|
|
126
|
+
# Act
|
|
127
|
+
local output=$(run_recover "REQ-001" --dry-run 2>&1)
|
|
128
|
+
|
|
129
|
+
# Assert
|
|
130
|
+
assert_contains "$output" "REQ-001" "Should show requirement ID"
|
|
131
|
+
assert_contains "$output" "prd_complete\|epic" "Should show status or phase"
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
# ============================================================================
|
|
135
|
+
# 测试恢复策略
|
|
136
|
+
# ============================================================================
|
|
137
|
+
|
|
138
|
+
test_recovery_from_prd_complete() {
|
|
139
|
+
describe "Should suggest Epic stage from prd_complete"
|
|
140
|
+
|
|
141
|
+
# Arrange
|
|
142
|
+
setup_requirement_with_status "REQ-002" "prd_complete" "epic_planning"
|
|
143
|
+
|
|
144
|
+
# Act
|
|
145
|
+
local output=$(run_recover "REQ-002" --dry-run 2>&1)
|
|
146
|
+
|
|
147
|
+
# Assert
|
|
148
|
+
assert_contains "$output" "epic\|Epic\|EPIC" "Should mention Epic stage"
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
test_recovery_from_initialized() {
|
|
152
|
+
describe "Should suggest PRD stage from initialized"
|
|
153
|
+
|
|
154
|
+
# Arrange
|
|
155
|
+
setup_requirement_with_status "REQ-003" "initialized" "planning"
|
|
156
|
+
|
|
157
|
+
# Act
|
|
158
|
+
local output=$(run_recover "REQ-003" --dry-run 2>&1)
|
|
159
|
+
|
|
160
|
+
# Assert
|
|
161
|
+
assert_contains "$output" "prd\|PRD" "Should mention PRD stage"
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
test_recovery_from_epic_complete() {
|
|
165
|
+
describe "Should suggest dev stage from epic_complete"
|
|
166
|
+
|
|
167
|
+
# Arrange
|
|
168
|
+
setup_requirement_with_status "REQ-004" "epic_complete" "epic_complete"
|
|
169
|
+
|
|
170
|
+
# Act
|
|
171
|
+
local output=$(run_recover "REQ-004" --dry-run 2>&1)
|
|
172
|
+
|
|
173
|
+
# Assert
|
|
174
|
+
assert_contains "$output" "dev\|开发" "Should mention dev stage"
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
# ============================================================================
|
|
178
|
+
# 测试 --from 选项
|
|
179
|
+
# ============================================================================
|
|
180
|
+
|
|
181
|
+
test_from_option_override() {
|
|
182
|
+
describe "Should respect --from option to override detection"
|
|
183
|
+
|
|
184
|
+
# Arrange
|
|
185
|
+
setup_requirement_with_status "REQ-005" "prd_complete" "epic_planning"
|
|
186
|
+
|
|
187
|
+
# Act
|
|
188
|
+
local output=$(run_recover "REQ-005" --from dev --dry-run 2>&1)
|
|
189
|
+
|
|
190
|
+
# Assert
|
|
191
|
+
assert_contains "$output" "dev\|开发" "Should start from dev as specified"
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
# ============================================================================
|
|
195
|
+
# 测试 dry-run 模式
|
|
196
|
+
# ============================================================================
|
|
197
|
+
|
|
198
|
+
test_dry_run_mode() {
|
|
199
|
+
describe "Should show recovery plan in dry-run mode"
|
|
200
|
+
|
|
201
|
+
# Arrange
|
|
202
|
+
setup_requirement_with_status "REQ-006" "prd_complete" "epic_planning"
|
|
203
|
+
|
|
204
|
+
# Act
|
|
205
|
+
local output=$(run_recover "REQ-006" --dry-run 2>&1)
|
|
206
|
+
|
|
207
|
+
# Assert
|
|
208
|
+
assert_contains "$output" "恢复计划\|Recovery Plan\|执行步骤" "Should show recovery plan"
|
|
209
|
+
assert_contains "$output" "flow-\|/flow" "Should show flow commands"
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
# ============================================================================
|
|
213
|
+
# 测试文档完整性检查
|
|
214
|
+
# ============================================================================
|
|
215
|
+
|
|
216
|
+
test_check_prd_exists() {
|
|
217
|
+
describe "Should check for PRD.md existence"
|
|
218
|
+
|
|
219
|
+
# Arrange
|
|
220
|
+
local req_dir=$(setup_requirement_with_status "REQ-007" "prd_complete" "epic_planning")
|
|
221
|
+
|
|
222
|
+
# Act
|
|
223
|
+
local output=$(run_recover "REQ-007" --dry-run 2>&1)
|
|
224
|
+
|
|
225
|
+
# Assert
|
|
226
|
+
assert_contains "$output" "PRD\|文档" "Should mention PRD or documents"
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
test_check_epic_if_exists() {
|
|
230
|
+
describe "Should check for EPIC.md if it exists"
|
|
231
|
+
|
|
232
|
+
# Arrange
|
|
233
|
+
local req_dir=$(setup_requirement_with_status "REQ-008" "epic_complete" "epic_complete")
|
|
234
|
+
echo "# EPIC" > "$req_dir/EPIC.md"
|
|
235
|
+
|
|
236
|
+
# Act
|
|
237
|
+
local output=$(run_recover "REQ-008" --dry-run 2>&1)
|
|
238
|
+
|
|
239
|
+
# Assert
|
|
240
|
+
assert_contains "$output" "EPIC\|Epic\|文档" "Should detect EPIC presence"
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
# ============================================================================
|
|
244
|
+
# 测试错误处理
|
|
245
|
+
# ============================================================================
|
|
246
|
+
|
|
247
|
+
test_missing_requirement_dir() {
|
|
248
|
+
describe "Should fail when requirement directory doesn't exist"
|
|
249
|
+
|
|
250
|
+
# Arrange - 不创建需求目录
|
|
251
|
+
|
|
252
|
+
# Act
|
|
253
|
+
local exit_code=0
|
|
254
|
+
local output=$(run_recover "REQ-NOTEXIST" --dry-run 2>&1) || exit_code=$?
|
|
255
|
+
|
|
256
|
+
# Assert
|
|
257
|
+
assert_not_equals "$exit_code" "0" "Should fail when dir missing"
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
test_missing_status_file() {
|
|
261
|
+
describe "Should handle missing status file gracefully"
|
|
262
|
+
|
|
263
|
+
# Arrange - 创建目录但不创建状态文件
|
|
264
|
+
local req_id="REQ-009"
|
|
265
|
+
local req_dir="$TEST_TMP_DIR/devflow/requirements/$req_id"
|
|
266
|
+
mkdir -p "$req_dir"
|
|
267
|
+
echo "# PRD" > "$req_dir/PRD.md"
|
|
268
|
+
|
|
269
|
+
# Act
|
|
270
|
+
local exit_code=0
|
|
271
|
+
local output=$(run_recover "REQ-009" --dry-run 2>&1) || exit_code=$?
|
|
272
|
+
|
|
273
|
+
# Assert
|
|
274
|
+
assert_not_equals "$exit_code" "0" "Should fail without status file"
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
# ============================================================================
|
|
278
|
+
# 测试已完成需求
|
|
279
|
+
# ============================================================================
|
|
280
|
+
|
|
281
|
+
test_completed_requirement() {
|
|
282
|
+
describe "Should indicate no recovery needed for completed requirement"
|
|
283
|
+
|
|
284
|
+
# Arrange
|
|
285
|
+
setup_requirement_with_status "REQ-010" "completed" "completed"
|
|
286
|
+
|
|
287
|
+
# Act
|
|
288
|
+
local exit_code=0
|
|
289
|
+
local output=$(run_recover "REQ-010" --dry-run 2>&1) || exit_code=$?
|
|
290
|
+
|
|
291
|
+
# Assert - 已完成应该退出成功但提示无需恢复
|
|
292
|
+
if [[ $exit_code -eq 0 ]]; then
|
|
293
|
+
assert_contains "$output" "完成\|complete" "Should mention completion"
|
|
294
|
+
fi
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
# ============================================================================
|
|
298
|
+
# 运行所有测试 (仅基础测试,完整测试需要真实Git环境)
|
|
299
|
+
# ============================================================================
|
|
300
|
+
|
|
301
|
+
run_tests \
|
|
302
|
+
test_help_flag \
|
|
303
|
+
test_script_executes \
|
|
304
|
+
test_has_required_options
|