Skip to content

Instantly share code, notes, and snippets.

@kangwonlee
Created December 2, 2017 15:13
Show Gist options
  • Save kangwonlee/0ebbb8afe90f70f5857d943c9fc15828 to your computer and use it in GitHub Desktop.
Save kangwonlee/0ebbb8afe90f70f5857d943c9fc15828 to your computer and use it in GitHub Desktop.
Run unittest over a range of commits
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