-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for fmt config options. (#230)
This commit adds tests for the configurable formatter. Each configuration option is tested individually, as they each should be independent of each other. If we have a need to test multiple configuration options simultaneously in the future this setup should be able to do it easily. While here I also found a bug in how tab stops were treated by the formatter when removing trailing whitespaces. After indentation was performed the step to remove trailing whitespace was not properly checking for the inserted tab characters. There was also another bug with handling the emptyline before the section header which I fixed. Also, fix a bug in the docs where the `meta.align_values` and `meta.align_patterns` options were incorrectly set. They changed to true in a previous commit but I did not update the docs then.
- Loading branch information
Showing
83 changed files
with
184 additions
and
12 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
12 changes: 12 additions & 0 deletions
12
fmt/src/testdata/config_tests/align_metadata_false.formatted
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,12 @@ | ||
rule test { | ||
meta: | ||
a = "b" | ||
long = "foo" | ||
|
||
strings: | ||
$a = "b" | ||
$axs = { 06 11 } | ||
|
||
condition: | ||
$a | ||
} |
12 changes: 12 additions & 0 deletions
12
fmt/src/testdata/config_tests/align_patterns_false.formatted
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,12 @@ | ||
rule test { | ||
meta: | ||
a = "b" | ||
long = "foo" | ||
|
||
strings: | ||
$a = "b" | ||
$axs = { 06 11 } | ||
|
||
condition: | ||
$a | ||
} |
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 @@ | ||
rule test{meta:a="b"long="foo"strings:$a="b"$axs={0611}condition:$a} |
13 changes: 13 additions & 0 deletions
13
fmt/src/testdata/config_tests/empty_line_after_section_header_true.formatted
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 @@ | ||
rule test { | ||
meta: | ||
|
||
a = "b" | ||
|
||
strings: | ||
|
||
$a = "b" | ||
|
||
condition: | ||
|
||
$a | ||
} |
8 changes: 8 additions & 0 deletions
8
fmt/src/testdata/config_tests/empty_line_before_section_header_false.formatted
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,8 @@ | ||
rule test { | ||
meta: | ||
a = "b" | ||
strings: | ||
$a = "b" | ||
condition: | ||
$a | ||
} |
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,2 @@ | ||
|
||
rule test{meta:a="b"strings:$a="b"condition:$a} |
10 changes: 10 additions & 0 deletions
10
fmt/src/testdata/config_tests/indent_section_contents_false.formatted
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,10 @@ | ||
rule test { | ||
meta: | ||
a = "b" | ||
|
||
strings: | ||
$a = "b" | ||
|
||
condition: | ||
$a | ||
} |
10 changes: 10 additions & 0 deletions
10
fmt/src/testdata/config_tests/indent_section_headers_false.formatted
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,10 @@ | ||
rule test { | ||
meta: | ||
a = "b" | ||
|
||
strings: | ||
$a = "b" | ||
|
||
condition: | ||
$a | ||
} |
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,10 @@ | ||
rule test { | ||
meta: | ||
a = "b" | ||
|
||
strings: | ||
$a = "b" | ||
|
||
condition: | ||
$a | ||
} |
10 changes: 10 additions & 0 deletions
10
fmt/src/testdata/config_tests/indent_spaces_zero.formatted
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,10 @@ | ||
rule test { | ||
meta: | ||
a = "b" | ||
|
||
strings: | ||
$a = "b" | ||
|
||
condition: | ||
$a | ||
} |
11 changes: 11 additions & 0 deletions
11
fmt/src/testdata/config_tests/newline_before_curly_brace_true.formatted
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,11 @@ | ||
rule test | ||
{ | ||
meta: | ||
a = "b" | ||
|
||
strings: | ||
$a = "b" | ||
|
||
condition: | ||
$a | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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