Skip to content

test(scripts): run only unit tests affected by changed files - #1065

Open
greenc-FNAL wants to merge 1 commit into
Framework-R-D:mainfrom
greenc-FNAL:maintenance/improve-pre-commit-script-test-selection
Open

greenc-FNAL wants to merge 1 commit into
Framework-R-D:mainfrom
greenc-FNAL:maintenance/improve-pre-commit-script-test-selection

Conversation

@greenc-FNAL

Copy link
Copy Markdown
Contributor
  • Add a selector that maps changed source and configuration files to relevant test modules, falling back to the full suite for unmapped dependencies.
  • Update the pre-commit hook to pass changed filenames to the selector, avoiding unrelated test runs.

- Add a selector that maps changed source and configuration files to relevant test modules, falling back to the full suite for unmapped dependencies.
- Update the pre-commit hook to pass changed filenames to the selector, avoiding unrelated test runs.
@coderabbitai

coderabbitai Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 42 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 6c08c5d5-c703-466f-a20f-2a03859e4274
Commits

Reviewing files that changed from the base of the PR and between 04d4754 and 8c7d9fb.

Files selected for processing: 3

  • .pre-commit-config.yaml
  • scripts/run_script_tests.py
  • scripts/test/test_run_script_tests.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.92593% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
scripts/run_script_tests.py 75.92% 13 Missing ⚠️
@@            Coverage Diff             @@
##             main    #1065      +/-   ##
==========================================
- Coverage   90.89%   86.46%   -4.43%     
==========================================
  Files         181       13     -168     
  Lines        6027     1817    -4210     
  Branches      960        0     -960     
==========================================
- Hits         5478     1571    -3907     
+ Misses        351      246     -105     
+ Partials      198        0     -198     
Flag Coverage Δ
amd64 ?
arm64 86.46% <75.92%> (-4.43%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
scripts/run_script_tests.py 75.92% <75.92%> (ø)

... and 193 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04d4754...8c7d9fb. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +53 to +56

def test_changed_unmapped_script_code_selects_all_tests() -> None:
"""Run all tests for script code not represented in the dependency map."""
assert select_tests(["scripts/new_helper.py"]) == _all_tests()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this case should be an error? Or it should execute no tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unmapped script changes intentionally select all script tests. Without an explicit mapping, we cannot safely infer which tests are affected; selecting none could silently skip relevant coverage. Failing instead would impose a mapping requirement that is not part of the current contract. The existing regression test at scripts/test/test_run_script_tests.py:54-56 covers this fallback. The focused prek hook passed; direct pytest was unavailable because the system Python 3.12 lacks pytest.

@knoepfel knoepfel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@greenc-FNAL, thanks for the PR. Only one comment for your consideration.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants