fix: classify Android androidTest/ sources and *IT.java/*IT.kt as test files#766
fix: classify Android androidTest/ sources and *IT.java/*IT.kt as test files#766bittoby wants to merge 1 commit intoentrius:testfrom
Conversation
anderdc
left a comment
There was a problem hiding this comment.
Drop the IT-suffix regex — the new androidtest[a-z]*/ and integrationtest/ directory patterns cover every real-world case (Maven Failsafe puts *IT.java under src/test/, Gradle Android puts them under androidTest/). The IT-suffix branch only catches hypothetical files outside any test directory and risks false-positives on production classes named *IT.{java,kt,kts}.
… spec/ files as test files
78844d5 to
8b38400
Compare
Fixed all! |
Fixes #765
Summary
FileChange.is_test_file()missed three real-world test conventions, causing those files to be scored at full production weight (1.0) instead ofTEST_FILE_CONTRIBUTION_WEIGHT(0.05) — a 20× over-score per token:androidTest/,androidTestGeneric/,androidTestGplay/, etc.integrationTest/— also covers Maven Failsafe*IT.java/.kt/.ktsfiles, which by convention live undersrc/test/orsrc/integrationTest/and are caught by the directory rule rather than a filename-suffix rule.spec/directory and the*_spec.{rb,js,ts,…}filename suffix.Impact is concrete:
nextcloud/androidkeeps its integration tests underapp/src/androidTest/...(16+ files likeUploadIT.java,AbstractIT.java,ActivitiesFragmentIT.kt); Ruby projects keep specs underspec/models/account_spec.rb. Each was previously mis-scored at production weight.Changes
gittensor/classes.py:(^|/)androidtest[a-z]*/,(^|/)integrationtest/, and(^|/)spec/to the directory pattern set._spec\.[^.]+$to the basename pattern set.re.compile-backed tuples (_TEST_DIR_PATTERNS,_TEST_BASENAME_PATTERNS) and extracted two small helpers (_matches_test_dir_pattern,_matches_test_basename_pattern) — avoids re-allocating and re-compiling the lists on every call tois_test_file().tests/test_classes.py: 23 new parametrized assertions across 3 test functions, plus a regression check covering the pre-existing conventions — Gradle Android & integrationTest paths, Ruby RSpecspec/paths and_spec.*suffixes, and lookalike negatives (Edit.java,build.gradle.kts,docs/androidtest.md,specification.rb,spectrum.rb,spec.rb).Test Plan
pytest tests/test_classes.py— 25 passedpytest tests/— 676 passed, 0 regressionspre-commit run --all-files --hook-stage pre-push— ruff, pyright, pytest all passapp/src/androidTest/java/...IT.java) now returnsTrueEdit.java,Commit.java,Unit.kt,build.gradle.kts,docs/androidtest.md,specification.rb,spectrum.rb,spec.rb) still returnFalse