From 9e0b7ee6292afaf0568a7795bed46b99e9a7e7e4 Mon Sep 17 00:00:00 2001 From: Jeroen Hoekx Date: Tue, 17 Apr 2012 11:14:58 +0200 Subject: [PATCH 1/2] template: expand path if metadata is in user home. --- library/template | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/template b/library/template index 0b13422d5a..31a2095e50 100755 --- a/library/template +++ b/library/template @@ -47,7 +47,8 @@ for x in items: source = params['src'] dest = params['dest'] -metadata = params.get('metadata', '/etc/ansible/setup') +metadata = params.get('metadata', '/etc/ansible/setup') +metadata = os.path.expanduser(metadata) module_vars = params.get('vars') # raise an error if there is no template metadata From 6f09b41eb5851cab2c0b8d8e91998977405e98b4 Mon Sep 17 00:00:00 2001 From: Jeroen Hoekx Date: Tue, 17 Apr 2012 13:30:30 +0200 Subject: [PATCH 2/2] Don't test modules that aren't present. Also account for path difference in sleep in different distributions. --- test/TestRunner.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/TestRunner.py b/test/TestRunner.py index d61466040f..fc890125a5 100644 --- a/test/TestRunner.py +++ b/test/TestRunner.py @@ -14,6 +14,15 @@ try: except: import simplejson as json +from nose.plugins.skip import SkipTest + +def get_binary(name): + for directory in os.environ["PATH"].split(os.pathsep): + path = os.path.join(directory, name) + if os.path.isfile(path) and os.access(path, os.X_OK): + return path + return None + class TestRunner(unittest.TestCase): def setUp(self): @@ -73,6 +82,8 @@ class TestRunner(unittest.TestCase): assert "ping" in result def test_facter(self): + if not get_binary("facter"): + raise SkipTest result = self._run('facter',[]) assert "hostname" in result @@ -172,7 +183,7 @@ class TestRunner(unittest.TestCase): def test_async(self): # test async launch and job status # of any particular module - result = self._run('command', [ "/bin/sleep", "3" ], background=20) + result = self._run('command', [ get_binary("sleep"), "3" ], background=20) assert 'ansible_job_id' in result assert 'started' in result jid = result['ansible_job_id'] @@ -197,6 +208,8 @@ class TestRunner(unittest.TestCase): assert open(input).read() == open(output).read() def test_yum(self): + if not get_binary("yum"): + raise SkipTest result = self._run('yum', [ "list=repos" ]) assert 'failed' not in result