mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-28 13:21:25 -07:00
Run integration tests from temporary directory.
ci_complete
This commit is contained in:
parent
18c35b69fb
commit
b834b29e43
7 changed files with 327 additions and 43 deletions
|
@ -754,6 +754,8 @@ class CommonConfig(object):
|
|||
if is_shippable():
|
||||
self.redact = True
|
||||
|
||||
self.cache = {}
|
||||
|
||||
|
||||
def docker_qualify_image(name):
|
||||
"""
|
||||
|
@ -765,6 +767,29 @@ def docker_qualify_image(name):
|
|||
return config.get('name', name)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def named_temporary_file(args, prefix, suffix, directory, content):
|
||||
"""
|
||||
:param args: CommonConfig
|
||||
:param prefix: str
|
||||
:param suffix: str
|
||||
:param directory: str
|
||||
:param content: str | bytes | unicode
|
||||
:rtype: str
|
||||
"""
|
||||
if not isinstance(content, bytes):
|
||||
content = content.encode('utf-8')
|
||||
|
||||
if args.explain:
|
||||
yield os.path.join(directory, '%stemp%s' % (prefix, suffix))
|
||||
else:
|
||||
with tempfile.NamedTemporaryFile(prefix=prefix, suffix=suffix, dir=directory) as tempfile_fd:
|
||||
tempfile_fd.write(content)
|
||||
tempfile_fd.flush()
|
||||
|
||||
yield tempfile_fd.name
|
||||
|
||||
|
||||
def parse_to_list_of_dict(pattern, value):
|
||||
"""
|
||||
:type pattern: str
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue