llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-testing-tools Author: Mattéo Rizza Murgier (matteo-rm) <details> <summary>Changes</summary> Handle run lines containing lit `%if`s by ignoring the condition and unwrapping, similar to other update scripts. --- Full diff: https://github.com/llvm/llvm-project/pull/238255.diff 5 Files Affected: - (added) clang/test/utils/update_cc_test_checks/Inputs/lit-if.c (+4) - (added) clang/test/utils/update_cc_test_checks/Inputs/lit-if.c.expected (+9) - (added) clang/test/utils/update_cc_test_checks/lit-if.test (+4) - (modified) llvm/utils/UpdateTestChecks/common.py (+8-2) - (modified) llvm/utils/update_cc_test_checks.py (+1-1) ``````````diff diff --git a/clang/test/utils/update_cc_test_checks/Inputs/lit-if.c b/clang/test/utils/update_cc_test_checks/Inputs/lit-if.c new file mode 100644 index 00000000000000..c277a98d66f028 --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/Inputs/lit-if.c @@ -0,0 +1,4 @@ +// Check that the commands of a '%if' RUN line are run. +// RUN: %if x86-registered-target %{ %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s %} + +void f(void) {} diff --git a/clang/test/utils/update_cc_test_checks/Inputs/lit-if.c.expected b/clang/test/utils/update_cc_test_checks/Inputs/lit-if.c.expected new file mode 100644 index 00000000000000..8b4eea71a5bc55 --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/Inputs/lit-if.c.expected @@ -0,0 +1,9 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// Check that the commands of a '%if' RUN line are run. +// RUN: %if x86-registered-target %{ %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s %} + +// CHECK-LABEL: @f( +// CHECK-NEXT: entry: +// CHECK-NEXT: ret void +// +void f(void) {} diff --git a/clang/test/utils/update_cc_test_checks/lit-if.test b/clang/test/utils/update_cc_test_checks/lit-if.test new file mode 100644 index 00000000000000..d4b6e1a40f9d05 --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/lit-if.test @@ -0,0 +1,4 @@ +## Test that the commands of a `%if` RUN line are run. + +# RUN: cp %S/Inputs/lit-if.c %t.c && %update_cc_test_checks %t.c +# RUN: diff -u %S/Inputs/lit-if.c.expected %t.c diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index 2d1af7e2a11976..ca99009f232c96 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -507,13 +507,19 @@ def getSubstitutions(sourcepath): ] -def split_run_line(run_line): - """Split a FileCheck RUN line into its tool, FileCheck, and pre-processing commands.""" +def unwrap_lit_if(run_line): + """Return the commands of a `%if <condition> %{ <commands> %}` RUN line, without + evaluating the condition.""" if "%if" in run_line: match = re.search(r"%{\s*(.*?)\s*%}", run_line) if match: run_line = match.group(1) + return run_line + +def split_run_line(run_line): + """Split a FileCheck RUN line into its tool, FileCheck, and pre-processing commands.""" + run_line = unwrap_lit_if(run_line) commands = [cmd.strip() for cmd in run_line.split("|")] assert len(commands) >= 2 preprocess_cmd = " | ".join(commands[:-2]) or None diff --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py index cabdda9d5c0536..2bf8c52f5a7dff 100755 --- a/llvm/utils/update_cc_test_checks.py +++ b/llvm/utils/update_cc_test_checks.py @@ -318,7 +318,7 @@ def update_test(ti: common.TestInfo): } for l in ti.run_lines: - commands = [cmd.strip() for cmd in l.split("|")] + commands = [cmd.strip() for cmd in common.unwrap_lit_if(l).split("|")] triple_in_cmd = None m = common.TRIPLE_ARG_RE.search(commands[0]) `````````` </details> https://github.com/llvm/llvm-project/pull/238255 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
