llvm-project/clang/test/Modules/compare-file-size.py
Connie Zhu 4caf0196c0
[clang][test] Rewrote test using command substitution to work with lit internal shell syntax (#105902)
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.

Fixes https://github.com/llvm/llvm-project/issues/102384.
2024-08-29 14:54:40 -07:00

21 lines
488 B
Python

# This program takes in two file path arguments in the form 'compare-file-size.py file1 file2'
# Returns true if the file size of the file1 is smaller than the file size of file2
import argparse
import os
def main():
parser = argparse.ArgumentParser()
parser.add_argument("file1", type=str)
parser.add_argument("file2", type=str)
args = parser.parse_args()
return os.path.getsize(args.file1) < os.path.getsize(args.file2)
if __name__ == "__main__":
main()