Ticket #1342: improved-package-tests.darcs.patch

File improved-package-tests.darcs.patch, 7.9 KB (added by zooko, at 2011-01-30T15:24:33Z)
Line 
11 patch for repository zooko@dev.allmydata.org:/home/darcs/tahoe-lafs/trunk:
2
3Sun Jan 30 07:38:29 MST 2011  zooko@zooko.com
4  * setup: rename test-with-fake-pkg.py to test-dont-use-too-old-dep.py, fix it to work with "python setup.py test"
5  Copy the technique that David-Sarah used in test-with-fake-dists.py to test a package named "fakedependency" instead of "pycryptopp". This allows us to run "python setup.py test" instead of executing trial directly, which means the test doesn't spuriously fail if some of tahoe-lafs's deps are missing on the buildslave, and the test doesn't skip if pycryptopp is already installed on the buildslave.
6   * rename test-with-fake-dists.py to test-dont-install-newer-dep-when-you-already-have-sufficiently-new-one.py.
7
8New patches:
9
10[setup: rename test-with-fake-pkg.py to test-dont-use-too-old-dep.py, fix it to work with "python setup.py test"
11zooko@zooko.com**20110130143829
12 Ignore-this: bba1e6aab80cd0b7ed9303d09ff28b2b
13 Copy the technique that David-Sarah used in test-with-fake-dists.py to test a package named "fakedependency" instead of "pycryptopp". This allows us to run "python setup.py test" instead of executing trial directly, which means the test doesn't spuriously fail if some of tahoe-lafs's deps are missing on the buildslave, and the test doesn't skip if pycryptopp is already installed on the buildslave.
14  * rename test-with-fake-dists.py to test-dont-install-newer-dep-when-you-already-have-sufficiently-new-one.py.
15] {
16move ./misc/build_helpers/test-with-fake-dists.py ./misc/build_helpers/test-dont-install-newer-dep-when-you-already-have-sufficiently-new-one.py
17move ./misc/build_helpers/test-with-fake-pkg.py ./misc/build_helpers/test-dont-use-too-old-dep.py
18hunk ./misc/build_helpers/test-dont-install-newer-dep-when-you-already-have-sufficiently-new-one.py 15
19     #
20     #   python setup.py --fakedependency -v test -s buildtest.test_build_with_fake_dist
21     #
22-    # which imports fakedependency and passes if fakedependency.__version__ == '1.0.0'.
23+    # which requires "fakedependency >= 1.0.0", imports fakedependency
24+    # and passes if fakedependency.__version__ == '1.0.0'.
25     #
26     # The goal is to turn red if the build system tries to build the
27     # source dist when it could have used the binary dist.
28hunk ./misc/build_helpers/test-dont-use-too-old-dep.py 3
29 #!/usr/bin/env python
30 
31-# We put a fake "pycryptopp-0.5.13" package on the PYTHONPATH so that
32-# the build system thinks pycryptopp-0.5.13 is already installed. Then
33-# we execute 'setup.py trial'. If the build system is too naive/greedy
34-# about finding dependencies, it will latch onto the
35-# "pycryptopp-0.5.13" and then will be unable to satisfy the
36-# requirement (from _auto_deps.py) for pycryptopp >= 0.5.20 (or
37-# pycryptopp >= 0.5.14, depending on machine architecture). This is
38-# currently happening on trunk, see #1190. So with trunk, running
39-# test-with-fake-pkg.py shows a failure, but with the ticket1190
40-# branch, test-with-fake-pkg.py succeeds.
41+import StringIO, os, platform, shutil, subprocess, sys, tarfile, zipfile
42+import pkg_resources
43 
44hunk ./misc/build_helpers/test-dont-use-too-old-dep.py 6
45-import os, subprocess, sys
46+def test():
47+    # We put a "fakedependency-0.9.9.egg" package and a
48+    # "fakedependency-1.0.0.tar.gz" into a directory, but the former is
49+    # booby-trapped so it will raise an exception when you try to import it.
50+    #
51+    # Then we run
52+    #
53+    #   python setup.py --fakedependency -v test -s buildtest.test_build_with_fake_dist
54+    #
55+    # which requires "fakedependency >= 1.0.0", imports fakedependency
56+    # and passes if fakedependency.__version__ == '1.0.0'.
57+    #
58+    # The goal is to turn red if the build system tries to use the
59+    # source dist when it could have used the binary dist.
60+    #
61+    # Note that for this test to make sense, Tahoe-LAFS needs to be asking
62+    # for a version of fakedependency which can be satisfied by 1.0.0.
63+    # The --fakedependency option to setup.py arranges that.
64 
65hunk ./misc/build_helpers/test-dont-use-too-old-dep.py 25
66-fakepkgdir = 'misc/build_helpers/fakepkgs'
67-fakepkgname = "pycryptopp"
68-fakepkgversion = "0.5.13"
69-testsuite = "allmydata.test.test_backupdb"
70+    fake_distdir = 'tahoe-deps'
71+    fake_distname = "fakedependency"
72+    fake_sdistversion = "1.0.0"
73+    fake_bdistversion = "0.9.9"
74 
75hunk ./misc/build_helpers/test-dont-use-too-old-dep.py 30
76-pkgdirname = os.path.join(os.getcwd(), fakepkgdir, '%s-%s.egg' % (fakepkgname, fakepkgversion))
77+    bdist_init = "raise Exception('Aha I caught you trying to import me. I am a fakedependency 0.9.9 package and you should not be satisfied with something < 1.0.0.')"
78+    sdist_setup = "import distutils.core\ndistutils.core.setup(name='fakedependency', version='1.0.0', packages=['fakedependency'])"
79+    sdist_init = "__version__ = '%s'" % (fake_sdistversion,)
80 
81hunk ./misc/build_helpers/test-dont-use-too-old-dep.py 34
82-try:
83-    os.makedirs(pkgdirname)
84-except OSError:
85-    # probably already exists
86-    pass
87+    testsuite = "buildtest.test_build_with_fake_dist"
88 
89hunk ./misc/build_helpers/test-dont-use-too-old-dep.py 36
90-os.environ['PYTHONPATH']=pkgdirname+os.pathsep+os.environ.get('PYTHONPATH','')
91-sys.exit(subprocess.call([sys.executable, 'setup.py', 'trial', '-s', testsuite], env=os.environ))
92+    dist_dirname = os.path.join(os.getcwd(), fake_distdir)
93+
94+    try:
95+        os.makedirs(dist_dirname)
96+    except OSError:
97+        # probably already exists
98+        pass
99+
100+    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()))
101+    try:
102+        bdist_egg = zipfile.ZipFile(bdist_egg_name, 'w')
103+        bdist_egg.writestr('fakedependency/__init__.py', bdist_init)
104+        bdist_egg.close()
105+
106+        sdist_name = os.path.join(dist_dirname, '%s-%s.tar' % (fake_distname, fake_sdistversion))
107+        sdist = tarfile.open(sdist_name, 'w:gz')
108+        sdist.errorlevel = 2
109+        tarinfo = tarfile.TarInfo('setup.py')
110+        tarinfo.errorlevel = 2
111+        tarinfo.size = len(sdist_setup)
112+        sdist.addfile(tarinfo, StringIO.StringIO(sdist_setup))
113+        tarinfo = tarfile.TarInfo('fakedependency/__init__.py')
114+        tarinfo.errorlevel = 2
115+        tarinfo.size = len(sdist_init)
116+        sdist.addfile(tarinfo, StringIO.StringIO(sdist_init))
117+        sdist.close()
118+
119+        sys.exit(subprocess.call([sys.executable, "setup.py", "--fakedependency", "-v", "test", "-s", testsuite],
120+                                 env=os.environ))
121+    finally:
122+        os.remove(bdist_egg_name)
123+        os.remove(sdist_name)
124+        cleanup()
125+
126+def cleanup():
127+    egg_info = os.path.join('src', 'allmydata_tahoe.egg-info')
128+    bin_tahoe = os.path.join('bin', 'tahoe')
129+    bin_tahoe_pyscript = os.path.join('bin', 'tahoe.pyscript')
130+
131+    if os.path.exists('build'):
132+        shutil.rmtree('build')
133+    if os.path.exists('support'):
134+        shutil.rmtree('support')
135+    if os.path.exists(egg_info):
136+        shutil.rmtree(egg_info)
137+    if os.path.exists(bin_tahoe):
138+        os.remove(bin_tahoe)
139+    if os.path.exists(bin_tahoe_pyscript):
140+        os.remove(bin_tahoe_pyscript)
141+
142+if __name__ == '__main__':
143+    test()
144}
145
146Context:
147
148[setup: adjust tests to use the new interface of check_requirement which has a 3-tuples instead of a 2-tuple
149zooko@zooko.com**20110128141546
150 Ignore-this: d4c6197c78c156e7ae3c3444d81db9ed
151 fixes #1339
152]
153[src/allmydata/__init__.py: fix #1339, give an indication in the --version[-and-path] output of when the imported setuptools is distribute, and use a separate element in _vers_and_locs_list tuples for information other than the package name and location. This also changes slightly how the sqlite version is reported.
154david-sarah@jacaranda.org**20110128054150
155 Ignore-this: 47e8d2afed1f8114681e9094dc93276
156]
157[TAG allmydata-tahoe-1.8.2b1
158warner@lothar.com**20110126061431]
159Patch bundle hash:
1600c710d424ff704d6dfbaf7ec48cdee357e3710d1