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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
slapos.buildout
Commits
9b2a7d72
Commit
9b2a7d72
authored
Mar 27, 2021
by
Jürgen Gmach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve warning message when a section contains unused options.
This fixes #483
parent
b7c3849d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
21 deletions
+44
-21
news/483.feature
news/483.feature
+1
-0
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+5
-2
src/zc/buildout/tests/allowhosts.txt
src/zc/buildout/tests/allowhosts.txt
+2
-1
src/zc/buildout/tests/extends-cache.txt
src/zc/buildout/tests/extends-cache.txt
+28
-14
src/zc/buildout/tests/test_all.py
src/zc/buildout/tests/test_all.py
+6
-3
src/zc/buildout/tests/update.txt
src/zc/buildout/tests/update.txt
+2
-1
No files found.
news/483.feature
0 → 100644
View file @
9b2a7d72
Improve
warning
message
when
a
section contains unused options. (#483)
\ No newline at end of file
src/zc/buildout/buildout.py
View file @
9b2a7d72
...
@@ -2010,8 +2010,11 @@ def _check_for_unused_options_in_section(buildout, section):
...
@@ -2010,8 +2010,11 @@ def _check_for_unused_options_in_section(buildout, section):
unused
=
[
option
for
option
in
sorted
(
options
.
_raw
)
unused
=
[
option
for
option
in
sorted
(
options
.
_raw
)
if
option
not
in
options
.
_data
]
if
option
not
in
options
.
_data
]
if
unused
:
if
unused
:
buildout
.
_logger
.
warning
(
"Unused options for %s: %s."
buildout
.
_logger
.
warning
(
%
(
section
,
' '
.
join
(
map
(
repr
,
unused
)))
"Section `%s` contains unused option(s): %s.
\
n
"
"This may be an indication for either a typo in the option's name "
"or a bug in the used recipe."
%
(
section
,
' '
.
join
(
map
(
repr
,
unused
)))
)
)
_usage
=
"""
\
_usage
=
"""
\
...
...
src/zc/buildout/tests/allowhosts.txt
View file @
9b2a7d72
...
@@ -114,7 +114,8 @@ https://bugs.launchpad.net/zc.buildout/+bug/239212::
...
@@ -114,7 +114,8 @@ https://bugs.launchpad.net/zc.buildout/+bug/239212::
... ''')
... ''')
>>> print_('XX'); print_(system(buildout), end='') # doctest: +ELLIPSIS
>>> print_('XX'); print_(system(buildout), end='') # doctest: +ELLIPSIS
X...
X...
Unused options for buildout: 'foo'.
Section `buildout` contains unused option(s): 'foo'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
Installing python...
Installing python...
Generated interpreter '/sample-buildout/bin/python'.
Generated interpreter '/sample-buildout/bin/python'.
...
...
src/zc/buildout/tests/extends-cache.txt
View file @
9b2a7d72
...
@@ -49,7 +49,8 @@ Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
...
@@ -49,7 +49,8 @@ Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
Trying the same online, we can:
Trying the same online, we can:
>>> print_(system(buildout))
>>> print_(system(buildout))
Unused options for buildout: 'foo'.
Section `buildout` contains unused option(s): 'foo'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
As long as we haven't said anything about caching downloaded configuration,
As long as we haven't said anything about caching downloaded configuration,
nothing gets cached. Offline mode will still cause the buildout to fail:
nothing gets cached. Offline mode will still cause the buildout to fail:
...
@@ -74,7 +75,8 @@ being a hash of the complete URL):
...
@@ -74,7 +75,8 @@ being a hash of the complete URL):
... """ % server_url)
... """ % server_url)
>>> print_(system(buildout))
>>> print_(system(buildout))
Unused options for buildout: 'foo'.
Section `buildout` contains unused option(s): 'foo'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
>>> cache = join(sample_buildout, 'cache')
>>> cache = join(sample_buildout, 'cache')
>>> ls(cache)
>>> ls(cache)
...
@@ -89,7 +91,8 @@ foo = bar
...
@@ -89,7 +91,8 @@ foo = bar
We can now run buildout offline as it will read base.cfg from the cache:
We can now run buildout offline as it will read base.cfg from the cache:
>>> print_(system(buildout + ' -o'))
>>> print_(system(buildout + ' -o'))
Unused options for buildout: 'foo'.
Section `buildout` contains unused option(s): 'foo'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
The cache is being used purely as a fall-back in case we are offline or don't
The cache is being used purely as a fall-back in case we are offline or don't
have access to a configuration file to be downloaded. As long as we are
have access to a configuration file to be downloaded. As long as we are
...
@@ -105,23 +108,27 @@ base.cfg from the cache:
...
@@ -105,23 +108,27 @@ base.cfg from the cache:
... """)
... """)
>>> print_(system(buildout + ' -o'))
>>> print_(system(buildout + ' -o'))
Unused options for buildout: 'foo'.
Section `buildout` contains unused option(s): 'foo'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
.. verify same behavior for install-from-cache:
.. verify same behavior for install-from-cache:
>>> print_(system(buildout + ' install-from-cache=true download-cache=.'))
>>> print_(system(buildout + ' install-from-cache=true download-cache=.'))
Unused options for buildout: 'foo'.
Section `buildout` contains unused option(s): 'foo'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
In online mode, buildout will download and use the modified version:
In online mode, buildout will download and use the modified version:
>>> print_(system(buildout))
>>> print_(system(buildout))
Unused options for buildout: 'bar'.
Section `buildout` contains unused option(s): 'bar'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
Trying offline mode again, the new version will be used as it has been put in
Trying offline mode again, the new version will be used as it has been put in
the cache now:
the cache now:
>>> print_(system(buildout + ' -o'))
>>> print_(system(buildout + ' -o'))
Unused options for buildout: 'bar'.
Section `buildout` contains unused option(s): 'bar'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
Clean up:
Clean up:
...
@@ -212,7 +219,8 @@ Buildout will now assemble its configuration from all of these 6 files,
...
@@ -212,7 +219,8 @@ Buildout will now assemble its configuration from all of these 6 files,
defaults first. The online resources end up in the respective extends caches:
defaults first. The online resources end up in the respective extends caches:
>>> print_(system(buildout))
>>> print_(system(buildout))
Unused options for buildout: 'foo'.
Section `buildout` contains unused option(s): 'foo'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
>>> ls('user-cache')
>>> ls('user-cache')
- 10e772cf422123ef6c64ae770f555740
- 10e772cf422123ef6c64ae770f555740
...
@@ -258,7 +266,8 @@ Let's rewrite the config files, clean out the caches and re-run buildout:
...
@@ -258,7 +266,8 @@ Let's rewrite the config files, clean out the caches and re-run buildout:
>>> remove('cache', os.listdir('cache')[0])
>>> remove('cache', os.listdir('cache')[0])
>>> print_(system(buildout))
>>> print_(system(buildout))
Unused options for buildout: 'foo'.
Section `buildout` contains unused option(s): 'foo'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
>>> ls('user-cache')
>>> ls('user-cache')
- 0548bad6002359532de37385bb532e26
- 0548bad6002359532de37385bb532e26
...
@@ -336,7 +345,8 @@ Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
...
@@ -336,7 +345,8 @@ Error: Couldn't download 'http://localhost/base.cfg' in offline mode.
... offline = true
... offline = true
... """ % server_url)
... """ % server_url)
>>> print_(system(buildout))
>>> print_(system(buildout))
Unused options for buildout: 'foo'.
Section `buildout` contains unused option(s): 'foo'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
The ``install-from-cache`` option is treated accordingly:
The ``install-from-cache`` option is treated accordingly:
...
@@ -429,7 +439,8 @@ A change to ``base.cfg`` is picked up on the next buildout run:
...
@@ -429,7 +439,8 @@ A change to ``base.cfg`` is picked up on the next buildout run:
... foo = bar
... foo = bar
... """)
... """)
>>> print_(system(buildout + " -n"))
>>> print_(system(buildout + " -n"))
Unused options for buildout: 'foo'.
Section `buildout` contains unused option(s): 'foo'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
>>> cat('cache', os.listdir(cache)[0])
>>> cat('cache', os.listdir(cache)[0])
[buildout]
[buildout]
parts =
parts =
...
@@ -443,7 +454,8 @@ already present in the extends cache will not be updated:
...
@@ -443,7 +454,8 @@ already present in the extends cache will not be updated:
... parts =
... parts =
... """)
... """)
>>> print_(system(buildout + " -N"))
>>> print_(system(buildout + " -N"))
Unused options for buildout: 'foo'.
Section `buildout` contains unused option(s): 'foo'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
>>> cat('cache', os.listdir(cache)[0])
>>> cat('cache', os.listdir(cache)[0])
[buildout]
[buildout]
parts =
parts =
...
@@ -472,7 +484,8 @@ used:
...
@@ -472,7 +484,8 @@ used:
... extends = %sbaseA.cfg %sbaseB.cfg
... extends = %sbaseA.cfg %sbaseB.cfg
... """ % (server_url, server_url))
... """ % (server_url, server_url))
>>> print_(system(buildout + " -n"))
>>> print_(system(buildout + " -n"))
Unused options for buildout: 'bar' 'foo'.
Section `buildout` contains unused option(s): 'bar' 'foo'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
(XXX We patch download utility's API to produce readable output for the test;
(XXX We patch download utility's API to produce readable output for the test;
a better solution would re-use the logging already done by the utility.)
a better solution would re-use the logging already done by the utility.)
...
@@ -489,7 +502,8 @@ The URL http://localhost/baseA.cfg was downloaded.
...
@@ -489,7 +502,8 @@ The URL http://localhost/baseA.cfg was downloaded.
The URL http://localhost/base.cfg was downloaded.
The URL http://localhost/base.cfg was downloaded.
The URL http://localhost/baseB.cfg was downloaded.
The URL http://localhost/baseB.cfg was downloaded.
Not upgrading because not running a local buildout command.
Not upgrading because not running a local buildout command.
Unused options for buildout: 'bar' 'foo'.
Section `buildout` contains unused option(s): 'bar' 'foo'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
>>> zc.buildout.download.Download.download = old_download
>>> zc.buildout.download.Download.download = old_download
...
...
src/zc/buildout/tests/test_all.py
View file @
9b2a7d72
...
@@ -822,7 +822,8 @@ def bug_92891_bootstrap_crashes_with_egg_recipe_in_buildout_section():
...
@@ -822,7 +822,8 @@ def bug_92891_bootstrap_crashes_with_egg_recipe_in_buildout_section():
Generated script '/sample-bootstrap/bin/buildout'.
Generated script '/sample-bootstrap/bin/buildout'.
>>> print_(system(os.path.join('bin', 'buildout')), end='')
>>> print_(system(os.path.join('bin', 'buildout')), end='')
Unused options for buildout: 'scripts' 'eggs'.
Section `buildout` contains unused option(s): 'eggs' 'scripts'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
"""
"""
...
@@ -1659,9 +1660,11 @@ def whine_about_unused_options():
...
@@ -1659,9 +1660,11 @@ def whine_about_unused_options():
>>> print_(system(buildout), end='')
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/.'
Develop: '/sample-buildout/.'
Unused options for buildout: 'a'.
Section `buildout` contains unused option(s): 'a'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
Installing foo.
Installing foo.
Unused options for foo: 'z'.
Section `foo` contains unused option(s): 'z'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
'''
'''
def
abnormal_exit
():
def
abnormal_exit
():
...
...
src/zc/buildout/tests/update.txt
View file @
9b2a7d72
...
@@ -196,7 +196,8 @@ directory:
...
@@ -196,7 +196,8 @@ directory:
Restarting.
Restarting.
Generated script '/sample-buildout/bin/buildout'.
Generated script '/sample-buildout/bin/buildout'.
Develop: '/sample-buildout/showversions'
Develop: '/sample-buildout/showversions'
Unused options for buildout: 'relative-paths'.
Section `buildout` contains unused option(s): 'relative-paths'.
This may be an indication for either a typo in the option's name or a bug in the used recipe.
Updating show-versions.
Updating show-versions.
zc.buildout 99.99
zc.buildout 99.99
...
...
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