From: Alfredo Deza Date: Wed, 6 Jan 2016 21:13:55 +0000 (-0500) Subject: create pytest tests X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bc34e10c06ac7bea67461403c2007731b37e077e;p=ceph-build.git create pytest tests Signed-off-by: Alfredo Deza --- diff --git a/ceph-pr-commits/build/test_commits.py b/ceph-pr-commits/build/test_commits.py new file mode 100644 index 00000000..e631d8b4 --- /dev/null +++ b/ceph-pr-commits/build/test_commits.py @@ -0,0 +1,49 @@ +from subprocess import Popen, PIPE +import os + + +def run(command): + path = os.getenv('WORKSPACE', '../../../ceph') + print "running %s" % ' '.join(command) + print "at path: %s" % os.path.abspath(path) + process = Popen( + command, + cwd=path, + stdout=PIPE, + stderr=PIPE, + close_fds=True + ) + + returncode = process.wait() + + return process.stdout.read() + + +def get_commits(): + target_branch = os.getenv('ghprbTargetBranch', 'master') + source_branch = os.getenv('ghprbSourceBranch', 'HEAD') + command = ['git', 'log', '--no-merges', '%s..%s' % (target_branch, source_branch)] + output = run(command) + chunked_commits = [] + for chunk in output.split('\n\ncommit'): + if not chunk: + continue + chunked_commits.append(chunk) + return chunked_commits + + +commits = get_commits() + + +class TestSignedOffByCommits(object): + + def test_signed_off_by('commit', commits): + assert 'Signed-off-by:' in commit + + def extract_sha(self, lines): + # XXX Unused for now, if py.test can spit out the hashes in verbose + # mode this should be removed, otherwise put to good use + trim = lines.split() + for i in trim: + if i and 'commit' not in i: + return i