Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: switch to printf in all examples #92

Merged
merged 1 commit into from
Jan 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions docs/05-check-commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ For all of the examples below, please note:

- ``.check`` extension is chosen arbitrarily. FileCheck can work with any file
names.
- When ``echo`` is used with the ``-e`` flag, the ``\n`` symbols are
treated as newline symbols. We use it to simulate multiline input for
FileCheck.

CHECK
-----
Expand All @@ -31,7 +28,7 @@ Valid input results in the exit code ``0`` that indicates success:

.. code-block:: bash

echo -e "String1\nString2\nString3" | filecheck CHECK.check
printf "String1\nString2\nString3" | filecheck CHECK.check
/Users/Stanislaw/.pyenv/versions/3.5.0/bin/filecheck

Invalid input results in the exit code ``1`` and error message:
Expand Down Expand Up @@ -120,14 +117,14 @@ Check file ``CHECK-NEXT.check``:

.. code-block:: bash

$ echo -e "String1\nString2" | filecheck CHECK-NEXT.check
$ printf "String1\nString2" | filecheck CHECK-NEXT.check
...filecheck
$ echo $?
0

.. code-block:: bash

$ echo -e "String1\nfoo\nString2" | filecheck CHECK-NEXT.check
$ printf "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
Expand Down Expand Up @@ -159,14 +156,16 @@ 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
$ printf "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
.. code-block:: bash

$ printf "String1\nString2" | filecheck CHECK-EMPTY.check
...filecheck
...CHECK-EMPTY.check:2:13: error: CHECK-EMPTY: expected string not found in input
CHECK-EMPTY:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
; RUN: printf "String1" | (%FILECHECK_EXEC %S/CHECK.check 2>&1; test $? = 1;) | %FILECHECK_EXEC %s --strict-whitespace --match-full-lines
; CHECK:{{^.*}}FileCheck{{(\.py)?$}}
// TODO: Something wrong with the greediness here:
; CHECK***:{{^.*}}CHECK.check:2:8: error: CHECK***: expected string not found in input
; CHECK:{{^.*}}
// TODO: And here:
; CHECK:{{.*}}String2
; CHECK: ^
; CHECK:<stdin>:1:8: note: scanning from here
; CHECK:String1
; CHECK: ^
; CHECK-EMPTY:
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CHECK: String1
CHECK: String2
CHECK: String3
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: echo -e "String1\nString2" | (%FILECHECK_EXEC %S/CHECK-EMPTY.check 2>&1; test $? = 1) | %FILECHECK_EXEC %s
; RUN: printf "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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
; RUN: echo -e "String1\n\nString2" | %FILECHECK_EXEC %S/CHECK-EMPTY.check | %FILECHECK_EXEC %s
; RUN: printf "String1\n\nString2" | %FILECHECK_EXEC %S/CHECK-EMPTY.check | %FILECHECK_EXEC %s
; CHECK: {{^.*}}FileCheck{{(\.py)?$}}
; CHECK-EMPTY:
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: echo -e "String1\nfoo\nString2" | (%FILECHECK_EXEC %S/CHECK-NEXT.check 2>&1; test $? = 1;) | %FILECHECK_EXEC %s
; RUN: printf "String1\nfoo\nString2" | (%FILECHECK_EXEC %S/CHECK-NEXT.check 2>&1; test $? = 1;) | %FILECHECK_EXEC %s

; CHECK: {{.*}}CHECK-NEXT.check:2:13: error: CHECK-NEXT: is not on the line after the previous match
; CHECK: CHECK-NEXT: String2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
; RUN: echo -e "String1\nString2" | %FILECHECK_EXEC %S/CHECK-NEXT.check | %FILECHECK_EXEC %s
; RUN: printf "String1\nString2" | %FILECHECK_EXEC %S/CHECK-NEXT.check | %FILECHECK_EXEC %s
; CHECK: {{^.*}}FileCheck{{(\.py)?$}}
; CHECK-EMPTY:
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: echo -e "String3" | (%FILECHECK_EXEC %S/CHECK-NOT.check 2>&1; test $? = 1;) | %FILECHECK_EXEC %s
; RUN: printf "String3" | (%FILECHECK_EXEC %S/CHECK-NOT.check 2>&1; test $? = 1;) | %FILECHECK_EXEC %s
; CHECK: {{.*}}CHECK-NOT.check:3:12: error: CHECK-NOT: excluded string found in input
; CHECK: CHECK-NOT: String3
; CHECK: ^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
; RUN: echo -e "String4" | %FILECHECK_EXEC %S/CHECK-NOT.check | %FILECHECK_EXEC %s
; RUN: printf "String4" | %FILECHECK_EXEC %S/CHECK-NOT.check | %FILECHECK_EXEC %s
; CHECK: {{^.*}}FileCheck{{(\.py)?$}}
; CHECK-EMPTY:
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: echo -e "String1" | (%FILECHECK_EXEC %S/CHECK.check 2>&1; test $? = 1;) | %FILECHECK_EXEC %s
; RUN: printf "String1" | (%FILECHECK_EXEC %S/CHECK.check 2>&1; test $? = 1;) | %FILECHECK_EXEC %s
; CHECK: {{^.*}}FileCheck{{(\.py)?$}}
; CHECK: {{.*}}CHECK.check:2:8: error: CHECK: expected string not found in input
; CHECK: CHECK: String2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
; RUN: echo -e "String1\nString2\nString3" | %FILECHECK_EXEC %S/CHECK.check | %FILECHECK_EXEC %s
; RUN: printf "String1\nString2\nString3" | %FILECHECK_EXEC %S/CHECK.check | %FILECHECK_EXEC %s
; CHECK: {{^.*}}FileCheck{{(\.py)?$}}
; CHECK-EMPTY: