Skip to content

Commit bfb1d05

Browse files
committed
[NFC][Py Reformat] Reformat python files in llvm-test-suite
This is an ongoing series of commits that are reformatting our Python code. Reformatting is done with `black`. If you end up having problems merging this commit because you have made changes to a python file, the best way to handle that is to run git checkout --ours <yourfile> and then reformat it with black. If you run into any problems, post to discourse about it and we will try to help. RFC Thread below: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style Specific to this change: * Does not change third-party code in `MicroBenchmarks/libs/benchmark`. Fix code to make it parseable by python3/black in the first place: * Fixed space/tab confusion in `CollectDebugInfoUsingLLDB.py`. * Change to python3 `print` syntax: `ABI-Testsuite/sample.py`, `ABI-Testsuite/test/lit.site.cfg`, `tools/get-report-time` Differential Revision: https://reviews.llvm.org/D151914
1 parent 99d48a3 commit bfb1d05

File tree

74 files changed

+2382
-1102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2382
-1102
lines changed

ABI-Testsuite/linux-x86.py

Lines changed: 94 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -4,116 +4,122 @@
44
from __future__ import print_function
55
import os
66
import sys
7+
78
wopt = " -w"
89
test_params = {
9-
"bindump" : "nm",
10-
"runtool" : "", # if None, then runtool_func must exists
11-
"Platform" : "linux-gcc",
12-
"cxx_rtti" : "-frtti", # option to enable rtti
13-
"cxx_exceptions" : "-fexceptions", # option to enable rtti
14-
"cxx_cpp11" : "-std=c++0x" ,
10+
"bindump": "nm",
11+
"runtool": "", # if None, then runtool_func must exists
12+
"Platform": "linux-gcc",
13+
"cxx_rtti": "-frtti", # option to enable rtti
14+
"cxx_exceptions": "-fexceptions", # option to enable rtti
15+
"cxx_cpp11": "-std=c++0x",
1516
}
1617

18+
1719
def build_cxx_compiler_name(cn):
18-
# build c++ compiler name from C compiler name
19-
# <prefix>clang <options> : becomes <prefix>clang -x c++ <options>
20-
# <prefix>gcc <options> : becomes <prefix>g++ <options>
21-
# <prefix>gcc-<vers> <options>: becomes <prefix>g++-<vers> <options>
20+
# build c++ compiler name from C compiler name
21+
# <prefix>clang <options> : becomes <prefix>clang -x c++ <options>
22+
# <prefix>gcc <options> : becomes <prefix>g++ <options>
23+
# <prefix>gcc-<vers> <options>: becomes <prefix>g++-<vers> <options>
2224

23-
cnlen = len(cn)
24-
if (cn == 'clang'): #plain clang
25-
return "clang -x c++"
25+
cnlen = len(cn)
26+
if cn == "clang": # plain clang
27+
return "clang -x c++"
2628

27-
idx = cn.find("clang ")
28-
if (idx >= 0): # clang with some options
29-
return cn[:(idx+6)] + "-x c++ " + cn[(idx+6):]
29+
idx = cn.find("clang ")
30+
if idx >= 0: # clang with some options
31+
return cn[: (idx + 6)] + "-x c++ " + cn[(idx + 6) :]
3032

31-
idx = cn.rfind('clang')
32-
if (idx == (cnlen-5)): # ends in gcc
33-
return cn + " -x c++"
33+
idx = cn.rfind("clang")
34+
if idx == (cnlen - 5): # ends in gcc
35+
return cn + " -x c++"
3436

35-
if (cn == 'gcc'):
36-
return "g++"
37+
if cn == "gcc":
38+
return "g++"
3739

38-
idx = cn.rfind('gcc')
39-
if (idx == (cnlen-3)): # ends in gcc
40-
return cn + " -x c++"
40+
idx = cn.rfind("gcc")
41+
if idx == (cnlen - 3): # ends in gcc
42+
return cn + " -x c++"
4143

42-
idx = cn.find("gcc ")
43-
if (idx >= 0): # gcc with some options
44-
return cn[:(idx+1)] + "++ " + cn[(idx+4):]
44+
idx = cn.find("gcc ")
45+
if idx >= 0: # gcc with some options
46+
return cn[: (idx + 1)] + "++ " + cn[(idx + 4) :]
4547

46-
idx = cn.find("gcc-")
47-
if (idx >= 0): # gcc-<version>
48-
return cn[:(idx+1)] + "++" + cn[(idx+3):]
48+
idx = cn.find("gcc-")
49+
if idx >= 0: # gcc-<version>
50+
return cn[: (idx + 1)] + "++" + cn[(idx + 3) :]
51+
52+
return "UNEXPECTED COMPILER"
4953

50-
return "UNEXPECTED COMPILER"
5154

