validate:launcher: Avoid printing twice env variables
authorThibault Saunier <tsaunier@gnome.org>
Fri, 12 Jun 2015 09:17:43 +0000 (11:17 +0200)
committerThibault Saunier <tsaunier@gnome.org>
Fri, 12 Jun 2015 09:31:13 +0000 (11:31 +0200)
When printing test command.

validate/launcher/baseclasses.py

index e324b69..8bef580 100644 (file)
@@ -84,7 +84,7 @@ class Test(Loggable):
         self.logfile = None
         self.out = None
         self.extra_logfiles = []
-        self._env_variable = ''
+        self.__env_variable = []
 
     def __str__(self):
         string = self.classname
@@ -114,9 +114,19 @@ class Test(Loggable):
         if value is None:
             return
 
-        if self._env_variable:
-            self._env_variable += " "
-        self._env_variable += "%s=%s" % (variable, value)
+        self.__env_variable.append(variable)
+
+    @property
+    def _env_variable(self):
+        res = ""
+        for var in set(self.__env_variable):
+            if res:
+                res += " "
+            value = self.proc_env.get(var, None)
+            if value:
+                res += "%s=%s" % (var, value)
+
+        return res
 
     def open_logfile(self):
         path = os.path.join(self.options.logsdir,