Skip to content

Commit fa882e3

Browse files
committed
[clang][test] Modified python program to return error code when failing
to get file size This patch removes the print statement that executes in the case of exceptions, opting to let the system return its own error code when failing to get the file size of a certain file. There are also some NFC changes: adding description for compare-file-size.py and changing the %{python} syntax to use the exisitng lit substitution %python.
1 parent 5801e58 commit fa882e3

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed
+8-16
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
1+
# This program takes in two file path arguments and returns true if the
2+
# file size of the first file is smaller than the file size of the second file
3+
14
import argparse
25
import os
36

4-
def get_file_size(file_path):
5-
try:
6-
return os.path.getsize(file_path)
7-
except:
8-
print(f"Unable to get file size of {file_path}")
9-
return None
10-
11-
def main():
12-
parser = argparse.ArgumentParser()
13-
14-
parser.add_argument("file1", type=str)
15-
parser.add_argument("file2", type=str)
7+
parser = argparse.ArgumentParser()
168

17-
args = parser.parse_args()
9+
parser.add_argument("file1", type=str)
10+
parser.add_argument("file2", type=str)
1811

19-
return get_file_size(args.file1) < get_file_size(args.file2)
12+
args = parser.parse_args()
2013

21-
if __name__ == "__main__":
22-
main()
14+
return os.path.getsize(args.file1) < os.path.getsize(args.file2)

clang/test/Modules/reduced-bmi-size.cppm

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t/a.pcm
1111
// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %s -o %t/a.reduced.pcm
1212
//
13-
// RUN: %{python} %S/compare-file-size.py %t/a.pcm %t/a.reduced.pcm
13+
// RUN: %python %S/compare-file-size.py %t/a.pcm %t/a.reduced.pcm
1414

1515
export module a;

clang/test/lit.cfg.py

-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@
7474

7575
config.substitutions.append(("%PATH%", config.environment["PATH"]))
7676

77-
config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
78-
7977

8078
# For each occurrence of a clang tool name, replace it with the full path to
8179
# the build directory holding that tool. We explicitly specify the directories

0 commit comments

Comments
 (0)