@@ -15,7 +15,7 @@ test_number=0
1515failures=0
1616
1717# Print TAP plan
18- echo " 1..12 "
18+ echo " 1..9 "
1919
2020# Create a temporary directory for this test
2121test_dir=$( create_test_dir)
@@ -33,15 +33,9 @@ echo "Initial content" > test_file.txt
3333git add test_file.txt
3434git commit -m " Initial commit" > /dev/null 2>&1
3535
36- # Make a change to test file
36+ # Make a change to test file for detecting diffs
3737echo " Modified content" >> test_file.txt
38-
39- # Modify the file and make additional commits for recent-commits test
40- git add test_file.txt
41- git commit -m " Second commit" > /dev/null 2>&1
42- echo " Third commit content" >> test_file.txt
4338git add test_file.txt
44- git commit -m " Third commit" > /dev/null 2>&1
4539
4640# Create test prompt files
4741mkdir -p " $test_dir /repo/prompts"
6458 failures=$(( failures + 1 ))
6559fi
6660
67- # Test 2: Recent commits option
68- # Check that --recent-commits=1 only shows one commit
69- recent_commits_output=$( cd " $test_dir /repo" && " $PROJECT_ROOT /git-context" --recent-commits=1 2>&1 )
70- if echo " $recent_commits_output " | grep -q " Recent Commits" &&
71- [ $( echo " $recent_commits_output " | grep -c " commit" ) -eq 1 ]; then
72- echo " ok $(( test_number+= 1 )) - recent-commits option limits commit count"
73- else
74- echo " not ok $(( test_number+= 1 )) - recent-commits option limits commit count"
75- echo " # Output did not show exactly 1 commit with --recent-commits=1"
76- echo " # Output: $recent_commits_output "
77- failures=$(( failures + 1 ))
78- fi
79-
80- # Test 3: No-prompt option
61+ # Test 2: No-prompt option
8162no_prompt_output=$( cd " $test_dir /repo" && " $PROJECT_ROOT /git-context" --no-prompt 2>&1 )
8263if ! echo " $no_prompt_output " | grep -q " Commit Message Guidance" ; then
8364 echo " ok $(( test_number+= 1 )) - no-prompt option suppresses guidance"
8768 failures=$(( failures + 1 ))
8869fi
8970
90- # Test 4 : Invalid option
71+ # Test 3 : Invalid option
9172if ! " $PROJECT_ROOT /git-context" --invalid-option > /dev/null 2>&1 ; then
9273 echo " ok $(( test_number+= 1 )) - invalid option causes error"
9374else
9879
9980echo " # Section 2: Output Format Tests"
10081
101- # Test 5: Check for Git Status section
82+ # Make a change to test file for diff output
83+ cd " $test_dir /repo"
84+ echo " Modified for diff" > test_file.txt
85+
86+ # Test 4: Check for Git Status section
10287output=$( cd " $test_dir /repo" && " $PROJECT_ROOT /git-context" 2>&1 )
10388if echo " $output " | grep -q " ## Git Status" ; then
10489 echo " ok $(( test_number+= 1 )) - output contains Git Status section"
10893 failures=$(( failures + 1 ))
10994fi
11095
111- # Test 6: Check for Current Changes section
112- if echo " $output " | grep -q " ## Current Changes (Diff)" ; then
113- echo " ok $(( test_number+= 1 )) - output contains Current Changes section"
114- else
115- echo " not ok $(( test_number+= 1 )) - output contains Current Changes section"
116- echo " # Output did not contain Current Changes section"
117- failures=$(( failures + 1 ))
118- fi
119-
120- # Test 7: Check for Files Changed section
96+ # Test 5: Check for Files Changed section
12197if echo " $output " | grep -q " ## Files Changed" ; then
12298 echo " ok $(( test_number+= 1 )) - output contains Files Changed section"
12399else
126102 failures=$(( failures + 1 ))
127103fi
128104
129- # Test 8 : Check for Recent Commits section
105+ # Test 6 : Check for Recent Commits section
130106if echo " $output " | grep -q " ## Recent Commits" ; then
131107 echo " ok $(( test_number+= 1 )) - output contains Recent Commits section"
132108else
135111 failures=$(( failures + 1 ))
136112fi
137113
138- # Test 9 : Check if output is in markdown format
114+ # Test 7 : Check if output is in markdown format
139115if echo " $output " | grep -q " ^#" && echo " $output " | grep -q " \`\`\` " ; then
140116 echo " ok $(( test_number+= 1 )) - output is in markdown format"
141117else
146122
147123echo " # Section 3: Prompt Handling Tests"
148124
149- # Test 10 : Default prompt
125+ # Test 8 : Default prompt
150126prompt_output=$( cd " $test_dir /repo" && " $PROJECT_ROOT /git-context" 2>&1 )
151127if echo " $prompt_output " | grep -q " Default prompt content" ; then
152128 echo " ok $(( test_number+= 1 )) - default prompt is included"
157133 failures=$(( failures + 1 ))
158134fi
159135
160- # Test 11 : Custom prompt file
136+ # Test 9 : Custom prompt file
161137custom_output=$( cd " $test_dir /repo" && " $PROJECT_ROOT /git-context" --prompt=custom_prompt.txt 2>&1 )
162138if echo " $custom_output " | grep -q " Custom prompt content" ; then
163139 echo " ok $(( test_number+= 1 )) - custom prompt file is used"
@@ -168,17 +144,6 @@ else
168144 failures=$(( failures + 1 ))
169145fi
170146
171- # Test 12: Conventional commit prompt
172- conventional_output=$( cd " $test_dir /repo" && " $PROJECT_ROOT /git-context" --prompt=prompts/conventional_commit.txt 2>&1 )
173- if echo " $conventional_output " | grep -q " Conventional commit content" ; then
174- echo " ok $(( test_number+= 1 )) - conventional commit prompt is used"
175- else
176- echo " not ok $(( test_number+= 1 )) - conventional commit prompt is used"
177- echo " # Output did not contain conventional commit content"
178- echo " # Output: $( echo " $conventional_output " | grep -A 2 -B 2 " Commit Message Guidance" || echo " No guidance section found" ) "
179- failures=$(( failures + 1 ))
180- fi
181-
182147# Clean up
183148echo " # Tests completed, cleaning up"
184149cleanup_test_dir " $test_dir "
0 commit comments