]> granicus.if.org Git - llvm/commitdiff
[test] Fix append_path in the empty case
authorFrancis Ricci <francisjricci@gmail.com>
Wed, 4 Oct 2017 17:30:28 +0000 (17:30 +0000)
committerFrancis Ricci <francisjricci@gmail.com>
Wed, 4 Oct 2017 17:30:28 +0000 (17:30 +0000)
Summary:
normpath() was being called on an empty string and appended to
the environment variable in the case where the environment variable
was unset. This led to ":." being appended to the path, since
normpath() of an empty string is '.', presumably to represent cwd.

Reviewers: zturner, sqlbyme, modocache

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D38542

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314915 91177308-0d34-0410-b5e6-96231b3b80d8

utils/lit/lit/llvm/config.py

index c3bdef318d6f0add78ce5847f55896d30ddaa53a..b1ad5876099b9f80c615be28044828aebfbf66d7 100644 (file)
@@ -107,9 +107,13 @@ class LLVMConfig(object):
             def norm(x):
                 return os.path.normcase(os.path.normpath(x))
 
-            current_paths = self.config.environment.get(variable, "")
-            current_paths = current_paths.split(os.path.pathsep)
-            paths = [norm(p) for p in current_paths]
+            current_paths = self.config.environment.get(variable, None)
+            if current_paths:
+                current_paths = current_paths.split(os.path.pathsep)
+                paths = [norm(p) for p in current_paths]
+            else:
+                paths = []
+
             # If we are passed a list [a b c], then iterating this list forwards
             # and adding each to the beginning would result in b c a.  So we
             # need to iterate in reverse to end up with the original ordering.