@@ -19,6 +19,9 @@ source "$SCRIPT_DIR/test-helpers.sh"
1919SETUP_SCRIPT=" $PROJECT_ROOT /scripts/setup-rlcr-loop.sh"
2020STOP_HOOK=" $PROJECT_ROOT /hooks/loop-codex-stop-hook.sh"
2121BITLESSON_TEMPLATE_FILE=" $PROJECT_ROOT /templates/bitlesson.md"
22+ BITLESSON_INIT_SCRIPT=" $PROJECT_ROOT /scripts/bitlesson-init.sh"
23+ BITLESSON_VALIDATE_DELTA_SCRIPT=" $PROJECT_ROOT /scripts/bitlesson-validate-delta.sh"
24+ BITLESSON_SELECT_SCRIPT=" $PROJECT_ROOT /scripts/bitlesson-select.sh"
2225
2326echo " =========================================="
2427echo " BitLesson Workflow Tests"
9699fi
97100
98101# ========================================
99- # Test 2: Setup initializes project-level bitlesson and round-0 requirements
102+ # Test 2: Extracted BitLesson scripts exist and validate inputs
100103# ========================================
101104
105+ if [[ -f " $BITLESSON_INIT_SCRIPT " && -x " $BITLESSON_INIT_SCRIPT " ]]; then
106+ pass " bitlesson-init.sh exists and is executable"
107+ else
108+ fail " bitlesson-init.sh exists and is executable" " executable script" " missing or not executable"
109+ fi
110+
111+ if [[ -f " $BITLESSON_VALIDATE_DELTA_SCRIPT " && -x " $BITLESSON_VALIDATE_DELTA_SCRIPT " ]]; then
112+ pass " bitlesson-validate-delta.sh exists and is executable"
113+ else
114+ fail " bitlesson-validate-delta.sh exists and is executable" " executable script" " missing or not executable"
115+ fi
116+
117+ if [[ -f " $BITLESSON_SELECT_SCRIPT " && -x " $BITLESSON_SELECT_SCRIPT " ]]; then
118+ pass " bitlesson-select.sh exists and is executable"
119+ else
120+ fail " bitlesson-select.sh exists and is executable" " executable script" " missing or not executable"
121+ fi
122+
102123setup_test_dir
124+ mkdir -p " $TEST_DIR /init-project"
125+
126+ set +e
127+ bash " $BITLESSON_INIT_SCRIPT " --project-root " $TEST_DIR /init-project" --template " $TEST_DIR /does-not-exist.md" > /dev/null 2>&1
128+ INIT_BAD_TEMPLATE_EXIT=$?
129+ set -e
130+
131+ if [[ " $INIT_BAD_TEMPLATE_EXIT " -ne 0 ]] && [[ ! -f " $TEST_DIR /init-project/bitlesson.md" ]]; then
132+ pass " bitlesson-init.sh errors when template file is missing"
133+ else
134+ fail " bitlesson-init.sh errors when template file is missing" " non-zero exit and no file created" " exit=$INIT_BAD_TEMPLATE_EXIT "
135+ fi
136+
137+ bash " $BITLESSON_INIT_SCRIPT " --project-root " $TEST_DIR /init-project" --template " $BITLESSON_TEMPLATE_FILE " > /dev/null 2>&1
138+
139+ if [[ -f " $TEST_DIR /init-project/bitlesson.md" ]]; then
140+ pass " bitlesson-init.sh creates bitlesson.md from template when missing"
141+ else
142+ fail " bitlesson-init.sh creates bitlesson.md from template when missing" " bitlesson.md created" " not found"
143+ fi
144+
145+ echo " SENTINEL" > " $TEST_DIR /init-project/bitlesson.md"
146+ bash " $BITLESSON_INIT_SCRIPT " --project-root " $TEST_DIR /init-project" --template " $BITLESSON_TEMPLATE_FILE " > /dev/null 2>&1
147+
148+ if grep -q " SENTINEL" " $TEST_DIR /init-project/bitlesson.md" ; then
149+ pass " bitlesson-init.sh does not overwrite an existing bitlesson.md"
150+ else
151+ fail " bitlesson-init.sh does not overwrite an existing bitlesson.md" " SENTINEL preserved" " template content overwritten"
152+ fi
153+
154+ # ========================================
155+ # Test 3: Setup initializes project-level bitlesson and round-0 requirements
156+ # ========================================
157+
103158init_test_git_repo " $TEST_DIR /project"
104159mkdir -p " $TEST_DIR /project/plans" " $TEST_DIR /project/bin"
105160cat > " $TEST_DIR /project/plans/plan.md" << 'EOF '
167222fi
168223
169224# ========================================
170- # Test 3 : Team/worktree templates enforce selector constraints
225+ # Test 4 : Team/worktree templates enforce selector constraints
171226# ========================================
172227
173228for template in \
185240done
186241
187242# ========================================
188- # Test 4 : Next-round prompt keeps BitLesson requirements
243+ # Test 5 : Next-round prompt keeps BitLesson requirements
189244# ========================================
190245
191246# Add one concrete lesson entry so Action:none in later round remains valid.
236291fi
237292
238293# ========================================
239- # Test 5 : Stop hook blocks Action:add when lesson IDs are not in bitlesson.md
294+ # Test 6 : Stop hook blocks Action:add when lesson IDs are not in bitlesson.md
240295# ========================================
241296
242297cat > " $LOOP_DIR /round-2-summary.md" << 'EOF '
258313fi
259314
260315# ========================================
261- # Test 6 : Stop hook blocks when BitLesson Delta is missing
316+ # Test 7 : Stop hook blocks when BitLesson Delta is missing
262317# ========================================
263318
264319cat > " $LOOP_DIR /round-2-summary.md" << 'EOF '
275330fi
276331
277332# ========================================
278- # Test 7 : Stop hook allows round>0 Action:none by default when bitlesson has no concrete entries
333+ # Test 8 : Stop hook allows round>0 Action:none by default when bitlesson has no concrete entries
279334# ========================================
280335
281336cp " $BITLESSON_TEMPLATE_FILE " " $TEST_DIR /project/bitlesson.md"
301356fi
302357
303358# ========================================
304- # Test 8 : Strict mode blocks round>0 Action:none when bitlesson has no concrete entries
359+ # Test 9 : Strict mode blocks round>0 Action:none when bitlesson has no concrete entries
305360# ========================================
306361
307362sed -i ' s/^bitlesson_allow_empty_none: true$/bitlesson_allow_empty_none: false/' " $STATE_FILE "
0 commit comments