fix(categorize): recognise Go, Python and Ruby test files - #66
Conversation
The "testing" rule only matched JS/TS conventions (a test/spec directory or the `.test.`/`.spec.` infix), so `foo_test.go` (Go), `test_foo.py` (Python) and `foo_spec.rb` (Ruby) fell through to the "backend" rule and were miscategorised. Extend the rule to also match the `_test.`/`_spec.` suffix and the `test_` prefix, across any file extension. Adds tests for categorize covering the new cases and guarding against false positives such as `latest.go` and `contest.py`.
|
Welcome, and thanks for a great first contribution. Correct diagnosis, tight fix, and you brought tests for a module that had none dedicated to it. The false-positive guards ( Verified locally: full suite green on your branch, typecheck clean. One thing before merge: every change here ships with a CHANGELOG.md entry (Keep a Changelog format). Can you add one under Small heads-up, no action needed: your suffix rule is broader than the title says ( |
|
Thanks for the changelog entry, and nice to see the assist from @eeshsaxena. One mechanical thing: that commit converted the whole CHANGELOG.md to CRLF line endings, so the diff rewrites all 1000+ lines instead of adding 5. Can you re-save it with LF endings (the repo's format) so the diff is just your new entry? |
c4d6721 to
1a87700
Compare
|
Thanks for the careful review, and good catch on the line endings. That was my editor rewriting the whole file as CRLF. I have re-saved CHANGELOG.md with LF endings to match the repo, so the diff is now just the five added lines for the Unreleased entry. The categorize fix and tests are unchanged. |
# Conflicts: # CHANGELOG.md
|
Merged. Welcome to the contributor list — first PR with a real bug, a correct fix, honest false-positive guards, and the repo's first dedicated categorize test file. Go test files finally count as what they are. Hope to see you around for another one. |
Bug
categorize(src/categorize.ts) only recognises JS/TS test conventions in its "testing" rule (atest//spec/directory or the.test./.spec.infix). Test files from other languages fall through to the "backend" rule and are miscategorised:Go's
_test.goin particular is a hard convention, so every Go test file is currently counted as backend, which inflates "backend" and undercounts "testing".Fix
Extend the "testing" rule to also match the
_test./_spec.suffix (Go, Ruby, and others) and the Pythontest_prefix, across any file extension. Existing JS/TS matches are unchanged.Tests
Added
test/categorize.test.tscovering the JS/TS, Go, Python and Ruby cases, and guarding against false positives such aslatest.goandcontest.py, which stay "backend".