@@ -158,17 +158,26 @@ test_full_script_execution() {
158158 TESTS_RUN=$(( TESTS_RUN + 1 ))
159159 info " Test 3: Full script execution"
160160
161- # Run the script - it will operate on the actual repo, not test env
162- # So we just verify it doesn't crash
163- if bash " $SCRIPT_UNDER_TEST " > /tmp/test-output-$$ .log 2>&1 ; then
164- pass " Script executed without errors"
161+ # Create a modified version of the script that operates in TEST_DIR
162+ local test_script=" /tmp/test-script-$$ .sh"
163+ sed " s|REPO_ROOT=.*|REPO_ROOT=\" $TEST_DIR \" |" " $SCRIPT_UNDER_TEST " > " $test_script "
164+ chmod +x " $test_script "
165+
166+ # Run the modified script in the test environment
167+ cd " $TEST_DIR "
168+ if bash " $test_script " > /tmp/test-output-$$ .log 2>&1 ; then
169+ # Verify it updated the test README
170+ if grep -q ' <version>1.2.3</version>' README.md; then
171+ pass " Script executed and updated versions correctly"
172+ else
173+ fail " Script execution" " versions updated to 1.2.3" " versions not updated"
174+ cat /tmp/test-output-$$ .log
175+ fi
165176 else
166177 fail " Script execution" " exit code 0" " exit code $? "
167178 cat /tmp/test-output-$$ .log
168- rm -f /tmp/test-output-$$ .log
169- return
170179 fi
171- rm -f /tmp/test-output-$$ .log
180+ rm -f /tmp/test-output-$$ .log " $test_script "
172181}
173182
174183# Test 4: Version pattern matching
@@ -227,20 +236,24 @@ test_error_handling() {
227236 TESTS_RUN=$(( TESTS_RUN + 1 ))
228237 info " Test 6: Script handles errors gracefully"
229238
230- # The script always returns to REPO_ROOT, so we test that it handles
231- # missing files in the FILES_TO_UPDATE array gracefully
239+ # Test that script handles missing files gracefully
232240 cd " $TEST_DIR "
233241 rm -f README.md
234242
235- # Override FILES_TO_UPDATE to include a non-existent file
236- FILES_TO_UPDATE=(" README.md" " nonexistent-file.md" ) bash " $SCRIPT_UNDER_TEST " 2>&1 | tee /tmp/test-error-output-$$ .log
243+ # Create a modified version of the script that operates in TEST_DIR
244+ local test_script=" /tmp/test-script-error-$$ .sh"
245+ sed " s|REPO_ROOT=.*|REPO_ROOT=\" $TEST_DIR \" |" " $SCRIPT_UNDER_TEST " > " $test_script "
246+ chmod +x " $test_script "
247+
248+ # Run with missing README.md file
249+ bash " $test_script " 2>&1 | tee /tmp/test-error-output-$$ .log
237250 if grep -q " WARNING: File not found" /tmp/test-error-output-$$ .log; then
238251 pass " Script handles missing files gracefully"
239252 else
240253 # If no warning, that's also ok as long as script doesn't crash
241254 pass " Script completes even with missing files"
242255 fi
243- rm -f /tmp/test-error-output-$$ .log
256+ rm -f /tmp/test-error-output-$$ .log " $test_script "
244257 cd " $TEST_DIR "
245258}
246259
0 commit comments