mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-31 00:24:13 +00:00
Attempt to fix test-with-fake-dist build step.
This commit is contained in:
parent
a8739c39ab
commit
33786a6d55
@ -4,35 +4,28 @@ import StringIO, glob, os, platform, shutil, subprocess, sys, tarfile, zipfile
|
|||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
# We put a fake "pycryptopp-0.5.24.egg" package and a fake
|
# We put a "fakedependency-1.0.0.egg" package and a
|
||||||
# "pycryptopp-9.9.99.tar.gz" into a directory, but the latter is
|
# "fakedependency-9.9.99.tar.gz" into a directory, but the latter is
|
||||||
# booby-trapped so it will raise an exception when you try to build
|
# booby-trapped so it will raise an exception when you try to build it.
|
||||||
# it.
|
#
|
||||||
|
# Then we run
|
||||||
# Then we run "python setup.py test -s
|
#
|
||||||
# buildtest.test_with_fake_dist", which imports pycryptopp
|
# python --fakedependency setup.py -v test -s buildtest.test_with_fake_dist
|
||||||
# and passes if pycryptopp.__version__ == '0.5.24'.
|
#
|
||||||
|
# which imports fakedependency and passes if fakedependency.__version__ == '1.0.0'.
|
||||||
# (If building succeeded -- meaning that you didn't try to build the
|
#
|
||||||
# booby-trapped 9.9.99 -- but pycryptopp.__version__ != '0.5.24' then
|
|
||||||
# that means a different version of pycryptopp was already installed
|
|
||||||
# so neither of the two fake pycryptopp packages were needed. In that
|
|
||||||
# case this test should be treated as a "skip" -- the functionality
|
|
||||||
# under test can't be exercised on the current system.)
|
|
||||||
|
|
||||||
# The goal is to turn red if the build system tries to build the
|
# The goal is to turn red if the build system tries to build the
|
||||||
# source dist when it could have used the binary dist.
|
# source dist when it could have used the binary dist.
|
||||||
|
#
|
||||||
# (Note that for this test to make sense, tahoe-lafs needs to be
|
# Note that for this test to make sense, Tahoe-LAFS needs to be asking
|
||||||
# asking for a version of pycryptopp which can be satisfied by either
|
# for a version of fakedependency which can be satisfied by 1.0.0.
|
||||||
# 0.5.24 or 0.5.25. At the time of this writing it requires >= 0.5.20
|
# The --fakedependency option to setup.py arranges that.
|
||||||
# on x86 and >= 0.5.14 on other architectures.)
|
|
||||||
|
|
||||||
fake_distdir = 'tahoe-deps'
|
fake_distdir = 'tahoe-deps'
|
||||||
fake_distname = "pycryptopp"
|
fake_distname = "fakedependency"
|
||||||
fake_sdistversion = "9.9.99"
|
fake_sdistversion = "9.9.99"
|
||||||
fake_bdistversion = "0.5.24"
|
fake_bdistversion = "1.0.0"
|
||||||
sdist_setup = "raise Exception('Aha I caught you trying to build me. I am a fake pycryptopp 9.9.99 sdist and you should be satisfied with a bdist.')"
|
sdist_setup = "raise Exception('Aha I caught you trying to build me. I am a fakedependency 9.9.99 sdist and you should be satisfied with a bdist.')"
|
||||||
|
|
||||||
testsuite = "buildtest.test_build_with_fake_dist"
|
testsuite = "buildtest.test_build_with_fake_dist"
|
||||||
|
|
||||||
@ -47,29 +40,31 @@ def test():
|
|||||||
bdist_egg_name = os.path.join(dist_dirname, '%s-%s-py%s.%s-%s.egg' % (fake_distname, fake_bdistversion, platform.python_version_tuple()[0], platform.python_version_tuple()[1], pkg_resources.get_supported_platform()))
|
bdist_egg_name = os.path.join(dist_dirname, '%s-%s-py%s.%s-%s.egg' % (fake_distname, fake_bdistversion, platform.python_version_tuple()[0], platform.python_version_tuple()[1], pkg_resources.get_supported_platform()))
|
||||||
try:
|
try:
|
||||||
bdist_egg = zipfile.ZipFile(bdist_egg_name, 'w')
|
bdist_egg = zipfile.ZipFile(bdist_egg_name, 'w')
|
||||||
bdist_egg.writestr('pycryptopp/__init__.py', '__version__ = "%s"\n' % (fake_bdistversion,))
|
bdist_egg.writestr('fakedependency/__init__.py', '__version__ = "%s"\n' % (fake_bdistversion,))
|
||||||
bdist_egg.close()
|
bdist_egg.close()
|
||||||
|
|
||||||
sdist_name = os.path.join(dist_dirname, '%s-%s.tar' % (fake_distname, fake_sdistversion))
|
sdist_name = os.path.join(dist_dirname, '%s-%s.tar' % (fake_distname, fake_sdistversion))
|
||||||
sdist = tarfile.open(sdist_name, 'w:gz')
|
sdist = tarfile.open(sdist_name, 'w:gz')
|
||||||
sdist.errorlevel =2
|
sdist.errorlevel = 2
|
||||||
tarinfo = tarfile.TarInfo('setup.py')
|
tarinfo = tarfile.TarInfo('setup.py')
|
||||||
tarinfo.errorlevel =2
|
tarinfo.errorlevel = 2
|
||||||
tarinfo.size = len(sdist_setup)
|
tarinfo.size = len(sdist_setup)
|
||||||
sdist.addfile(tarinfo, StringIO.StringIO(sdist_setup))
|
sdist.addfile(tarinfo, StringIO.StringIO(sdist_setup))
|
||||||
sdist.close()
|
sdist.close()
|
||||||
|
|
||||||
sys.exit(subprocess.call([sys.executable, "setup.py", "-v", "test", "-s", testsuite], env=os.environ))
|
sys.exit(subprocess.call([sys.executable, "setup.py", "--fakedependency", "-v", "test", "-s", testsuite],
|
||||||
|
env=os.environ))
|
||||||
finally:
|
finally:
|
||||||
os.remove(bdist_egg_name)
|
os.remove(bdist_egg_name)
|
||||||
os.remove(sdist_name)
|
os.remove(sdist_name)
|
||||||
cleanup()
|
cleanup()
|
||||||
|
|
||||||
def cleanup():
|
def cleanup():
|
||||||
for path, subdnames, fnames in os.walk('.'):
|
shutil.rmtree('build')
|
||||||
for fdname in subdnames + fnames:
|
shutil.rmtree('support')
|
||||||
if fdname.startswith('pycryptopp-0.5.24'):
|
shutil.rmtree(os.path.join('src', 'allmydata_tahoe.egg-info'))
|
||||||
shutil.rmtree(os.path.join(path, fdname))
|
os.remove(os.path.join('bin', 'tahoe'))
|
||||||
|
os.remove(os.path.join('bin', 'tahoe.pyscript'))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
test()
|
test()
|
||||||
|
4
setup.py
4
setup.py
@ -63,6 +63,10 @@ adglobals = {}
|
|||||||
execfile('src/allmydata/_auto_deps.py', adglobals)
|
execfile('src/allmydata/_auto_deps.py', adglobals)
|
||||||
install_requires = adglobals['install_requires']
|
install_requires = adglobals['install_requires']
|
||||||
|
|
||||||
|
if len(sys.argv) > 1 and sys.argv[1] == '--fakedependency':
|
||||||
|
del sys.argv[1]
|
||||||
|
install_requires += ["fakedependency >= 1.0.0"]
|
||||||
|
|
||||||
__requires__ = install_requires[:]
|
__requires__ = install_requires[:]
|
||||||
if 'trial' in sys.argv or 'test' in sys.argv:
|
if 'trial' in sys.argv or 'test' in sys.argv:
|
||||||
if version is not None:
|
if version is not None:
|
||||||
|
@ -4,7 +4,5 @@ from twisted.trial import unittest
|
|||||||
|
|
||||||
class T(unittest.TestCase):
|
class T(unittest.TestCase):
|
||||||
def test_version(self):
|
def test_version(self):
|
||||||
import pycryptopp
|
import fakedependency
|
||||||
if pycryptopp.__version__ != '0.5.24':
|
self.failUnlessEqual(fakedependency.__version__, '1.0.0')
|
||||||
raise unittest.SkipTest("We can't tell if this worked because this system has a different version of pycryptopp already installed. See comment in misc/build_helpers/test-with-fake-dists.py for details.")
|
|
||||||
# If you tried to build 9.9.99 then you would have gotten an exception and stopped before you even ran this test, so I guess you succeeded!
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user