Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce autoTestDiscoverOnSavePattern configuration option #24728

Conversation

soceanainn
Copy link

@soceanainn soceanainn commented Jan 17, 2025

Closes #24817

What this change does

Introduce autoTestDiscoverOnSavePattern configuration option to control autoTestDiscoverOnSaveEnabled behavior to only attempt test discovery refresh when files matching the specified glob pattern are saved.

Why this change

In a Python project we have with over 40K tests, developers definitely notice issues when pytest discovery is running whenever any file in the workspace is saved, despite all tests matching a very consistent pattern (./tests/**/test_*.py).

Other alternatives I considered

I did consider trying to match only the specific patterns used by unittest/pytest here. Given that would require parsing underlying configuration files / raw args in the test configuration for the workspace for both unittest and pytest (plus any other test runners supported in future) - I don't think that's going to be easy to maintain. Plus the addition / deletion of __init__.py files play a significant part in test discovery despite not being covered by the test configuration pattern - so this solution would be incomplete.

Another alternative would be to accept a parent directory and only include python files from that directory + subdirectories (using workspace directory as default value). This avoids introducing a glob configuration value, but feels very limiting.

@soceanainn soceanainn force-pushed the seamus/avoid-eager-test-refresh-for-non-test-files branch from c61bbd7 to 564eacf Compare January 17, 2025 19:55
@soceanainn soceanainn force-pushed the seamus/avoid-eager-test-refresh-for-non-test-files branch from 564eacf to b5c1b48 Compare January 17, 2025 19:57
@soceanainn
Copy link
Author

@microsoft-github-policy-service agree

@eleanorjboyd
Copy link
Member

Hi @soceanainn, apologies for the delay! Think this is a great add but will need to discuss with the team about the settings add- I will get back to you soon! Thanks

@soceanainn
Copy link
Author

Thanks @eleanorjboyd !

I think it's missing 'skip package*.json' label (and any other relevant labels) which I don't have permissions to add, but otherwise should be good to go from a CI perspective.

It would be good to try to get this in ASAP, as VsCode is borderline unusable on our project with autoTestDiscoverOnSaveEnabled enabled (multiple devs reporting freezing on save when test discovery kicks in). We have something like ~40K tests in the project.

@karthiknadig karthiknadig added feature-request Request for new features or functionality skip package*.json package.json and package-lock.json don't both need updating labels Feb 14, 2025
@eleanorjboyd eleanorjboyd added the skip tests Updates to tests unnecessary label Feb 14, 2025
@eleanorjboyd
Copy link
Member

yes will merge it today after getting additional approval from a coworker. Will also need to change the glob pattern to **/*.py as default since I think this will work for any python file regardless of if its in a subdirectory etc so Ill make that edit too

karthiknadig
karthiknadig previously approved these changes Feb 14, 2025
@karthiknadig karthiknadig merged commit 08e228d into microsoft:main Feb 14, 2025
46 checks passed
@eleanorjboyd
Copy link
Member

@soceanainn now that this is merged it will be on the next version of the python extension pre-release (which will come out monday morning). If you are able to give it a try and let me know if it works as intended that would be great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality skip package*.json package.json and package-lock.json don't both need updating skip tests Updates to tests unnecessary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add autoTestDiscoverOnSavePattern setting to filter when discovery is run
3 participants