diff --git a/docs/05-check-commands.rst b/docs/05-check-commands.rst index 959ac14..a0038dd 100644 --- a/docs/05-check-commands.rst +++ b/docs/05-check-commands.rst @@ -122,7 +122,7 @@ Check file ``CHECK-NEXT.check``: $ echo -e "String1\nString2" | filecheck CHECK-NEXT.check ...filecheck - $ echo ?0 + $ echo $? 0 .. code-block:: bash @@ -145,4 +145,34 @@ Check file ``CHECK-NEXT.check``: CHECK-EMPTY ----------- -... +``CHECK-EMPTY`` command is used to match empty lines. + +Consider the following check file: + +.. code-block:: text + + CHECK: String1 + CHECK-EMPTY: + CHECK: String2 + +In the following example, there is an empty line so the test will pass: + +.. code-block:: bash + + echo -e "String1\n\nString2" | filecheck CHECK-EMPTY.check + ...filecheck + $ echo $? + 0 + +If the empty line is removed, the test will fail: + + echo -e "String1\nString2" | filecheck CHECK-EMPTY.check + ...filecheck + ...CHECK-EMPTY.check:2:13: error: CHECK-EMPTY: expected string not found in input + CHECK-EMPTY: + ^ + :2:1: note: scanning from here + String2 + ^ + $ echo $? + 1 diff --git a/tests/integration/tests/examples/check-commands/CHECK-EMPTY/Failure/CHECK-EMPTY.check b/tests/integration/tests/examples/check-commands/CHECK-EMPTY/Failure/CHECK-EMPTY.check new file mode 100644 index 0000000..4205b02 --- /dev/null +++ b/tests/integration/tests/examples/check-commands/CHECK-EMPTY/Failure/CHECK-EMPTY.check @@ -0,0 +1,3 @@ +CHECK: String1 +CHECK-EMPTY: +CHECK: String2 \ No newline at end of file diff --git a/tests/integration/tests/examples/check-commands/CHECK-EMPTY/Failure/CHECK-EMPTY.itest-py b/tests/integration/tests/examples/check-commands/CHECK-EMPTY/Failure/CHECK-EMPTY.itest-py new file mode 100644 index 0000000..0402a4a --- /dev/null +++ b/tests/integration/tests/examples/check-commands/CHECK-EMPTY/Failure/CHECK-EMPTY.itest-py @@ -0,0 +1,9 @@ +; RUN: echo -e "String1\nString2" | (%FILECHECK_EXEC %S/CHECK-EMPTY.check 2>&1; test $? = 1) | %FILECHECK_EXEC %s +; CHECK: {{^.*}}FileCheck{{(\.py)?$}} +; CHECK: {{^.*}}CHECK-EMPTY.check:2:13: error: CHECK-EMPTY: expected string not found in input +; CHECK: CHECK-EMPTY: +; CHECK: ^ +; CHECK: :2:1: note: scanning from here +; CHECK: String2 +; CHECK: ^ +; CHECK-EMPTY: diff --git a/tests/integration/tests/examples/check-commands/CHECK-EMPTY/Success/CHECK-EMPTY.check b/tests/integration/tests/examples/check-commands/CHECK-EMPTY/Success/CHECK-EMPTY.check new file mode 100644 index 0000000..2a500e5 --- /dev/null +++ b/tests/integration/tests/examples/check-commands/CHECK-EMPTY/Success/CHECK-EMPTY.check @@ -0,0 +1,3 @@ +CHECK: String1 +CHECK-EMPTY: +CHECK: String2 diff --git a/tests/integration/tests/examples/check-commands/CHECK-EMPTY/Success/CHECK-EMPTY.itest b/tests/integration/tests/examples/check-commands/CHECK-EMPTY/Success/CHECK-EMPTY.itest new file mode 100644 index 0000000..d2d5b3b --- /dev/null +++ b/tests/integration/tests/examples/check-commands/CHECK-EMPTY/Success/CHECK-EMPTY.itest @@ -0,0 +1,3 @@ +; RUN: echo -e "String1\n\nString2" | %FILECHECK_EXEC %S/CHECK-EMPTY.check | %FILECHECK_EXEC %s +; CHECK: {{^.*}}FileCheck{{(\.py)?$}} +; CHECK-EMPTY: