Skip to content

Conversation

@guotin
Copy link
Contributor

@guotin guotin commented Mar 24, 2021

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.

guotin and others added 2 commits March 24, 2021 17:16
add a flag to allow checking for tests from changes between commits
guotin and others added 5 commits March 25, 2021 15:05
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
Copy link
Contributor

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.

"""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()]
Copy link
Contributor

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 commithash is provided but doesn't exist in history
Otherwise the commithash is compared to the current working copy.
"""
repo = get_git_repo()
if not commit_exists(commithash_to_compare, repo):
Copy link
Contributor

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()

guotin and others added 2 commits March 29, 2021 08:29
simplify checking if a given commit exists for change detection
*__pycache__*
runpytest-*
stderr
stdout
Copy link
Contributor

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?

Copy link
Contributor Author

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.

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

Labels

None yet

4 participants