From 0233cb85f20d79cf962ea801ea35b1bc2994e8e5 Mon Sep 17 00:00:00 2001 From: Stanislav Pankevich Date: Sun, 29 Dec 2019 15:29:52 +0100 Subject: [PATCH] docs: Check commands: CHECK-NEXT description --- docs/05-check-commands.rst | 37 +++++++++++++++++++++++- examples/check-commands/CHECK-NEXT.check | 2 ++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 examples/check-commands/CHECK-NEXT.check diff --git a/docs/05-check-commands.rst b/docs/05-check-commands.rst index 74cf7b2..11d4ab9 100644 --- a/docs/05-check-commands.rst +++ b/docs/05-check-commands.rst @@ -107,7 +107,42 @@ Example CHECK-NEXT ---------- -... +``CHECK-NEXT`` command means that a given string or a regular expression must be +present in input provided to FileCheck. Additionally, there must be another +check right before ``CHECK-NEXT``, that has passed on the input line just before +the current input line. ``CHECK-NEXT`` cannot be the first check in the check +file. + +Check file ``CHECK-NEXT.check``: + +.. code-block:: text + + CHECK: String1 + CHECK-NEXT: String2 + +.. code-block:: bash + + $ echo -e "String1\nString2" | filecheck CHECK-NEXT.check + ...filecheck + $ echo ?0 + 0 + +.. code-block:: bash + + $ echo -e "String1\nfoo\nString2" | filecheck CHECK-NEXT.check + ...filecheck + CHECK-NEXT.check:2:13: error: CHECK-NEXT: is not on the line after the previous match + CHECK-NEXT: String2 + ^ + :3:1: note: 'next' match was here + String2 + ^ + :1:8: note: previous match ended here + String1 + ^ + :2:1: note: non-matching line after previous match is here + foo + ^ CHECK-EMPTY ----------- diff --git a/examples/check-commands/CHECK-NEXT.check b/examples/check-commands/CHECK-NEXT.check new file mode 100644 index 0000000..920cc71 --- /dev/null +++ b/examples/check-commands/CHECK-NEXT.check @@ -0,0 +1,2 @@ +CHECK: String1 +CHECK-NEXT: String2