- Notifications
You must be signed in to change notification settings - Fork 3
feat: rts from committed changes #98
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
Conversation
add a flag to allow checking for tests from changes between commits
use pytest fixture to clean up test code
remove the useless git head commithash parameters from diff functions
change logic of rts to always consider both committed and workdir tests
fix some wrong docstrings for git functions
README.md Outdated
| As a result only tests related to changes in working directory and branch will be executed. | ||
| As a result only tests related to changes in working directory will be executed. | ||
| | ||
| #### Tests from working directory + committed changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's have the title starting the same way as previous: "Tests from changes in Git working directory + committed changes" to make it clear that it is the same as previous with some extra.
pytest_rts/utils/git.py Outdated
| """Check if a given commithash exists in the Git repository""" | ||
| if not commithash: | ||
| return False | ||
| return commithash in [commit.hash for commit in repo.get_list_commits()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- it is better to use
repo.get_commit(commithash)here - print warning if
commithashis provided but doesn't exist in history
pytest_rts/utils/common.py Outdated
| Otherwise the commithash is compared to the current working copy. | ||
| """ | ||
| repo = get_git_repo() | ||
| if not commit_exists(commithash_to_compare, repo): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inverted condition is more readable: compare if commit_exists() with if not commit_exists()
simplify checking if a given commit exists for change detection
| *__pycache__* | ||
| runpytest-* | ||
| stderr | ||
| stdout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are stderr and stdout here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files produced by the pytester plugin. I thought ignoring them would make debugging test cases for running working directory changes easier.
Here's a version that can check tests from committed changes with
--rts-from-commit=[init commithash]. If it's not provided, only changes in the working directory are checked. A slight problem is that new tests are discovered independently from the workdir/committed option and it would require some extra checking to get things perfectly right.Wrote some testcases for various situations. Also noticed that I created really flaky tests in the last PR because
__pycache__files in the testrepo didn't update between runs. I think I fixed it by clearing them before each test.