5255
def build_linker_name(cn):
53-
# build linkercompiler name from C compiler name
54-
# <prefix>clang <options> : becomes <prefix>clang++ <options>
55-
# <prefix>gcc <options> : becomes <prefix>g++ <options>
56-
# <prefix>gcc-<vers> <options>: becomes <prefix>g++-<vers> <options>
56+
# build linkercompiler name from C compiler name
57+
# <prefix>clang <options> : becomes <prefix>clang++ <options>
58+
# <prefix>gcc <options> : becomes <prefix>g++ <options>
59+
# <prefix>gcc-<vers> <options>: becomes <prefix>g++-<vers> <options>
5760

58-
if (cn == 'clang'): #plain clang
59-
return "clang++"
61+
if cn == "clang": # plain clang
62+
return "clang++"
6063

61-
idx = cn.find("clang ")
62-
if (idx >= 0): # clang with some options
63-
return cn[:(idx+5)] + "++ " + cn[(idx+6):]
64+
idx = cn.find("clang ")
65+
if idx >= 0: # clang with some options
66+
return cn[: (idx + 5)] + "++ " + cn[(idx + 6) :]
6467

65-
cnlen = len(cn)
66-
idx = cn.rfind('clang')
67-
if (idx == (cnlen-5)): # ends in clang
68-
return cn + "++"
68+
cnlen = len(cn)
69+
idx = cn.rfind("clang")
70+
if idx == (cnlen - 5): # ends in clang
71+
return cn + "++"
6972

70-
return build_cxx_compiler_name(cn) # for gcc, linekr name is same as c++ compiler name
73+
return build_cxx_compiler_name(
74+
cn
75+
) # for gcc, linekr name is same as c++ compiler name
7176

7277

