Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.