Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.buildout
Commits
b1b8ccd3
Commit
b1b8ccd3
authored
Feb 21, 2013
by
Reinout van Rees
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test, but I cannot get it sys.exit to work correctly
parent
8c13789c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
0 deletions
+83
-0
src/zc/buildout/update.txt
src/zc/buildout/update.txt
+83
-0
No files found.
src/zc/buildout/update.txt
View file @
b1b8ccd3
...
@@ -234,3 +234,86 @@ directory:
...
@@ -234,3 +234,86 @@ directory:
<BLANKLINE>
<BLANKLINE>
if __name__ == '__main__':
if __name__ == '__main__':
sys.exit(zc.buildout.buildout.main())
sys.exit(zc.buildout.buildout.main())
When buildout restarts and the restarted buildout exits with an error code,
the original buildout that called the second buildout also exits with that
error code. Otherwise build scripts can erroneously detect a succesful
buildout run even if it failed.
Make a recipe that fails:
>>> mkdir(sample_buildout, 'failrecipe')
>>> write(sample_buildout, 'failrecipe', 'failrecipe.py',
... """
... import pkg_resources
... import sys
... print_ = lambda *a: sys.stdout.write(' '.join(map(str, a))+'\\n')
...
... class Recipe:
...
... def __init__(self, buildout, name, options):
... sys.exit('recipe sys-exits')
...
... def install(self):
... pass
...
... update = install
... """)
>>> write(sample_buildout, 'failrecipe', 'setup.py',
... """
... from setuptools import setup
...
... setup(
... name = "failrecipe",
... entry_points = {'zc.buildout': ['default = failrecipe:Recipe']},
... )
... """)
Let's downgrade again, triggering a restart. And use the failing recipe that
gives us a sys.exit:
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... find-links = %(new_releases)s
... index = %(new_releases)s
... parts = fail
... develop = failrecipe
...
... [versions]
... zc.buildout = < 99
... distribute = < 99
...
... [fail]
... recipe = failrecipe
... """ % dict(new_releases=new_releases))
Mock the sys.exit:
>>> import sys
>>> orig_exit = sys.exit
>>> def sys_exit(code):
... if code == 'Second exit':
... print_('Exiting with an error')
... else:
... print('Sys.exit with error %s' % code)
... #raise SystemExit(code)
>>> sys.exit = sys_exit
Run the buildout:
>>> print_(system(buildout), end='')
Upgraded:
zc.buildout version 1.4.4;
distribute version 0.6;
restarting.
Generated script '/sample-buildout/bin/buildout'.
Develop: '/sample-buildout/failrecipe'
sys.exit occurred. Exit code: recipe sys-exits
Restore sys.exit:
>>> sys.exit = orig_exit
>>> print_("We are still alive")
We are still alive
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment