mirror of
https://github.com/samba-team/samba.git
synced 2025-02-28 01:58:17 +03:00
selftest.run: Factor out exported_envvars_str.
This commit is contained in:
parent
a6a8456646
commit
f26b40a925
@ -68,3 +68,12 @@ def expand_command_run(cmd, supports_loadfile, supports_idlist, subtests=None):
|
||||
"Running subtests requested, but command does not support "
|
||||
"this.")
|
||||
return (cmd, None)
|
||||
|
||||
|
||||
def exported_envvars_str(vars, names):
|
||||
out = ""
|
||||
for n in names:
|
||||
if not n in vars:
|
||||
continue
|
||||
out += "%s=%s\n" % (n, vars[n])
|
||||
return out
|
||||
|
@ -42,6 +42,7 @@ from selftest.run import (
|
||||
expand_environment_strings,
|
||||
expand_command_list,
|
||||
expand_command_run,
|
||||
exported_envvars_str,
|
||||
)
|
||||
from selftest.target import (
|
||||
EnvironmentManager,
|
||||
@ -446,17 +447,6 @@ exported_envvars = [
|
||||
"LOCAL_PATH"
|
||||
]
|
||||
|
||||
def exported_envvars_str(testenv_vars):
|
||||
out = ""
|
||||
|
||||
for n in exported_envvars:
|
||||
if not n in testenv_vars:
|
||||
continue
|
||||
out += "%s=%s\n" % (n, testenv_vars[n])
|
||||
|
||||
return out
|
||||
|
||||
|
||||
def switch_env(name, prefix):
|
||||
if ":" in name:
|
||||
(envname, option) = name.split(":", 1)
|
||||
@ -500,7 +490,7 @@ if opts.testenv:
|
||||
os.environ["PIDDIR"] = testenv_vars["PIDDIR"]
|
||||
os.environ["ENVNAME"] = testenv_name
|
||||
|
||||
envvarstr = exported_envvars_str(testenv_vars)
|
||||
envvarstr = exported_envvars_str(testenv_vars, exported_envvars)
|
||||
|
||||
term = os.environ.get("TERMINAL", "xterm -e")
|
||||
cmd = """'echo -e "
|
||||
|
@ -25,6 +25,7 @@ from selftest.run import (
|
||||
expand_command_list,
|
||||
expand_environment_strings,
|
||||
expand_command_run,
|
||||
exported_envvars_str,
|
||||
)
|
||||
|
||||
from selftest.tests import TestCase
|
||||
@ -77,3 +78,17 @@ class ExpandCommandRunTests(TestCase):
|
||||
def test_loadlist_all(self):
|
||||
self.assertEquals(("test ", None),
|
||||
expand_command_run("test $LOADLIST", True, False))
|
||||
|
||||
|
||||
class ExportedEnvvarsStrTests(TestCase):
|
||||
|
||||
def test_no_vars(self):
|
||||
self.assertEquals("", exported_envvars_str({}, ["foo", "bar"]))
|
||||
|
||||
def test_vars(self):
|
||||
self.assertEquals("foo=1\n",
|
||||
exported_envvars_str({"foo": "1"}, ["foo", "bar"]))
|
||||
|
||||
def test_vars_unknown(self):
|
||||
self.assertEquals("foo=1\n",
|
||||
exported_envvars_str({"foo": "1", "bla": "2"}, ["foo", "bar"]))
|
||||
|
Loading…
x
Reference in New Issue
Block a user