diff --git a/CHANGELOG.md b/CHANGELOG.md index 94f98a0..5ce07fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ always bump at least minor; breaking schema changes bump major. - Add `infra/gitlab-ci` to the closed skill taxonomy (#24). ### Fixed +- Go (`foo_test.go`), Python (`test_foo.py`) and Ruby (`foo_spec.rb`) test files are now categorised as `testing` instead of falling through to `backend`. - Improve manifest dependency detection by comparing parent and child revision snapshots instead of relying only on added diff lines. This now correctly detects dependencies added inside existing blocks in diff --git a/src/categorize.ts b/src/categorize.ts index fba1801..c5a1f45 100644 --- a/src/categorize.ts +++ b/src/categorize.ts @@ -8,7 +8,15 @@ import type { CategoryName } from "./types.js"; // // Order matters: first matching rule wins. const RULES: Array<[RegExp, CategoryName]> = [ - [/(^|\/)(__tests__|tests?|specs?)(\/|$)|\.(test|spec)\.[jt]sx?$/i, "testing"], + // Recognise test files across languages: a `test/` or `spec/` directory, the + // JS/TS `.test.`/`.spec.` infix, the `_test.`/`_spec.` suffix used by Go + // (`foo_test.go`), Ruby (`foo_spec.rb`) and others, and the Python `test_` + // prefix (`test_foo.py`). Previously only the JS/TS forms were matched, so + // `foo_test.go` and `test_foo.py` fell through to "backend". + [ + /(^|\/)(__tests__|tests?|specs?)(\/|$)|[._](test|spec)\.[a-z0-9]+$|(^|\/)test_[^/]+\.[a-z0-9]+$/i, + "testing", + ], [/(^|\/)(claude\.md|agents\.md|\.cursor|\.aider|copilot)/i, "ai-workflow"], [ /(^|\/)(\.github\/workflows|dockerfile|docker-compose|terraform|k8s|kubernetes|infra)(\/|$|\.)/i, diff --git a/test/categorize.test.ts b/test/categorize.test.ts new file mode 100644 index 0000000..5b11462 --- /dev/null +++ b/test/categorize.test.ts @@ -0,0 +1,22 @@ +import { describe, expect, it } from "vitest"; + +import { categorize } from "../src/categorize.js"; + +describe("categorize", () => { + it("classifies JS/TS test files as testing", () => { + expect(categorize("src/Button.test.tsx")).toBe("testing"); + expect(categorize("__tests__/foo.ts")).toBe("testing"); + }); + + it("classifies Go, Python and Ruby test files as testing", () => { + expect(categorize("pkg/foo_test.go")).toBe("testing"); + expect(categorize("app/test_user.py")).toBe("testing"); + expect(categorize("lib/user_spec.rb")).toBe("testing"); + }); + + it("does not misclassify non-test source files", () => { + expect(categorize("src/api/users.go")).toBe("backend"); + expect(categorize("src/latest.go")).toBe("backend"); + expect(categorize("src/contest.py")).toBe("backend"); + }); +});