llvm.org GIT mirror llvm / 76fe1ec
[lit] Reverse path list when updating environment vars. Bug pointed out by EricWF. This would construct a path where items would be added in the wrong order, potentially leading to using the wrong tools for testing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313765 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 2 years ago
1 changed file(s) with 4 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
105105 current_paths = self.config.environment.get(variable, "")
106106 current_paths = current_paths.split(os.path.pathsep)
107107 paths = [norm(p) for p in current_paths]
108 for p in paths_to_add:
108 # If we are passed a list [a b c], then iterating this list forwards
109 # and adding each to the beginning would result in b c a. So we
110 # need to iterate in reverse to end up with the original ordering.
111 for p in reversed(paths_to_add):
109112 # Move it to the front if it already exists, otherwise insert it at the
110113 # beginning.
111114 p = norm(p)