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

Feature: support only running tests for modified files #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

briancappello
Copy link

@briancappello briancappello commented Nov 30, 2017

I took a stab at fixing #71 - this solution works for me, and hopefully should be flexible enough for others to make work relatively easily with their directory structures. But feedback is appreciated!

I added docs to the README, hopefully they should be sufficient explanation for how to use it.

Basically how it works:

On startup, run all tests, and watch for events (same as before).
On startup, collect a list of all the valid test filepaths (using py.test --collect-only)
On new events, update (if necessary) the valid test filepaths
On new events, collect the list of modified files from the events, and for each modified file, call an end-user-supplied function to convert the modified file path into its respective test file path. The test file paths are then appended to the args for the call to pytest. If any of the given test file paths are not in the list of valid tests, then run all tests.

Thanks!

edits: clarify explanation of implementation details

@blueyed
Copy link
Collaborator

blueyed commented Dec 3, 2017

Interesting, but rather complex (from a quick look).
Do you expect the transformation function to figure out what test (file) needs to run for some changed code?

Do you know about pytest-testmon, or pytest-incremental?
You could trigger / use those instead.

@briancappello
Copy link
Author

@blueyed Thanks for taking a look!

Do you expect the transformation function to figure out what test (file) needs to run for some changed code?

Yes, I wasn't sure how else to do it (as different projects might have different conventions they follow).

Do you know about pytest-testmon, or pytest-incremental?

I did not! But I do now :) I'll take a look at them when I have some time later this week. Thanks for the suggestions, hopefully they can help simplify the code.

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.

None yet

2 participants