-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print missing no-eol in pretty test result
Summary: This CL ensures Scrut suggest to add `(no-eol)` with the pretty renderer if it is missing. # What? Append ` (no-eol)` to unexpected output lines that do not end in a new-line in the pretty validation result renderer # Why? Before this CL, if a test output validation contained an `equal` rule (i.e. a comparison with a line that ends in a new-line) but expected a `no-eol` rule (i.e. a comparison with a line that does not end with a new-line), then the pretty rendere would provide: ``` 1 | - There is no new line 1 | + There is no new line ``` This was unclear and did not provide the test author with any actionable steps to fix the test. With this CL the output will now correctly show: ``` 1 | - There is no new line 1 | + There is no new line (no-eol) ``` Reviewed By: AndreasBackx Differential Revision: D63902398 fbshipit-source-id: 0703165dc80b41e1fe32a837493ae320baf5f759
- Loading branch information
1 parent
2e4558e
commit 5cb71b0
Showing
8 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# A test where output does NOT end in new-line | ||
|
||
```scrut | ||
$ echo -n There is no new line | ||
There is no new line | ||
``` | ||
|
||
# A test where output DOES end in new-line | ||
|
||
```scrut | ||
$ echo There is a new line | ||
There is a new line (no-eol) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Test that Scrut proposes noeol if a line does not match for that reason | ||
|
||
This test validates that if the user writes a Scrut test where they use an equal-rule (i.e. with ending new-line | ||
character) but the output does not end in a new-line, then Scrut prints the missing `(no-eol)` suffix. | ||
|
||
## No-EOL is proposed in the pretty print of the failed test | ||
|
||
```scrut | ||
$ "$SCRUT_BIN" test --renderer pretty --match-markdown "*.mdtest" "$TESTDIR/invalid.mdtest" | ||
// ============================================================================= | ||
// @ .*[/\\]invalid\.mdtest:4 (regex) | ||
// ----------------------------------------------------------------------------- | ||
// # A test where output does NOT end in new-line | ||
// ----------------------------------------------------------------------------- | ||
// $ echo -n There is no new line | ||
// ============================================================================= | ||
1 | - There is no new line | ||
1 | + There is no new line (no-eol) (equal) | ||
// ============================================================================= | ||
// @ .*[/\\]invalid\.mdtest:11 (regex) | ||
// ----------------------------------------------------------------------------- | ||
// # A test where output DOES end in new-line | ||
// ----------------------------------------------------------------------------- | ||
// $ echo There is a new line | ||
// ============================================================================= | ||
1 | - There is a new line (no-eol) (equal) | ||
1 | + There is a new line | ||
Result: 1 file(s) with 2 test(s): 0 succeeded, 2 failed and 0 skipped | ||
[50] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Test that Scrut proposes noeol if a line does not match for that reason | ||
|
||
This test validates that if the user writes a Scrut test where they use an equal-rule (i.e. with ending new-line | ||
character) but the output does not end in a new-line, then Scrut prints the missing `(no-eol)` suffix. | ||
|
||
|
||
```scrut | ||
$ cp "$TESTDIR/invalid.mdtest" "$(pwd)/invalid.mdtest" | ||
``` | ||
|
||
## No-EOL is proposed in the pretty print of the failed test | ||
|
||
```scrut | ||
$ "$SCRUT_BIN" update --match-markdown "*.mdtest" "$(pwd)/invalid.mdtest" | ||
Result: 1 file(s) of which 1 updated, 0 skipped and 0 unchanged | ||
``` | ||
|
||
## Generated file matches valid result | ||
|
||
```scrut | ||
$ diff "$(pwd)/invalid.mdtest.new" "$TESTDIR/valid.mdtest" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# A test where output does NOT end in new-line | ||
|
||
```scrut | ||
$ echo -n There is no new line | ||
There is no new line (no-eol) | ||
``` | ||
|
||
# A test where output DOES end in new-line | ||
|
||
```scrut | ||
$ echo There is a new line | ||
There is a new line | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters