diff --git a/lib/cdist/test/exec/remote.py b/lib/cdist/test/exec/remote.py index 92b68d06..1334e330 100644 --- a/lib/cdist/test/exec/remote.py +++ b/lib/cdist/test/exec/remote.py @@ -118,3 +118,16 @@ class RemoteTestCase(test.CdistTestCase): self.remote.create_directories() self.assertTrue(os.path.isdir(self.remote.base_path)) self.assertTrue(os.path.isdir(self.remote.conf_path)) + + def test_run_script_target_host_in_env(self): + handle, remote_exec_path = self.mkstemp(dir=self.temp_dir) + with os.fdopen(handle, 'w') as fd: + fd.writelines(["#!/bin/sh\n", "echo $__target_host"]) + os.chmod(remote_exec_path, 0o755) + remote_exec = remote_exec_path + remote_copy = "echo" + r = remote.Remote(self.target_host, self.base_path, remote_exec, remote_copy) + handle, script = self.mkstemp(dir=self.temp_dir) + with os.fdopen(handle, "w") as fd: + fd.writelines(["#!/bin/sh\n", "echo foobar"]) + self.assertEqual(r.run_script(script, return_output=True), "%s\n" % self.target_host)