Skip to content

Commit b9fd375

Browse files
committed
Revert "[lit] Keep original cfg file case around."
This reverts commit bc3f54d. The patch breaks in the following two scenarios: 1. When manually passing an absolute path to llvm-lit with a lower-case drive letter: `python bin\llvm-lit.py -sv c:\llvm-project\clang\test\PCH` 2. When the PWD has a lower-case drive letter, like after running `cd c:\` with a lower-case "c:" (cmd's default is upper-case, but it takes case-ness from what's passed to `cd` apparently).
1 parent 92e8af0 commit b9fd375

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,10 +1423,16 @@ endfunction()
14231423
# path. Since this uses __file__, it has to be emitted into python files that
14241424
# use it and can't be in a lit module. Use with make_paths_relative().
14251425
string(CONCAT LLVM_LIT_PATH_FUNCTION
1426+
# Lit converts config paths to lower case in discovery.py, before
1427+
# loading the config. This causes __file__ to be all lower-case (including
1428+
# the drive letter), but several clang tests pass -include %s and a
1429+
# clang warning checks that passed case matches on-disk cache. So it's
1430+
# important that this restores the on-disk case of the prefix.
14261431
"# Allow generated file to be relocatable.\n"
14271432
"def path(p):\n"
14281433
" if not p: return ''\n"
14291434
" p = os.path.join(os.path.dirname(os.path.abspath(__file__)), p)\n"
1435+
" if os.name == 'nt' and os.path.isabs(p): return p[0].upper() + p[1:]\n"
14301436
" return p\n"
14311437
)
14321438

llvm/utils/lit/lit/discovery.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def search1(path):
5353
config_map = litConfig.params.get('config_map')
5454
if config_map:
5555
cfgpath = os.path.realpath(cfgpath)
56-
t, target = config_map.get(os.path.normcase(cfgpath), (None, None))
57-
assert t is None or t == cfgpath
56+
cfgpath = os.path.normcase(cfgpath)
57+
target = config_map.get(cfgpath)
5858
if target:
5959
cfgpath = target
6060

llvm/utils/lit/lit/llvm/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ def __init__(self, lit_config, config):
115115

116116
def with_environment(self, variable, value, append_path=False):
117117
if append_path:
118-
# For paths, we should be able to take a list of them and process
119-
# all of them.
118+
# For paths, we should be able to take a list of them and process all
119+
# of them.
120120
paths_to_add = value
121121
if lit.util.is_string(paths_to_add):
122122
paths_to_add = [paths_to_add]
@@ -135,8 +135,8 @@ def norm(x):
135135
# and adding each to the beginning would result in b c a. So we
136136
# need to iterate in reverse to end up with the original ordering.
137137
for p in reversed(paths_to_add):
138-
# Move it to the front if it already exists, otherwise insert
139-
# it at the beginning.
138+
# Move it to the front if it already exists, otherwise insert it at the
139+
# beginning.
140140
p = norm(p)
141141
try:
142142
paths.remove(p)

llvm/utils/lit/tests/Inputs/config-map-discovery/driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
main_config = os.path.realpath(main_config)
77
main_config = os.path.normcase(main_config)
88

9-
config_map = {os.path.normcase(main_config) : (main_config, sys.argv[2])}
9+
config_map = {main_config : sys.argv[2]}
1010
builtin_parameters = {'config_map' : config_map}
1111

1212
if __name__=='__main__':

llvm/utils/llvm-lit/llvm-lit.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ config_map = {}
99
def map_config(source_dir, site_config):
1010
global config_map
1111
source_dir = os.path.realpath(source_dir)
12+
source_dir = os.path.normcase(source_dir)
1213
site_config = os.path.normpath(site_config)
13-
config_map[os.path.normcase(source_dir)] = source_dir, site_config
14+
config_map[source_dir] = site_config
1415

1516
# Set up some builtin parameters, so that by default the LLVM test suite
1617
# configuration file knows how to find the object tree.

0 commit comments

Comments
 (0)