From: Alfredo Deza Date: Wed, 6 Jan 2016 21:14:13 +0000 (-0500) Subject: port build script to just run py.test X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=67394805847eb5bd84ab18143e588a538085e635;p=ceph-build.git port build script to just run py.test Signed-off-by: Alfredo Deza --- diff --git a/ceph-pr-commits/build/build b/ceph-pr-commits/build/build index 8213bfc5..af17ee3c 100644 --- a/ceph-pr-commits/build/build +++ b/ceph-pr-commits/build/build @@ -1,60 +1,9 @@ -#!/usr/bin/env python -from subprocess import Popen, PIPE -import os +#!/bin/bash -target_branch = os.getenv('ghprbTargetBranch', 'master') -source_branch = os.getenv('ghprbSourceBranch', 'HEAD') +# the following two methods exist in scripts/build_utils.sh +pkgs=( "pytest" ) +install_python_packages "pkgs[@]" -command = ['git', 'log', '--no-merges', '%s..%s' % (target_branch, source_branch)] - -process = Popen( - command, - stdout=PIPE, - stderr=PIPE, - close_fds=True -) - -returncode = process.wait() - -stdout = process.stdout.read() -stderr = process.stderr.read() - - -def produce_junit(**kw): - time = kw.get('time', 0) - tests = kw.get('tests', []) - failures = kw.get('failures', []) - total_tests = len(tests) or 1 - total_failures = len(failures) - template = """ - - - """.format(total_failures=total_failures, total_tests=total_tests) - path = os.path.join(os.getenv("$WORKSPACE", ""), 'report.xml') - print template - with open(path, 'w') as junit_file: - junit_file.write(template) - - -def extract_sha(lines): - trim = lines.split() - for i in trim: - if i and 'commit' not in i: - return i - -# git log output goes to stdout so process that -tests = [] -failures = [] -for chunk in stdout.split('\n\ncommit'): # we are interested in every commit chunk - if not chunk: - continue - tests.append(1) - if not 'Signed-off-by:' in chunk: - sha = extract_sha(chunk) - failures.append(sha) - -produce_junit(tests=tests, failures=failures) - -if failures: - raise SystemExit('A commit is missing "Signed-off-by". sha: %s' % sha) +cd "$WORKSPACE/ceph-build/ceph-pr-commits/build" +$VENV/py.test -v --junit="$WORKSPACE/report.xml"