diff --git a/ansible_mitogen/target.py b/ansible_mitogen/target.py index 40e5c57b..652b5adc 100644 --- a/ansible_mitogen/target.py +++ b/ansible_mitogen/target.py @@ -93,7 +93,7 @@ MAKE_TEMP_FAILED_MSG = ( u"were mounted on 'noexec' filesystems.\n" u"\n" u"The following paths were tried:\n" - u" %(namelist)s\n" + u" %(paths)s\n" u"\n" u"Please check '-vvv' output for a log of individual path errors." ) diff --git a/docs/changelog.rst b/docs/changelog.rst index a10ac883..84b24cd0 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -27,6 +27,10 @@ Fixes * `#557 `_: fix a crash when running on machines with high CPU counts. +* `#575 `_: fix a crash when + rendering an error message to indicate no usable temporary directories could + be found. + * `#570 `_: the ``firewalld`` module internally caches a dbus name that changes across ``firewalld`` restarts, causing a failure if the service is restarted between ``firewalld`` module invocations. @@ -37,7 +41,8 @@ Thanks! Mitogen would not be possible without the support of users. A huge thanks for bug reports, testing, features and fixes in this release contributed by -`Orion Poplawski `_, and +`Orion Poplawski `_, +`Thibaut Barrère `_, and `@Moumoutaru `_. diff --git a/tests/ansible/tests/target_test.py b/tests/ansible/tests/target_test.py index 7d6c0b46..6bdc949b 100644 --- a/tests/ansible/tests/target_test.py +++ b/tests/ansible/tests/target_test.py @@ -15,14 +15,47 @@ LOGGER_NAME = ansible_mitogen.target.LOG.name class NamedTemporaryDirectory(object): + def __init__(self, **kwargs): + self.kwargs = kwargs + def __enter__(self): - self.path = tempfile.mkdtemp() + self.path = tempfile.mkdtemp(**self.kwargs) return self.path def __exit__(self, _1, _2, _3): subprocess.check_call(['rm', '-rf', self.path]) +class FindGoodTempDirTest(testlib.TestCase): + func = staticmethod(ansible_mitogen.target.find_good_temp_dir) + + def test_expands_usernames(self): + with NamedTemporaryDirectory( + prefix='.ansible_mitogen_test', + dir=os.environ['HOME'] + ) as tmpdir: + path = self.func(['~']) + self.assertTrue(path.startswith(os.environ['HOME'])) + + def test_expands_vars(self): + with NamedTemporaryDirectory( + prefix='.ansible_mitogen_test', + dir=os.environ['HOME'] + ) as tmpdir: + os.environ['somevar'] = 'xyz' + path = self.func([tmpdir + '/$somevar']) + self.assertTrue(path.startswith('%s/%s' % (tmpdir, 'xyz'))) + + @mock.patch('ansible_mitogen.target.is_good_temp_dir') + def test_no_good_candidate(self, is_good_temp_dir): + is_good_temp_dir.return_value = False + e = self.assertRaises(IOError, + lambda: self.func([]) + ) + self.assertTrue(str(e).startswith('Unable to find a useable')) + + + class ApplyModeSpecTest(unittest2.TestCase): func = staticmethod(ansible_mitogen.target.apply_mode_spec)