From c35a887e1a47b9e196be893feb62cf4efb0e3a51 Mon Sep 17 00:00:00 2001 From: Jeppe Klitgaard Date: Mon, 6 Apr 2015 00:53:23 +0200 Subject: [PATCH] Spruced up verify-manifest.py --- bin/verify-manifest.py | 40 +++++++++++++++++++--------------------- tox.ini | 1 + 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/bin/verify-manifest.py b/bin/verify-manifest.py index a395263..32385be 100644 --- a/bin/verify-manifest.py +++ b/bin/verify-manifest.py @@ -1,34 +1,32 @@ -import subprocess +""" +Exits with exit code 0 if manifest was verified. +""" + +from sh import check_manifest +from sh import ErrorReturnCode_1 import sys EXPECTED_OUTPUT = "lists of files in version control and sdist match" -def check_manifest(): +def verify_manifest(): """ - Returns a tuple containing ``(output, status)``. - - Status is: - ``True`` if ``output`` was as expected (no errors), - ``False`` otherwise. + Returns a ``str`` containing output from ``check-manifest``. """ - output = subprocess.check_output(["check-manifest"]).decode() - if EXPECTED_OUTPUT == output.strip(): - status = True - else: - status = False + try: + output = check_manifest().decode() + except ErrorReturnCode_1 as e: + output = e.stderr.decode() + e.stdout.decode() - return (output, status) + return output if __name__ == '__main__': - output, verified = check_manifest() + output = verify_manifest() - if not verified: - print("Check-manifest didn't match.") - print("OUTPUT: {}".format(output)) - print("EXPECTED_OUTPUT: {}".format(EXPECTED_OUTPUT)) - sys.exit(1) + print(output) + + if output == EXPECTED_OUTPUT: + sys.exit(0) else: - print("Manifest verified.") - sys.exit(0) + sys.exit(1) diff --git a/tox.ini b/tox.ini index 3c05964..be62c9a 100644 --- a/tox.ini +++ b/tox.ini @@ -70,6 +70,7 @@ commands = basepython = python3.4 deps = check-manifest + sh commands = python {toxinidir}/bin/verify-manifest.py \ No newline at end of file