Created
December 2, 2017 15:13
-
-
Save kangwonlee/0ebbb8afe90f70f5857d943c9fc15828 to your computer and use it in GitHub Desktop.
Run unittest over a range of commits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import sys | |
def generate_commit(data_txt): | |
for line in data_txt.splitlines(): | |
yield line.split()[0] | |
def main(git_path, start_commit, end_commit, python_path, unittest_file_path): | |
completed_process = subprocess.run([git_path, 'log', '--oneline', start_commit + '..' + end_commit], stdout=subprocess.PIPE) | |
for commit_txt in generate_commit(completed_process.stdout): | |
print(commit_txt.decode('utf-8')) | |
# https://stackoverflow.com/questions/606191/convert-byto-to-a-string | |
subprocess.run([git_path, 'checkout', commit_txt.decode('utf-8')]) | |
subprocess.run([python_path, '-m', 'unittest', unittest_file_path]) | |
if __name__ == '__main__': | |
main(*sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment