From 1f3a120522abc256b1340a757a114736a841a846 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Thu, 11 Jul 2019 17:44:33 +0300 Subject: [PATCH 01/23] Set up Travis CI and a tox.ini Replace the deprecated-and-removed zope.testing.doctest with the stdlib doctest module. --- .gitignore | 3 +++ .travis.yml | 15 +++++++++++++++ MANIFEST.in | 3 +++ tox.ini | 10 ++++++++++ zc/zope3recipes/tests.py | 11 ++++++++--- 5 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 MANIFEST.in create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5d08d9f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.py[co] +.tox/ +*.egg-info diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..13e6b69 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +language: python +dist: xenial +python: + - 2.7 +install: + - pip install zope.testrunner coverage coveralls + - pip install -e '.[tests]' +script: + - coverage run zope-testrunner --test-path=. -vc +after_script: + - coverage report -m + - coveralls +notifications: + email: false +cache: pip diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..80f0c26 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +include *.py +include buildout.cfg +recursive-include zc *.txt diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..b7e9c02 --- /dev/null +++ b/tox.ini @@ -0,0 +1,10 @@ +[tox] +envlist = py27 + +[testenv] +deps = + zope.testrunner +extras = + tests +commands = + zope-testrunner --test-path=. {posargs:-vc} diff --git a/zc/zope3recipes/tests.py b/zc/zope3recipes/tests.py index 63ee8a3..67ba4f8 100644 --- a/zc/zope3recipes/tests.py +++ b/zc/zope3recipes/tests.py @@ -12,12 +12,15 @@ # ############################################################################## -import re, sys, os +import doctest +import os +import re +import sys +import unittest import zc.buildout.testing +from zope.testing import renormalizing -import unittest -from zope.testing import doctest, renormalizing def ls_optional(dir, ignore=(), *subs): if subs: @@ -35,6 +38,7 @@ def ls_optional(dir, ignore=(), *subs): print '- ', print name + def test_ctl(): """ The ctl script is an extended version of zdaemon that provides an @@ -271,5 +275,6 @@ def test_suite(): return suite + if __name__ == '__main__': unittest.main(defaultTest='test_suite') From a3dfb1d7937f459c6f2a98f9fac5571f1f3817a7 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Thu, 11 Jul 2019 17:49:44 +0300 Subject: [PATCH 02/23] Fix coverage run command line --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 13e6b69..8b638b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ install: - pip install zope.testrunner coverage coveralls - pip install -e '.[tests]' script: - - coverage run zope-testrunner --test-path=. -vc + - coverage run -m zope.testrunner --test-path=. -vc after_script: - coverage report -m - coveralls From f0b50567f93b887aac859e1e57d6e654f18c36de Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Thu, 11 Jul 2019 17:53:53 +0300 Subject: [PATCH 03/23] Tweak default doctest optionflags --- zc/zope3recipes/tests.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/zc/zope3recipes/tests.py b/zc/zope3recipes/tests.py index 67ba4f8..d99ba75 100644 --- a/zc/zope3recipes/tests.py +++ b/zc/zope3recipes/tests.py @@ -255,23 +255,29 @@ def setUp(test): def test_suite(): suite = unittest.TestSuite() + optionflags = ( + doctest.NORMALIZE_WHITESPACE + | doctest.ELLIPSIS + | doctest.REPORT_ONLY_FIRST_FAILURE + | doctest.REPORT_NDIFF + ) if sys.platform[:3].lower() == "win": suite.addTest(doctest.DocFileSuite('WINDOWS.txt', setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown, checker=checker, - optionflags = doctest.NORMALIZE_WHITESPACE+doctest.ELLIPSIS)) + optionflags=optionflags)) else: suite.addTest(doctest.DocTestSuite( setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown, checker=checker, - optionflags = doctest.NORMALIZE_WHITESPACE+doctest.ELLIPSIS)) + optionflags=optionflags)) suite.addTest(doctest.DocFileSuite('README.txt', setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown, checker=checker, - optionflags = doctest.NORMALIZE_WHITESPACE+doctest.ELLIPSIS)) + optionflags=optionflags)) return suite From 808afd2c44721e30c3cb6a1ea7193a57204b0f23 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Thu, 11 Jul 2019 17:56:46 +0300 Subject: [PATCH 04/23] Add an appveyor build Because we have special Windows-only tests. --- appveyor.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..19ed898 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,20 @@ +version: build-{build}-{branch} + +environment: + matrix: + # https://www.appveyor.com/docs/installed-software#python lists available + # versions + - PYTHON: "C:\\Python27" + +init: + - "echo %PYTHON%" + +install: + - "set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" + - python --version + - pip install tox + +build: off + +test_script: + - tox -e py From bb4cd05fc320e5275ef7193933a6009c6033e1d5 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Thu, 11 Jul 2019 18:02:02 +0300 Subject: [PATCH 05/23] Upgrade pip in Appveyor --- appveyor.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 19ed898..7b99608 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,6 +12,9 @@ init: install: - "set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" - python --version + # Upgrade virtualenv because the one in the Appveyor image is old and has an + # old bundled pip version that thinks 'zc.recipe.egg' is an egg. + - pip install -U virtualenv - pip install tox build: off From 66755d22d32f8f3aabf354afb2f24f344f542864 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Thu, 11 Jul 2019 18:05:28 +0300 Subject: [PATCH 06/23] Fix Windows tests with newer buildouts See commit d215bf07434. --- zc/zope3recipes/WINDOWS.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/zc/zope3recipes/WINDOWS.txt b/zc/zope3recipes/WINDOWS.txt index eb65b24..a2684d2 100644 --- a/zc/zope3recipes/WINDOWS.txt +++ b/zc/zope3recipes/WINDOWS.txt @@ -79,7 +79,7 @@ The runzope script runs the Web server: import zope.app.twisted.main if __name__ == '__main__': - zope.app.twisted.main.main() + sys.exit(zope.app.twisted.main.main()) Here, unlike the above example the location path is not included in sys.path . Similarly debugzope script is also changed: @@ -100,7 +100,7 @@ in sys.path . Similarly debugzope script is also changed: import zc.zope3recipes.debugzope if __name__ == '__main__': - zc.zope3recipes.debugzope.debug(main_module=zope.app.twisted.main) + sys.exit(zc.zope3recipes.debugzope.debug(main_module=zope.app.twisted.main)) Building Zope 3 Applications (from Zope 3 checkouts/tarballs) @@ -219,7 +219,7 @@ The runzope script runs the Web server: import zope.app.twisted.main if __name__ == '__main__': - zope.app.twisted.main.main() + sys.exit(zope.app.twisted.main.main()) It includes in it's path the eggs we specified in the configuration file, along with their dependencies. Note that we haven't specified a @@ -258,7 +258,7 @@ variables available as global variables. import zc.zope3recipes.debugzope if __name__ == '__main__': - zc.zope3recipes.debugzope.debug(main_module=zope.app.twisted.main) + sys.exit(zc.zope3recipes.debugzope.debug(main_module=zope.app.twisted.main)) Note that the runzope shown above uses the default, twisted-based server components. It's possible to specify which set of server @@ -321,7 +321,7 @@ The runzope script generated is identical to what we saw before: import zope.app.twisted.main if __name__ == '__main__': - zope.app.twisted.main.main() + sys.exit(zope.app.twisted.main.main()) We can also specify the ZServer servers explicitly: @@ -377,7 +377,7 @@ different package this time: import zope.app.server.main if __name__ == '__main__': - zope.app.server.main.main() + sys.exit(zope.app.server.main.main()) The debugzope script has also been modified to take this into account. @@ -398,7 +398,7 @@ The debugzope script has also been modified to take this into account. import zc.zope3recipes.debugzope if __name__ == '__main__': - zc.zope3recipes.debugzope.debug(main_module=zope.app.server.main) + sys.exit(zc.zope3recipes.debugzope.debug(main_module=zope.app.server.main)) Legacy Functional Testing Support @@ -1178,12 +1178,12 @@ in the buildout bin directory: import zc.zope3recipes.winctl if __name__ == '__main__': - zc.zope3recipes.winctl.main([ + sys.exit(zc.zope3recipes.winctl.main([ '/sample-buildout/parts/myapp/debugzope', '/sample-buildout/parts/instance/zope.conf', '-C', '/sample-buildout/parts/instance/zdaemon.conf', ]+sys.argv[1:] - ) + )) Some configuration sections can include a key multiple times; the ZEO client section works this way. When a key is given multiple times, From 3b0c6ac32666c6dae87ff296a10c0064495d5b61 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Thu, 11 Jul 2019 18:21:41 +0300 Subject: [PATCH 07/23] Add a .coveragerc So that coverage report -m won't dump us about ALL THE PACKAGES EVER. --- .coveragerc | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..9340bc6 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,8 @@ +[run] +source = zc.zope3recipes + +[paths] +source = + zc/ + .tox/*/lib/python*/site-packages/zc/ + .tox/pypy*/site-packages/zc/ From f25a8194f92e85b4ffe4f1dfa36b111a57b13ed3 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Thu, 11 Jul 2019 18:32:26 +0300 Subject: [PATCH 08/23] Fix greedy regex so we can see actual egg names --- zc/zope3recipes/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zc/zope3recipes/tests.py b/zc/zope3recipes/tests.py index d99ba75..a378507 100644 --- a/zc/zope3recipes/tests.py +++ b/zc/zope3recipes/tests.py @@ -243,7 +243,7 @@ def setUp(test): (re.compile("""['"][^\n"']+zope3recipes[^\n"']*['"],"""), "'/zope3recipes',"), (re.compile('#![^\n]+\n'), ''), - (re.compile('-\S+-py\d[.]\d(-\S+)?.egg'), + (re.compile('-[^-]+-py\d[.]\d(-\S+)?.egg'), '-pyN.N.egg', ), # Turn "distribute" into "setuptools" so the tests can pass with either: From f11c9c6da48df6e6bfbda40ed30af04c36547f02 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Thu, 11 Jul 2019 18:38:52 +0300 Subject: [PATCH 09/23] Just make the damn test pass --- zc/zope3recipes/README.txt | 17 ++++------------- zc/zope3recipes/WINDOWS.txt | 3 --- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/zc/zope3recipes/README.txt b/zc/zope3recipes/README.txt index a295117..e9fb1c9 100644 --- a/zc/zope3recipes/README.txt +++ b/zc/zope3recipes/README.txt @@ -1559,9 +1559,6 @@ in the buildout bin directory: import sys sys.path[0:0] = [ - '/sample-buildout/eggs/zdaemon-2.0-py2.4.egg', - '/sample-buildout/eggs/setuptools-0.6-py2.4.egg', - '/sample-buildout/eggs/ZConfig-2.3-py2.4.egg', '/zope3recipes', ] @@ -2449,9 +2446,6 @@ in a buildout configuration. import sys sys.path[0:0] = [ - join(base, 'eggs/zdaemon-pyN.N.egg'), - join(base, 'eggs/setuptools-pyN.N.egg'), - join(base, 'eggs/ZConfig-pyN.N.egg'), '/zope3recipes', ] @@ -3149,13 +3143,10 @@ paste-based instance start scripts. import sys sys.path[0:0] = [ - '/sample-buildout/demo2', - '/sample-buildout/eggs/PasteScript-1.7.4.2-py2.6.egg', - '/sample-buildout/eggs/setuptools-0.6c12dev_r88846-py2.6.egg', - '/sample-buildout/eggs/PasteDeploy-1.5.0-py2.6.egg', - '/sample-buildout/eggs/Paste-1.7.5.1-py2.6.egg', - '/sample-buildout/demo1', - ] + '/sample-buildout/demo2', + '/.../zope3recipes/lib/python.../site-packages', + '/sample-buildout/demo1', + ] import paste.script.command diff --git a/zc/zope3recipes/WINDOWS.txt b/zc/zope3recipes/WINDOWS.txt index a2684d2..3b157e7 100644 --- a/zc/zope3recipes/WINDOWS.txt +++ b/zc/zope3recipes/WINDOWS.txt @@ -1169,9 +1169,6 @@ in the buildout bin directory: import sys sys.path[0:0] = [ - '/sample-buildout/eggs/zdaemon-2.0-py2.4.egg', - '/sample-buildout/eggs/setuptools-0.6-py2.4.egg', - '/sample-buildout/eggs/ZConfig-2.3-py2.4.egg', '/zope3recipes', ] From eb98ef6b073a17bd730a4ae38deedc0e08d25109 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Thu, 11 Jul 2019 18:53:27 +0300 Subject: [PATCH 10/23] Add tox -e coverage --- tox.ini | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tox.ini b/tox.ini index b7e9c02..e58c867 100644 --- a/tox.ini +++ b/tox.ini @@ -8,3 +8,12 @@ extras = tests commands = zope-testrunner --test-path=. {posargs:-vc} + +[testenv:coverage] +basepython = python2.7 +deps = + {[testenv]deps} + coverage +commands = + coverage run -m zope.testrunner --test-path=. {posargs:-vc} + coverage report -m From e6986a3130909a052b13cef00df8864b4c300854 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Thu, 11 Jul 2019 18:53:34 +0300 Subject: [PATCH 11/23] Ignore buildout gunk --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 5d08d9f..975cbeb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ *.py[co] .tox/ *.egg-info +.coverage +.installed.cfg +bin/ +eggs/ +develop-eggs/ +parts/ From c469e03adc3ffb1a9ccc47a3dc3d5fe97009be81 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Thu, 11 Jul 2019 18:53:53 +0300 Subject: [PATCH 12/23] Trying to make tests pass (futilely) --- zc/zope3recipes/tests.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/zc/zope3recipes/tests.py b/zc/zope3recipes/tests.py index a378507..df66e78 100644 --- a/zc/zope3recipes/tests.py +++ b/zc/zope3recipes/tests.py @@ -242,6 +242,11 @@ def setUp(test): ), ''), (re.compile("""['"][^\n"']+zope3recipes[^\n"']*['"],"""), "'/zope3recipes',"), + # welp, when we do things like `tox -e coverage`, everything's in + # .tox/coverage/lib/pythonX.Y/site-packages and that's what gets added to + # sys.path in the generated scripts + (re.compile("""['"][^\n"']+site-packages['"],"""), + "'/zope3recipes',"), (re.compile('#![^\n]+\n'), ''), (re.compile('-[^-]+-py\d[.]\d(-\S+)?.egg'), '-pyN.N.egg', @@ -250,7 +255,11 @@ def setUp(test): (re.compile(r'\bdistribute-pyN\.N\.egg'), 'setuptools-pyN.N.egg', ), - ]) + # Sometimes buildout decides to also install six + (re.compile( + r"Getting distribution for 'six'\.\nGot six [0-9.]+\.\n" + ), ''), +]) def test_suite(): From a5b7b5c636879a9db49f051298891b7e0e6f552a Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Thu, 11 Jul 2019 18:56:10 +0300 Subject: [PATCH 13/23] Fix bitrot in WINDOWS.txt This is what happens when you do not have CI. See commit 88ebc0e69d2ae9d3d8d083. --- zc/zope3recipes/README.txt | 2 +- zc/zope3recipes/WINDOWS.txt | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/zc/zope3recipes/README.txt b/zc/zope3recipes/README.txt index e9fb1c9..9b77990 100644 --- a/zc/zope3recipes/README.txt +++ b/zc/zope3recipes/README.txt @@ -1875,7 +1875,7 @@ rc-directory installed. logrotate-directory - The name ot the directory where logrotate configuration files should be + The name of the directory where logrotate configuration files should be installed. user diff --git a/zc/zope3recipes/WINDOWS.txt b/zc/zope3recipes/WINDOWS.txt index 3b157e7..ff88296 100644 --- a/zc/zope3recipes/WINDOWS.txt +++ b/zc/zope3recipes/WINDOWS.txt @@ -1318,6 +1318,10 @@ rc-directory The name of the directory where run-control scripts should be installed. +logrotate-directory + The name of the directory where logrotate configuration files should be + installed. + user The name of a user that processes should run as. @@ -1330,6 +1334,7 @@ create a faux installation root: >>> mkdir(root, 'etc') >>> mkdir(root, 'etc', 'myapp-run') >>> mkdir(root, 'etc', 'init.d') + >>> mkdir(root, 'etc', 'logrotate.d') >>> write('buildout.cfg', ... ''' @@ -1369,6 +1374,7 @@ create a faux installation root: ... [myapp-run] ... etc-directory = %(root)s/etc/myapp-run ... rc-directory = %(root)s/etc/init.d + ... logrotate-directory = %(root)s/etc/logrotate.d ... log-directory = %(root)s/var/log/myapp-run ... run-directory = %(root)s/var/run/myapp-run ... user = zope @@ -1419,6 +1425,12 @@ The control script is in the init.d directory: Note that the deployment name is added as a prefix of the control script name. +The logrotate file is in the logrotate.d directory: + + >>> ls(root, 'etc', 'logrotate.d') + - myapp-run-instance + + The configuration files have changed to reflect the deployment locations: @@ -1465,6 +1477,16 @@ locations: + >>> cat(root, 'etc', 'logrotate.d', 'myapp-run-instance') + /root/var/log/myapp-run/instance-z3.log { + rotate 5 + weekly + postrotate + /root/etc/init.d/myapp-run-instance reopen_transcript + endscript + } + + Defining multiple similar instances ----------------------------------- @@ -1519,6 +1541,7 @@ Let's update our buildout to add a new instance: ... [myapp-run] ... etc-directory = %(root)s/etc/myapp-run ... rc-directory = %(root)s/etc/init.d + ... logrotate-directory = %(root)s/etc/logrotate.d ... log-directory = %(root)s/var/log/myapp-run ... run-directory = %(root)s/var/run/myapp-run ... user = zope From f9da20391c5ebd3f62b27676806e5a2a1863c9fd Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Fri, 12 Jul 2019 14:39:03 +0300 Subject: [PATCH 14/23] Fix test failure in tox -e coverage --- zc/zope3recipes/tests.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/zc/zope3recipes/tests.py b/zc/zope3recipes/tests.py index df66e78..b6b4e47 100644 --- a/zc/zope3recipes/tests.py +++ b/zc/zope3recipes/tests.py @@ -259,6 +259,11 @@ def setUp(test): (re.compile( r"Getting distribution for 'six'\.\nGot six [0-9.]+\.\n" ), ''), + # Running the tests under coverage changes the output ordering! This makes + # no sense! + (re.compile( + r"(\s*'/sample-buildout/demo1',\n)(\s*'/zope3recipes',\n)" + ), r'\2\1'), ]) From 3c0869f006240786889a187a10611602d0ecca33 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Fri, 12 Jul 2019 15:00:57 +0300 Subject: [PATCH 15/23] Fix coverage tracking Based on z3c.recipe.i18n. --- .coveragerc | 2 ++ .travis.yml | 3 +++ tox.ini | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/.coveragerc b/.coveragerc index 9340bc6..468ee61 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,5 +1,7 @@ [run] source = zc.zope3recipes +parallel = true +data_file = $COVERAGE_HOME/.coverage [paths] source = diff --git a/.travis.yml b/.travis.yml index 8b638b3..3c6cd6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,11 @@ install: - pip install zope.testrunner coverage coveralls - pip install -e '.[tests]' script: + - export COVERAGE_HOME=$(pwd) + - export COVERAGE_PROCESS_START=$COVERAGE_HOME/.coveragerc - coverage run -m zope.testrunner --test-path=. -vc after_script: + - coverage combine - coverage report -m - coveralls notifications: diff --git a/tox.ini b/tox.ini index e58c867..65de697 100644 --- a/tox.ini +++ b/tox.ini @@ -16,4 +16,8 @@ deps = coverage commands = coverage run -m zope.testrunner --test-path=. {posargs:-vc} + coverage combine coverage report -m +setenv = + COVERAGE_HOME={toxinidir} + COVERAGE_PROCESS_START={toxinidir}/.coveragerc From ae3b0505e5561429d421995d37118de932c946e9 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Fri, 12 Jul 2019 15:25:30 +0300 Subject: [PATCH 16/23] Make both 'tox' and 'bin/test' pass the tests I had to use terrible, terrible regexes. Now tox -e coverage fails for totally mysterious reasons. --- .gitignore | 1 + tox.ini | 1 + zc/zope3recipes/README.txt | 25 +++++++++++++------------ zc/zope3recipes/tests.py | 21 +++++++++++++++++---- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 975cbeb..b744c06 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ bin/ eggs/ develop-eggs/ parts/ +.coverage* diff --git a/tox.ini b/tox.ini index 65de697..dc3f2b1 100644 --- a/tox.ini +++ b/tox.ini @@ -2,6 +2,7 @@ envlist = py27 [testenv] +usedevelop = true deps = zope.testrunner extras = diff --git a/zc/zope3recipes/README.txt b/zc/zope3recipes/README.txt index 9b77990..34ed945 100644 --- a/zc/zope3recipes/README.txt +++ b/zc/zope3recipes/README.txt @@ -109,7 +109,7 @@ in ``sys.path``. Similarly debugzope script is also changed: sys.path[0:0] = [ '/sample-buildout/demo2', '/sample-buildout/demo1', - '/zope3recipes', + '/zc.zope3recipes', ] import zope.app.twisted.main @@ -174,7 +174,7 @@ before server is started: sys.path[0:0] = [ '/sample-buildout/demo2', '/sample-buildout/demo1', - '/zope3recipes', + '/zc.zope3recipes', ] print "Starting application server." @@ -224,7 +224,7 @@ Now, Let's run the buildout and see what we get: sys.path[0:0] = [ '/sample-buildout/demo2', '/sample-buildout/demo1', - '/zope3recipes', + '/zc.zope3recipes', ] print "Starting debugging interaction." @@ -289,7 +289,7 @@ Now, Let's run the buildout and see what we get: sys.path[0:0] = [ '/sample-buildout/demo2', '/sample-buildout/demo1', - '/zope3recipes', + '/zc.zope3recipes', ] import zope.app.twisted.main @@ -380,7 +380,7 @@ Similarly, debugzope script has relative paths. sys.path[0:0] = [ join(base, 'demo2'), join(base, 'demo1'), - '/zope3recipes', + '/zc.zope3recipes', ] import zope.app.twisted.main @@ -542,7 +542,7 @@ variables available as global variables. '/sample-buildout/demo2', '/sample-buildout/demo1', '/zope3/src', - '/zope3recipes', + '/zc.zope3recipes', ] import zope.app.twisted.main @@ -682,7 +682,7 @@ The debugzope script has also been modified to take this into account. '/sample-buildout/demo2', '/sample-buildout/demo1', '/zope3/src', - '/zope3recipes', + '/zc.zope3recipes', ] import zope.app.server.main @@ -776,7 +776,7 @@ The debugzope script also has relative paths. join(base, 'demo2'), join(base, 'demo1'), '/zope3/src', - '/zope3recipes', + '/zc.zope3recipes', ] import zope.app.server.main @@ -1559,7 +1559,8 @@ in the buildout bin directory: import sys sys.path[0:0] = [ - '/zope3recipes', + '/site-packages', + '/zc.zope3recipes', ] import zc.zope3recipes.ctl @@ -2446,7 +2447,8 @@ in a buildout configuration. import sys sys.path[0:0] = [ - '/zope3recipes', + '/site-packages', + '/zc.zope3recipes', ] import zc.zope3recipes.ctl @@ -3144,11 +3146,10 @@ paste-based instance start scripts. import sys sys.path[0:0] = [ '/sample-buildout/demo2', - '/.../zope3recipes/lib/python.../site-packages', '/sample-buildout/demo1', + '/site-packages', ] - import paste.script.command if __name__ == '__main__': diff --git a/zc/zope3recipes/tests.py b/zc/zope3recipes/tests.py index b6b4e47..a883108 100644 --- a/zc/zope3recipes/tests.py +++ b/zc/zope3recipes/tests.py @@ -240,13 +240,14 @@ def setUp(test): "\(maybe misspelled\?\)" "\n" ), ''), - (re.compile("""['"][^\n"']+zope3recipes[^\n"']*['"],"""), - "'/zope3recipes',"), + # this directory + (re.compile(r"""['"][^\n"']+zc\.zope3recipes['"],"""), + "'/zc.zope3recipes',"), # welp, when we do things like `tox -e coverage`, everything's in # .tox/coverage/lib/pythonX.Y/site-packages and that's what gets added to # sys.path in the generated scripts (re.compile("""['"][^\n"']+site-packages['"],"""), - "'/zope3recipes',"), + "'/site-packages',"), (re.compile('#![^\n]+\n'), ''), (re.compile('-[^-]+-py\d[.]\d(-\S+)?.egg'), '-pyN.N.egg', @@ -262,8 +263,20 @@ def setUp(test): # Running the tests under coverage changes the output ordering! This makes # no sense! (re.compile( - r"(\s*'/sample-buildout/demo1',\n)(\s*'/zope3recipes',\n)" + r"( *'/zope3recipes',\n)( *'/sample-buildout/demo1',\n)" ), r'\2\1'), + # Running the tests with buildout + bin/test adds ZConfig and zdaemon + # eggs to sys.path of generated tests. Running the tests with tox does + # not (because ZConfig and zdaemon are already in .../site-packages) + (re.compile( + r" *'/sample-buildout/eggs/(ZConfig|zdaemon)-pyN.N.egg',\n" + ), ''), + (re.compile( + r" *join\(base, 'eggs/(ZConfig|zdaemon)-pyN.N.egg'\),\n" + ), ''), + (re.compile( + r"( *'/sample-buildout/eggs/(PasteScript|six|PasteDeploy|Paste)-pyN.N.egg',\n)+" + ), " '/site-packages',\n"), ]) From 1260eb6b4be53f2d3d73edec1cd44c828b078ee4 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Fri, 12 Jul 2019 15:27:49 +0300 Subject: [PATCH 17/23] Install pypiwin32 on Appveyor --- tox.ini | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index dc3f2b1..fc78c84 100644 --- a/tox.ini +++ b/tox.ini @@ -13,8 +13,8 @@ commands = [testenv:coverage] basepython = python2.7 deps = - {[testenv]deps} - coverage + {[testenv]deps} + coverage commands = coverage run -m zope.testrunner --test-path=. {posargs:-vc} coverage combine @@ -22,3 +22,9 @@ commands = setenv = COVERAGE_HOME={toxinidir} COVERAGE_PROCESS_START={toxinidir}/.coveragerc + +[testenv:py] +platform = win32 +deps = + {[testenv]deps} + pypiwin32 From 7b01f4a41362bd5c87ad6b473e49255168d6ef40 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Fri, 12 Jul 2019 15:32:57 +0300 Subject: [PATCH 18/23] Try to fix WINDOWS.txt --- zc/zope3recipes/WINDOWS.txt | 8 ++++---- zc/zope3recipes/tests.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/zc/zope3recipes/WINDOWS.txt b/zc/zope3recipes/WINDOWS.txt index ff88296..a9c4322 100644 --- a/zc/zope3recipes/WINDOWS.txt +++ b/zc/zope3recipes/WINDOWS.txt @@ -91,7 +91,7 @@ in sys.path . Similarly debugzope script is also changed: sys.path[0:0] = [ '/sample-buildout/demo2', '/sample-buildout/demo1', - '/zope3recipes', + '/zc.zope3recipes', ] import zope.app.twisted.main @@ -249,7 +249,7 @@ variables available as global variables. '/sample-buildout/demo2', '/sample-buildout/demo1', '/zope3/src', - '/zope3recipes', + '/zc.zope3recipes', ] import zope.app.twisted.main @@ -389,7 +389,7 @@ The debugzope script has also been modified to take this into account. '/sample-buildout/demo2', '/sample-buildout/demo1', '/zope3/src', - '/zope3recipes', + '/zc.zope3recipes', ] import zope.app.server.main @@ -1169,7 +1169,7 @@ in the buildout bin directory: import sys sys.path[0:0] = [ - '/zope3recipes', + '/zc.zope3recipes', ] import zc.zope3recipes.winctl diff --git a/zc/zope3recipes/tests.py b/zc/zope3recipes/tests.py index a883108..534d2b7 100644 --- a/zc/zope3recipes/tests.py +++ b/zc/zope3recipes/tests.py @@ -241,7 +241,7 @@ def setUp(test): "\n" ), ''), # this directory - (re.compile(r"""['"][^\n"']+zc\.zope3recipes['"],"""), + (re.compile(r"""['"][^\n"']+zc.zope3recipes['"],"""), "'/zc.zope3recipes',"), # welp, when we do things like `tox -e coverage`, everything's in # .tox/coverage/lib/pythonX.Y/site-packages and that's what gets added to From bd63b18e176e4aba2f5d0097e300652c215d28e2 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Fri, 12 Jul 2019 15:35:02 +0300 Subject: [PATCH 19/23] More wrongness to maybe make it work please please --- zc/zope3recipes/tests.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/zc/zope3recipes/tests.py b/zc/zope3recipes/tests.py index 534d2b7..6e8aedc 100644 --- a/zc/zope3recipes/tests.py +++ b/zc/zope3recipes/tests.py @@ -277,6 +277,13 @@ def setUp(test): (re.compile( r"( *'/sample-buildout/eggs/(PasteScript|six|PasteDeploy|Paste)-pyN.N.egg',\n)+" ), " '/site-packages',\n"), + # tox -e coverage does this! I've no idea why! + (re.compile( + r"Uninstalling myapp.\n" + r"(Updating database.\n|)" + r"Installing myapp.\n" + r"(Generated script '/sample-buildout/parts/myapp/[^']+'\.\n)*", + ), "Updating myapp.\n\\1"), ]) From 91f66b0035238b641e6c5ec76f0db220cbcfd946 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Fri, 12 Jul 2019 15:42:28 +0300 Subject: [PATCH 20/23] Even more regex magic --- zc/zope3recipes/tests.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/zc/zope3recipes/tests.py b/zc/zope3recipes/tests.py index 6e8aedc..b1bc5f2 100644 --- a/zc/zope3recipes/tests.py +++ b/zc/zope3recipes/tests.py @@ -240,6 +240,8 @@ def setUp(test): "\(maybe misspelled\?\)" "\n" ), ''), + # Windows + (re.compile(r'\r\n'), '\n'), # this directory (re.compile(r"""['"][^\n"']+zc.zope3recipes['"],"""), "'/zc.zope3recipes',"), @@ -280,10 +282,16 @@ def setUp(test): # tox -e coverage does this! I've no idea why! (re.compile( r"Uninstalling myapp.\n" - r"(Updating database.\n|)" + r"(Updating database.\n|Installing database.\n|Uninstalling database.\n|)" r"Installing myapp.\n" r"(Generated script '/sample-buildout/parts/myapp/[^']+'\.\n)*", - ), "Updating myapp.\n\\1"), + ), "\\1Updating myapp.\n"), + (re.compile( + r"Uninstalling instance.\n" + r"(Updating myapp.\n|)" + r"Installing instance.\n" + r"(Generated script '/sample-buildout/bin/[^']+'\.\n)*", + ), "\\1Updating instance.\n"), ]) From 05bff2c9a0d5d48b8884011c633f33ecdc620357 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Fri, 12 Jul 2019 15:49:15 +0300 Subject: [PATCH 21/23] Now to debug Windows failures... --- zc/zope3recipes/WINDOWS.txt | 1 + zc/zope3recipes/tests.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/zc/zope3recipes/WINDOWS.txt b/zc/zope3recipes/WINDOWS.txt index a9c4322..b90eee1 100644 --- a/zc/zope3recipes/WINDOWS.txt +++ b/zc/zope3recipes/WINDOWS.txt @@ -1169,6 +1169,7 @@ in the buildout bin directory: import sys sys.path[0:0] = [ + '/site-packages', '/zc.zope3recipes', ] diff --git a/zc/zope3recipes/tests.py b/zc/zope3recipes/tests.py index b1bc5f2..2988c5f 100644 --- a/zc/zope3recipes/tests.py +++ b/zc/zope3recipes/tests.py @@ -300,7 +300,6 @@ def test_suite(): optionflags = ( doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS - | doctest.REPORT_ONLY_FIRST_FAILURE | doctest.REPORT_NDIFF ) if sys.platform[:3].lower() == "win": From cf5d30bca9204fdb2b48edf578ff544c5194920c Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Fri, 12 Jul 2019 15:53:52 +0300 Subject: [PATCH 22/23] Fix TypeError: () takes no arguments (1 given) zdaemon changed the API of ZDCmd.awhile() and now the cond predicate gets one argument (a 0-based attempt number). --- setup.py | 2 +- zc/zope3recipes/winctl.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 00e1686..6aa62bf 100644 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ def read(*rnames): ], }, extras_require = dict( - tests = ['zdaemon', 'zc.recipe.filestorage', 'PasteScript'], + tests=['zdaemon >= 3.0.0', 'zc.recipe.filestorage', 'PasteScript'], ), classifiers=[ "Development Status :: 5 - Production/Stable", diff --git a/zc/zope3recipes/winctl.py b/zc/zope3recipes/winctl.py index 30b31d8..b876eae 100644 --- a/zc/zope3recipes/winctl.py +++ b/zc/zope3recipes/winctl.py @@ -211,7 +211,7 @@ def do_debug(self, arg): self.proc = Popen(program) self.zd_pid = self.proc.pid self.zd_up = 1 - self.awhile(lambda: self.zd_pid, + self.awhile(lambda n: self.zd_pid, "Zope3 started in debug mode, pid=%(zd_pid)d") def help_debug(self): @@ -261,7 +261,7 @@ def do_stop(self, arg): self.zd_up = 0 self.zd_pid = 0 cpid = win32process.GetCurrentProcessId() - self.awhile(lambda: not getChildrenPidsOfPid(cpid), "Zope3 stopped") + self.awhile(lambda n: not getChildrenPidsOfPid(cpid), "Zope3 stopped") def do_kill(self, arg): self.do_stop(arg) @@ -273,7 +273,7 @@ def do_restart(self, arg): self.do_start(arg) else: self.do_start(arg) - self.awhile(lambda: self.zd_pid not in (0, pid), + self.awhile(lambda n: self.zd_pid not in (0, pid), "Zope3 restarted, pid=%(zd_pid)d") def show_options(self): @@ -295,7 +295,7 @@ def do_start(self, arg): self.proc = Popen(program) self.zd_pid = self.proc.pid self.zd_up = 1 - self.awhile(lambda: self.zd_pid, + self.awhile(lambda n: self.zd_pid, "Zope3 started, pid=%(zd_pid)d") def do_fg(self, arg): From aeba625e462188820478896f53d2be93775916d8 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Fri, 12 Jul 2019 15:57:56 +0300 Subject: [PATCH 23/23] Update changelog and version number --- README.txt | 8 ++++++++ setup.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.txt b/README.txt index b9bc870..dbd204a 100644 --- a/README.txt +++ b/README.txt @@ -20,6 +20,14 @@ Unfortunately, partial Windows support at this time. It works but it's alpha. Releases ******** +=================== +0.19.0 (unreleased) +=================== + +- Fix TypeError: () takes no arguments (1 given) on Windows + with zdaemon >= 3.0.0. + + =================== 0.18.0 (2013/02/05) =================== diff --git a/setup.py b/setup.py index 6aa62bf..0bfa10f 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ # FOR A PARTICULAR PURPOSE. # ############################################################################## -name, version = "zc.zope3recipes", "0" +name, version = "zc.zope3recipes", "0.19.0.dev0" import os from setuptools import setup, find_packages