summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--selftest/run.py9
-rwxr-xr-xselftest/selftest.py14
-rw-r--r--selftest/tests/test_run.py15
3 files changed, 26 insertions, 12 deletions
diff --git a/selftest/run.py b/selftest/run.py
index 25f3e5d7c9..20ede65532 100644
--- a/selftest/run.py
+++ b/selftest/run.py
@@ -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
diff --git a/selftest/selftest.py b/selftest/selftest.py
index 893ff4cfaa..9ca1e45c1d 100755
--- a/selftest/selftest.py
+++ b/selftest/selftest.py
@@ -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 "
diff --git a/selftest/tests/test_run.py b/selftest/tests/test_run.py
index f1ce4bc9de..894ceaa7fc 100644
--- a/selftest/tests/test_run.py
+++ b/selftest/tests/test_run.py
@@ -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"]))