utils/devstats/tests/test_excludes.py
Krzysztof kuhy Rudnicki 6e5b5d1c3a Add devstats: kuhy vs the 100x article
`python -m devstats compare` walks ~/src, counts kuhy's default-branch
commits once per piece of work (worktrees, clones and filter-repo copies
folded in), drops lockfiles/generated/vendored/data via excludes.py, and
prints 30/90/300-day net LoC/day, per-active-day vs 194, commits and
tags beside the article's Cmdr figures. --write regenerates
devstats/DOCS-comparison.md (aggregates only); --by-repo is terminal-only.
Read-only: only rev-parse, for-each-ref and log, GIT_OPTIONAL_LOCKS=0.

Bug-class-check: none — new tool, not a bug fix
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 12:18:05 +01:00

69 lines
2.4 KiB
Python

"""The one exclude list decides what counts as code, docs or dropped churn."""
from __future__ import annotations
import pytest
from devstats.excludes import RULES, classify
@pytest.mark.parametrize(
("path", "bucket"),
[
("src/main.py", "code"),
("tests/test_main.py", "code"),
("lib/screen.dart", "code"),
("scenes/level.tscn", "code"),
("Makefile", "code"),
("package.json", "code"),
("web/tsconfig.app.json", "code"),
("requirements-dev.txt", "code"),
("native/CMakeLists.txt", "code"),
# lockfiles
("web/pnpm-lock.yaml", "excluded"),
("package-lock.json", "excluded"),
("uv.lock", "excluded"),
("app/pubspec.lock", "excluded"),
("go.sum", "excluded"),
# generated
("lib/model.g.dart", "excluded"),
("lib/model.freezed.dart", "excluded"),
("static/app.min.js", "excluded"),
("coverage.xml", "excluded"),
("icon.svg.import", "excluded"),
("player.gd.uid", "excluded"),
("android/build/reports/problems/problems-report.html", "excluded"),
("web/dist/index.js", "excluded"),
# vendored
("web/node_modules/x/index.js", "excluded"),
("addons/gut/gut.gd", "excluded"),
("game/addons/dev_tools/panel.gd", "excluded"),
("godot_dev_tools/addons/dev_tools/panel.gd", "code"),
("third_party/lib.c", "excluded"),
("vendor/pkg/a.go", "excluded"),
# data / assets
("pacman/words.txt", "excluded"),
("tools/eval/data/reference.json", "excluded"),
("assets/audio/MANIFEST.json", "excluded"),
("tests/fixtures/run.tcx", "excluded"),
("tests/fixtures/host/q.py", "excluded"),
("games/chips/sea.tres", "excluded"),
("report.csv", "excluded"),
# docs and translations
("README.md", "docs"),
("docs/guide.py", "docs"),
("lib/l10n/app_pl.arb", "docs"),
("public/locales/en.json", "docs"),
("LICENSE", "docs"),
# an excluded dir beats a docs file and a code keep
("node_modules/x/README.md", "excluded"),
("node_modules/x/package.json", "excluded"),
],
)
def test_classify(path: str, bucket: str) -> None:
assert classify(path) == bucket
def test_rules_use_known_buckets_only() -> None:
assert {bucket for bucket, _ in RULES} == {"code", "docs", "excluded"}