issue #554: don't rely on tmp_path autoremoval in test.

Ansible doesn't do this, so we shouldn't either.
pull/564/head
David Wilson 6 years ago
parent 7743e57ff3
commit f36b4b47bf

@ -19,22 +19,26 @@
#
- name: "Find regular temp path"
action_passthrough:
method: _make_tmp_path
mitogen_action_script:
script: |
path = self._make_tmp_path()
self._remove_tmp_path(path)
register: tmp_path
- name: "Find regular temp path (new task)"
action_passthrough:
method: _make_tmp_path
mitogen_action_script:
script: |
path = self._make_tmp_path()
self._remove_tmp_path(path)
register: tmp_path2
- name: "Find good temp path"
set_fact:
good_temp_path: "{{tmp_path.result|dirname}}"
good_temp_path: "{{tmp_path.path|dirname}}"
- name: "Find good temp path (new task)"
set_fact:
good_temp_path2: "{{tmp_path2.result|dirname}}"
good_temp_path2: "{{tmp_path2.path|dirname}}"
- name: "Verify common base path for both tasks"
assert:
@ -44,7 +48,7 @@
- name: "Verify different subdir for both tasks"
assert:
that:
- tmp_path.result != tmp_path2.result
- tmp_path.path != tmp_path2.path
#
# Verify subdirectory removal.
@ -52,12 +56,12 @@
- name: Stat temp path
stat:
path: "{{tmp_path.result}}"
path: "{{tmp_path.path}}"
register: stat1
- name: Stat temp path (new task)
stat:
path: "{{tmp_path2.result}}"
path: "{{tmp_path2.path}}"
register: stat2
- name: "Verify neither subdir exists any more"
@ -108,14 +112,17 @@
- name: "Find root temp path"
become: true
action_passthrough:
method: _make_tmp_path
mitogen_action_script:
script: |
path = self._make_tmp_path()
self._remove_tmp_path(path)
register: tmp_path_root
- name: "Verify root temp path differs from regular path"
assert:
that:
- tmp_path2.result != tmp_path_root.result
- tmp_path2.path != tmp_path_root.path
- tmp_path2.path|dirname != tmp_path_root.path|dirname
#
# readonly homedir

@ -16,12 +16,20 @@ def execute(s, gbls, lcls):
class ActionModule(ActionBase):
def run(self, tmp=None, task_vars=None):
super(ActionModule, self).run(tmp=tmp, task_vars=task_vars)
lcls = {
'self': self,
'result': {}
}
lcls = {}
# Capture keys to remove later, including any crap Python adds.
execute('pass', globals(), lcls)
lcls['self'] = self
# Old mitogen_action_script used explicit result dict.
lcls['result'] = lcls
pre_keys = list(lcls)
execute(self._task.args['script'], globals(), lcls)
return lcls['result']
for key in pre_keys:
del lcls[key]
return lcls
if __name__ == '__main__':

Loading…
Cancel
Save