@@ -228,18 +228,19 @@ test_benchmark_20_files() {
228228 git -C " $repo " add -A && git -C " $repo " commit -m " add 20 pairs" --quiet 2> /dev/null
229229
230230 local start_time end_time elapsed
231- start_time=$( date +%s )
231+ start_time=$( python3 -c " import time; print(time.time()) " )
232232 for i in $( seq 1 20) ; do
233233 fuzzy_find_associated_tests " $repo /src/module_${i} .py" " $repo " > /dev/null 2>&1
234234 done
235- end_time=$( date +%s )
236- elapsed=$(( end_time - start_time ) )
235+ end_time=$( python3 -c " import time; print(time.time()) " )
236+ elapsed=$( python3 -c " print(int(( $ end_time - $ start_time) * 1000)) " )
237237
238- if (( elapsed < 10 )) ; then
238+ # elapsed is now in milliseconds; 10s = 10000ms
239+ if (( elapsed < 10000 )) ; then
239240 (( ++ PASS ))
240241 else
241242 (( ++ FAIL ))
242- echo " FAIL: benchmark_20_files — took ${elapsed} s (limit: 10s )" >&2
243+ echo " FAIL: benchmark_20_files — took ${elapsed} ms (limit: 10000ms )" >&2
243244 fi
244245}
245246
@@ -287,6 +288,27 @@ test_red_phase_counter_additive() {
287288 fi
288289}
289290
291+ # ── Test 12: source-file-is-test-file edge case ──────────────────────────────
292+ # Bug dso-ovj9: when the source file IS a test file (e.g., tests/test_foo.py),
293+ # fuzzy_find_associated_tests should return itself (it's its own test).
294+ test_source_file_is_test_file () {
295+ if (( ! _FUZZY_MATCH_LOADED )) ; then
296+ (( ++ FAIL ))
297+ echo " FAIL: test_source_file_is_test_file — fuzzy-match.sh not loaded" >&2
298+ return
299+ fi
300+ local repo
301+ repo=$( create_test_repo)
302+ mkdir -p " $repo /tests"
303+ echo " pass" > " $repo /tests/test_foo.py"
304+ git -C " $repo " add -A && git -C " $repo " commit -m " add test" --quiet 2> /dev/null
305+
306+ local result
307+ result=$( fuzzy_find_associated_tests " $repo /tests/test_foo.py" " $repo " )
308+ # A test file queried as source should return itself (it's its own associated test)
309+ assert_ne " source-is-test: result should be non-empty" " " " $result "
310+ }
311+
290312# ── Run all tests ────────────────────────────────────────────────────────────
291313test_bash_convention_matches
292314test_python_convention_matches
@@ -299,6 +321,7 @@ test_custom_test_dirs
299321test_benchmark_20_files
300322test_dogfood_bump_version
301323test_red_phase_counter_additive
324+ test_source_file_is_test_file
302325
303326# ── Summary ──────────────────────────────────────────────────────────────────
304327# In RED phase (library missing), all tests correctly FAIL. Print summary with
0 commit comments