7378
import subprocess
79+
7480
if __name__ == "__main__":
75-
print(sys.argv)
76-
litargs = [sys.argv[0]] # args for lit.main
77-
c_compiler_name = sys.argv[1].strip()
78-
cxx_compiler_name = build_cxx_compiler_name(c_compiler_name)
79-
linker_name = build_linker_name(c_compiler_name)
80-
#print("C++ compiler:", cxx_compiler_name)
81-
#print("linker :", linker_name)
82-
for la in sys.argv[2:]:
83-
litargs.append(la)
84-
sys.argv = litargs
85-
cmd = c_compiler_name.split() + [ "-o", "b.exe", "test/common/genselector.c"]
86-
#print("cmd = ", cmd)
87-
rv = subprocess.call(cmd)
88-
#print("rv = " , rv)
89-
if rv != 0:
90-
print("compiler failed: ", cmd)
91-
sys.exit(1)
92-
rv = subprocess.call("./b.exe")
93-
fp = open("nselector.h")
94-
fi = fp.read();
95-
fp.close()
96-
if ("LP64" in fi):
97-
test_params["Mode"] = "LP64-x86"
98-
prf = "--check-prefix=LP64"
99-
else:
100-
# 'gcc -m32' or 'clang -m32' mode
101-
test_params["Mode"] = "ILP32-x86"
102-
prf = "--check-prefix=ILP32"
103-
test_params["prefixes"] = prf;
104-
test_params["c_compiler"] = c_compiler_name
105-
test_params["cxx_compiler"] = cxx_compiler_name
106-
test_params["linker"] = linker_name
107-
test_params["Platform"] = "linux-" + cmd[0]
108-
109-
print("test_params = " , test_params)
110-
builtin_parameters = {
111-
'build_mode' : "Release",
112-
'llvm_site_config' : os.path.join(os.getcwd(), 'lit.site.cfg'),
113-
'clang_site_config': os.path.join(os.getcwd(), 'lit.site.cfg'),
114-
'test_params' : test_params
81+
print(sys.argv)
82+
litargs = [sys.argv[0]] # args for lit.main
83+
c_compiler_name = sys.argv[1].strip()
84+
cxx_compiler_name = build_cxx_compiler_name(c_compiler_name)
85+
linker_name = build_linker_name(c_compiler_name)
86+
# print("C++ compiler:", cxx_compiler_name)
87+
# print("linker :", linker_name)
88+
for la in sys.argv[2:]:
89+
litargs.append(la)
90+
sys.argv = litargs
91+
cmd = c_compiler_name.split() + ["-o", "b.exe", "test/common/genselector.c"]
92+
# print("cmd = ", cmd)
93+
rv = subprocess.call(cmd)
94+
# print("rv = " , rv)
95+
if rv != 0:
96+
print("compiler failed: ", cmd)
97+
sys.exit(1)
98+
rv = subprocess.call("./b.exe")
99+
fp = open("nselector.h")
100+
fi = fp.read()
101+
fp.close()
102+
if "LP64" in fi:
103+
test_params["Mode"] = "LP64-x86"
104+
prf = "--check-prefix=LP64"
105+
else:
106+
# 'gcc -m32' or 'clang -m32' mode
107+
test_params["Mode"] = "ILP32-x86"
108+
prf = "--check-prefix=ILP32"
109+
test_params["prefixes"] = prf
110+
test_params["c_compiler"] = c_compiler_name
111+
test_params["cxx_compiler"] = cxx_compiler_name
112+
test_params["linker"] = linker_name
113+
test_params["Platform"] = "linux-" + cmd[0]
114+
115+
print("test_params = ", test_params)
116+
builtin_parameters = {
117+
"build_mode": "Release",
118+
"llvm_site_config": os.path.join(os.getcwd(), "lit.site.cfg"),
119+
"clang_site_config": os.path.join(os.getcwd(), "lit.site.cfg"),
120+
"test_params": test_params,
115121
}
116-
#print("builtin_params = " , test_params)
117-
from lit.main import main
118-
main(builtin_parameters)
122+
# print("builtin_params = " , test_params)
123+
from lit.main import main
119124

125+
main(builtin_parameters)

ABI-Testsuite/sample.py

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,38 @@
66

77
import os
88
import sys
9-
wopt = "" # set to " -w", or equivalent option, to disable warnings.
10-
11-
#skiplist = [ "test/s2_7/test_02", "test/s2_7/test_06"] # Enable to choose a 'skip list'
12-
13-
test_params = {
14-
'bindump': 'nm', # name of the nm-like tool to print symbol names
15-
'cxx_rtti': '-frtti', # option to enable rtti
16-
'runtool': '', # leave empty for native runs.
17-
# Set to the name of the 'runner' tool for cross tools
18-
'linker': 'clang++ -w', # name of the linker
19-
'cxx_compiler': 'clang -x c++'+wopt, # name of the C++ compiler
20-
'c_compiler': 'clang'+wopt, # name of the C compiler
21-
'cxx_cpp11': '-std=c++0x', # option to enable C++11 mode, if any
22-
'prefixes': '--check-prefix=LP64', # must be LP64 or ILP32
23-
'Platform': 'linux-clang', # just for documentation
24-
'Mode': 'LP64-x86', # must be "LP64-x86" or "ILP32-x86"
25-
'cxx_exceptions': '-fexceptions' # options to enable exceptions
9+
10+
wopt = "" # set to " -w", or equivalent option, to disable warnings.
11+
12+
# skiplist = [ "test/s2_7/test_02", "test/s2_7/test_06"] # Enable to choose a 'skip list'
13+
14+
test_params = {
15+
"bindump": "nm", # name of the nm-like tool to print symbol names
16+
"cxx_rtti": "-frtti", # option to enable rtti
17+
"runtool": "", # leave empty for native runs.
18+
# Set to the name of the 'runner' tool for cross tools
19+
"linker": "clang++ -w", # name of the linker
20+
"cxx_compiler": "clang -x c++" + wopt, # name of the C++ compiler
21+
"c_compiler": "clang" + wopt, # name of the C compiler
22+
"cxx_cpp11": "-std=c++0x", # option to enable C++11 mode, if any
23+
"prefixes": "--check-prefix=LP64", # must be LP64 or ILP32
24+
"Platform": "linux-clang", # just for documentation
25+
"Mode": "LP64-x86", # must be "LP64-x86" or "ILP32-x86"
26+
"cxx_exceptions": "-fexceptions" # options to enable exceptions
2627
# , skip_list: skiplist # if skiplist is not empty
27-
}
28+
}
2829

2930

3031
import subprocess
32+
3133
if __name__ == "__main__":
32-
print "test_params = " , test_params
33-
builtin_parameters = {
34-
'build_mode' : "Release",
35-
'llvm_site_config' : os.path.join(os.getcwd(), 'lit.site.cfg'),
36-
'clang_site_config': os.path.join(os.getcwd(), 'lit.site.cfg'),
37-
'test_params' : test_params
34+
print(f"test_params = {test_params}")
35+
builtin_parameters = {
36+
"build_mode": "Release",
37+
"llvm_site_config": os.path.join(os.getcwd(), "lit.site.cfg"),
38+
"clang_site_config": os.path.join(os.getcwd(), "lit.site.cfg"),
39+
"test_params": test_params,
3840
}
39-
from lit.main import main
40-
main(builtin_parameters)
41+
from lit.main import main
4142

43+
main(builtin_parameters)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
22
# See https://llvm.org/LICENSE.txt for license information.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4-
config.suffixes = ['.c']
4+
config.suffixes = [".c"]

ABI-Testsuite/test/coll/lit.local.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
22
# See https://llvm.org/LICENSE.txt for license information.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4-
config.suffixes = ['.c']
4+
config.suffixes = [".c"]

ABI-Testsuite/test/common/lit.local.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# See https://llvm.org/LICENSE.txt for license information.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
# Skip this directory
5-
config.suffixes = []
5+
config.suffixes = []

0 commit comments

Comments
 (0)