@@ -15,7 +15,7 @@ test_number=0
15
15
failures=0
16
16
17
17
# Print TAP plan
18
- echo " 1..12 "
18
+ echo " 1..9 "
19
19
20
20
# Create a temporary directory for this test
21
21
test_dir=$( create_test_dir)
@@ -33,15 +33,9 @@ echo "Initial content" > test_file.txt
33
33
git add test_file.txt
34
34
git commit -m " Initial commit" > /dev/null 2>&1
35
35
36
- # Make a change to test file
36
+ # Make a change to test file for detecting diffs
37
37
echo " 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
43
38
git add test_file.txt
44
- git commit -m " Third commit" > /dev/null 2>&1
45
39
46
40
# Create test prompt files
47
41
mkdir -p " $test_dir /repo/prompts"
64
58
failures=$(( failures + 1 ))
65
59
fi
66
60
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
81
62
no_prompt_output=$( cd " $test_dir /repo" && " $PROJECT_ROOT /git-context" --no-prompt 2>&1 )
82
63
if ! echo " $no_prompt_output " | grep -q " Commit Message Guidance" ; then
83
64
echo " ok $(( test_number+= 1 )) - no-prompt option suppresses guidance"
87
68
failures=$(( failures + 1 ))
88
69
fi
89
70
90
- # Test 4 : Invalid option
71
+ # Test 3 : Invalid option
91
72
if ! " $PROJECT_ROOT /git-context" --invalid-option > /dev/null 2>&1 ; then
92
73
echo " ok $(( test_number+= 1 )) - invalid option causes error"
93
74
else
98
79
99
80
echo " # Section 2: Output Format Tests"
100
81
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
102
87
output=$( cd " $test_dir /repo" && " $PROJECT_ROOT /git-context" 2>&1 )
103
88
if echo " $output " | grep -q " ## Git Status" ; then
104
89
echo " ok $(( test_number+= 1 )) - output contains Git Status section"
108
93
failures=$(( failures + 1 ))
109
94
fi
110
95
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
121
97
if echo " $output " | grep -q " ## Files Changed" ; then
122
98
echo " ok $(( test_number+= 1 )) - output contains Files Changed section"
123
99
else
126
102
failures=$(( failures + 1 ))
127
103
fi
128
104
129
- # Test 8 : Check for Recent Commits section
105
+ # Test 6 : Check for Recent Commits section
130
106
if echo " $output " | grep -q " ## Recent Commits" ; then
131
107
echo " ok $(( test_number+= 1 )) - output contains Recent Commits section"
132
108
else
135
111
failures=$(( failures + 1 ))
136
112
fi
137
113
138
- # Test 9 : Check if output is in markdown format
114
+ # Test 7 : Check if output is in markdown format
139
115
if echo " $output " | grep -q " ^#" && echo " $output " | grep -q " \`\`\` " ; then
140
116
echo " ok $(( test_number+= 1 )) - output is in markdown format"
141
117
else
146
122
147
123
echo " # Section 3: Prompt Handling Tests"
148
124
149
- # Test 10 : Default prompt
125
+ # Test 8 : Default prompt
150
126
prompt_output=$( cd " $test_dir /repo" && " $PROJECT_ROOT /git-context" 2>&1 )
151
127
if echo " $prompt_output " | grep -q " Default prompt content" ; then
152
128
echo " ok $(( test_number+= 1 )) - default prompt is included"
157
133
failures=$(( failures + 1 ))
158
134
fi
159
135
160
- # Test 11 : Custom prompt file
136
+ # Test 9 : Custom prompt file
161
137
custom_output=$( cd " $test_dir /repo" && " $PROJECT_ROOT /git-context" --prompt=custom_prompt.txt 2>&1 )
162
138
if echo " $custom_output " | grep -q " Custom prompt content" ; then
163
139
echo " ok $(( test_number+= 1 )) - custom prompt file is used"
@@ -168,17 +144,6 @@ else
168
144
failures=$(( failures + 1 ))
169
145
fi
170
146
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
-
182
147
# Clean up
183
148
echo " # Tests completed, cleaning up"
184
149
cleanup_test_dir " $test_dir "
0 commit comments