Make include_path deterministic
In code the `include_path` and defaults like `.` added to a set as opposed a list. Resulting in that the order is machine/hashcode specific and that user cannot make i.e. `.` to have higher precedence than the fallbacks. Without doing this you have to use absolute or unique paths which might not always be possible in your .ini file. Change-Id: I9721b168a67e799dfc19d7df951b99c0749b52e0
This commit is contained in:
parent
a3aef64855
commit
4b5d0b405a
|
@ -201,12 +201,12 @@ class LocalLoader(OrderedConstructor, LocalAnchorLoader):
|
|||
def __init__(self, *args, **kwargs):
|
||||
# make sure to pop off any local settings before passing to
|
||||
# the parent constructor as any unknown args may cause errors.
|
||||
self.search_path = set()
|
||||
self.search_path = list()
|
||||
if 'search_path' in kwargs:
|
||||
for p in kwargs.pop('search_path'):
|
||||
logger.debug("Adding '{0}' to search path for include tags"
|
||||
.format(p))
|
||||
self.search_path.add(os.path.normpath(p))
|
||||
self.search_path.append(os.path.normpath(p))
|
||||
|
||||
if 'escape_callback' in kwargs:
|
||||
self._escape = kwargs.pop('escape_callback')
|
||||
|
@ -228,15 +228,15 @@ class LocalLoader(OrderedConstructor, LocalAnchorLoader):
|
|||
type(self).construct_yaml_map)
|
||||
|
||||
if hasattr(self.stream, 'name'):
|
||||
self.search_path.add(os.path.normpath(
|
||||
self.search_path.append(os.path.normpath(
|
||||
os.path.dirname(self.stream.name)))
|
||||
self.search_path.add(os.path.normpath(os.path.curdir))
|
||||
self.search_path.append(os.path.normpath(os.path.curdir))
|
||||
|
||||
def _find_file(self, filename):
|
||||
for dirname in self.search_path:
|
||||
candidate = os.path.expanduser(os.path.join(dirname, filename))
|
||||
if os.path.isfile(candidate):
|
||||
logger.info("Including file '{0}' from path '{0}'"
|
||||
logger.info("Including file '{0}' from path '{1}'"
|
||||
.format(filename, dirname))
|
||||
return candidate
|
||||
return filename
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
[job_builder]
|
||||
include_path=tests/yamlparser/fixtures:tests/yamlparser/fixtures/other_include_path
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<description>from current dir<!-- Managed by Jenkins Job Builder --></description>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
<properties/>
|
||||
<scm class="hudson.scm.NullSCM"/>
|
||||
<builders/>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
- project:
|
||||
name: include_path
|
||||
jobs:
|
||||
- 'include_path'
|
||||
|
||||
- job-template:
|
||||
name: 'include_path'
|
||||
description: !include test.inc
|
|
@ -0,0 +1,5 @@
|
|||
[job_builder]
|
||||
include_path=tests/yamlparser/fixtures/other_include_path:tests/yamlparser/fixtures
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<description>from other include path<!-- Managed by Jenkins Job Builder --></description>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
<properties/>
|
||||
<scm class="hudson.scm.NullSCM"/>
|
||||
<builders/>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
- project:
|
||||
name: include_path
|
||||
jobs:
|
||||
- 'include_path'
|
||||
|
||||
- job-template:
|
||||
name: 'include_path'
|
||||
description: !include test.inc
|
|
@ -0,0 +1 @@
|
|||
from other include path
|
|
@ -0,0 +1 @@
|
|||
from current dir
|
Loading…
Reference in New Issue