Skip to content

Commit

Permalink
[clang][test] Rewrote test using command substitution to work with li…
Browse files Browse the repository at this point in the history
…t internal shell syntax (llvm#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 llvm#102384.
  • Loading branch information
connieyzhu authored Aug 29, 2024
1 parent 7284e0f commit 4caf019
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
20 changes: 20 additions & 0 deletions clang/test/Modules/compare-file-size.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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()
3 changes: 1 addition & 2 deletions clang/test/Modules/reduced-bmi-size.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t/a.pcm
// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %s -o %t/a.reduced.pcm
//
// %s implies the current source file. So we can't use it directly.
// RUN: [ $(stat -c%\s "%t/a.pcm") -le $(stat -c%\s "%t/a.reduced.pcm") ]
// RUN: %python %S/compare-file-size.py %t/a.pcm %t/a.reduced.pcm

export module a;

0 comments on commit 4caf019

Please sign in to comment.