Skip to content

Commit b7cf36a

Browse files
committed
[clang][test] Rewrote test to work with lit internal shell syntax
This patch rewrites a test that uses command substitution $() and the stat command, which are not supported by lit's internal shell. Instead of using this syntax to perform the file size comparison done in this test, a Python script is used instead to perform the same operation.
1 parent f3a47b9 commit b7cf36a

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import argparse
2+
import os
3+
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)
16+
17+
args = parser.parse_args()
18+
19+
return get_file_size(args.file1) < get_file_size(args.file2)
20+
21+
if __name__ == "__main__":
22+
main()

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +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-
// %s implies the current source file. So we can't use it directly.
14-
// RUN: [ $(stat -c%\s "%t/a.pcm") -le $(stat -c%\s "%t/a.reduced.pcm") ]
13+
// RUN: %{python} %S/compare-file-size.py %t/a.pcm %t/a.reduced.pcm
1514

1615
export module a;

clang/test/lit.cfg.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474

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

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

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

0 commit comments

Comments
 (0)