]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-build.git/commitdiff
create pytest tests
authorAlfredo Deza <adeza@redhat.com>
Wed, 6 Jan 2016 21:13:55 +0000 (16:13 -0500)
committerAlfredo Deza <adeza@redhat.com>
Wed, 6 Jan 2016 21:15:29 +0000 (16:15 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
ceph-pr-commits/build/test_commits.py [new file with mode: 0644]

diff --git a/ceph-pr-commits/build/test_commits.py b/ceph-pr-commits/build/test_commits.py
new file mode 100644 (file)
index 0000000..e631d8b
--- /dev/null
@@ -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