commit 34be2ece71819ae005914317d9a492b755037d26 Author: Damian Johnson atagar@torproject.org Date: Mon Dec 5 15:41:24 2016 -0800
Test our source distribution matches the git contents
Having a hardcoded Manifest.in is error prone. Unfortunately we need to do it, so to avoid shooting ourselves in the foot we need a test. This checks that source distributions we generate match the contents of the git repository. --- test/integ/installation.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
diff --git a/test/integ/installation.py b/test/integ/installation.py index 189c26e..9e11c4d 100644 --- a/test/integ/installation.py +++ b/test/integ/installation.py @@ -2,6 +2,7 @@ import glob import os import shutil import sys +import tarfile import unittest
import stem @@ -10,6 +11,8 @@ import stem.util.system import test.runner import test.util
+INSTALL_MISMATCH_MSG = "Running 'python setup.py sdist' doesn't match our git contents in the following way. The manifest in our setup.py may need to be updated...\n\n" +
class TestInstallation(unittest.TestCase): # TODO: remove when dropping support for python 2.6 @@ -56,6 +59,51 @@ class TestInstallation(unittest.TestCase): return False
@test.runner.only_run_once + def test_sdist_matches_git(self): + """ + Check the source distribution tarball we make for releases matches the + contents of 'git archive'. This primarily is meant to test that our + MANIFEST.in is up to date. + """ + + if self.requires_installation(): + return + elif not stem.util.system.is_available('git'): + test.runner.skip(self, '(git unavailable)') + return + + original_cwd = os.getcwd() + dist_path = os.path.join(test.util.STEM_BASE, 'dist') + git_contents = [line.split()[-1] for line in stem.util.system.call('git ls-tree --full-tree -r HEAD')] + + try: + os.chdir(test.util.STEM_BASE) + stem.util.system.call(sys.executable + ' setup.py sdist') + + # tarball has a prefix 'stem-[verion]' directory so stipping that out + + dist_tar = tarfile.open(os.path.join(dist_path, 'stem-dry-run-%s.tar.gz' % stem.__version__)) + tar_contents = ['/'.join(info.name.split('/')[1:]) for info in dist_tar.getmembers() if info.isfile()] + finally: + if os.path.exists(dist_path): + shutil.rmtree(dist_path) + + os.chdir(original_cwd) + + issues = [] + + for path in git_contents: + if path not in tar_contents and path not in ['.gitignore']: + issues.append(' * %s is missing from our release tarball' % path) + + for path in tar_contents: + if path not in git_contents and path not in ['MANIFEST.in', 'PKG-INFO']: + issues.append(" * %s isn't expected in our release tarball" % path) + + if issues: + self.fail(INSTALL_MISMATCH_MSG + '\n'.join(issues)) + + @test.runner.only_run_once def test_installing_stem(self): """ Attempt to use the package we install.
tor-commits@lists.torproject.org