From 17893685e0166903491d2b3b8d959c94716bcd1e Mon Sep 17 00:00:00 2001 From: Arunendra21 <156455722+Arunendra21@users.noreply.github.com> Date: Thu, 6 Aug 2026 10:03:35 +0530 Subject: [PATCH 1/2] fix(categorize): recognise Go, Python and Ruby test files 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`. --- src/categorize.ts | 10 +++++++++- test/categorize.test.ts | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/categorize.test.ts 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"); + }); +}); From 1a877003e7a2e9d8072a2ea690f54aa433023a94 Mon Sep 17 00:00:00 2001 From: Arunendra21 <156455722+Arunendra21@users.noreply.github.com> Date: Sun, 9 Aug 2026 14:48:41 +0530 Subject: [PATCH 2/2] docs(changelog): add Unreleased Fixed entry for multi-language test detection --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61bdd18..7c91721 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versioning: strict [semver](https://semver.org/) — bundle schema changes always bump at least minor; breaking schema changes bump major. +## [Unreleased] + +### 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`. + ## [0.10.0] - 2026-08-05 ### Added