Skip to content

Commit aded7a7

Browse files
authored
Added actual info in README.md (#342)
### What's done: Updated actual info in README.md
1 parent c4414a8 commit aded7a7

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ In case you would like to have several plugins to work in your directory with sa
6767
...
6868
```
6969

70+
## Save warnings DSL
71+
![save-cli](https://user-images.githubusercontent.com/58667063/146390474-71e4921d-416b-4922-b2ea-894f71e491c3.jpg)
72+
You can read more about the `warn plugin` [here](save-plugins/warn-plugin/README.md)
73+
74+
7075
## How to configure
7176
SAVE has a command line interface that runs the framework and your executable. What you need is simply to configure the output of your static analyzer so SAVE will be able to
7277
check if the proper error was raised on the proper line of test code.
@@ -151,6 +156,9 @@ excludedTests = ["warn/chapter1/GarbageTest.kt", "warn/otherDir/NewTest.kt"], e.
151156
152157
# command execution time for one test (milliseconds)
153158
timeOutMillis = 10000
159+
160+
# language for tests
161+
language = "Kotlin"
154162
```
155163

156164
## Executing specific tests

save-plugins/warn-plugin/README.md

+30-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Plugin that runs the provided executable and compares emitted warnings with expe
33
Please note, that it is important for test resources to have specific keywords. For test file it should be `Test`.
44

55
### Examples
6-
If you don't like to read long readme file, you can simply check [examples](/examples/kotlin-diktat/warn).
6+
If you don't like to read long readme file, you can simply check [examples](/examples/kotlin-diktat/warn).
7+
There are all available configurations that you need.
78

89
### Source files
910
Test source files (input for SAVE) should have a comment line (use single-line commenting syntax of the target programming language for it)
@@ -27,7 +28,13 @@ Warning messages are very flexible and can be described in very different ways:
2728
```
2829
// ;warn:3:1: Warning with an explicit set of a line number and column number
2930
```
30-
31+
```
32+
/* ;warn:1: Multiline warning. This line should match `expectedWariningsPattern`
33+
* To match other lines, you need to specify a value of `expectedWarningsEndPattern` (and `expectedWarningsMiddlePattern` if there is any).
34+
* This line should match `expectedWarningsMiddlePattern`
35+
* And the next line should match `expectedWarningsEndPattern`
36+
*/
37+
```
3138
### Regular expressions in warnings
3239
Regular expressions can be used in warning messages.
3340
To configure delimiters, use `patternForRegexInWarning` option (default: `"{{", "}}"`):
@@ -74,13 +81,27 @@ you will need the following SAVE configuration:
7481
execCmd = "./detekt"
7582
description = "My suite description"
7683
suiteName = "DocsCheck"
77-
# warning is set inside the comment in code, `//` marks comment start in Java
84+
language = "Kotlin"
85+
# if you are using IN_PLACE mode, this flag will be used to extract EXPECTED warnings from the file
7886
expectedWarningsPattern = "// ;warn:(\\d+):(\\d+): (.*)" # (default value)
79-
87+
# for multiline warnings ONLY (if you are using IN_PLACE mode and multiline warnings)
88+
expectedWarningsMiddlePattern = "\\* (.*)"
89+
expectedWarningsEndPattern = "(.*)?\\*/"
8090

8191
[warn]
92+
# extra execution flags that are added to the exec cmd
8293
execFlags = "--build-upon-default-config -i"
8394

95+
# the format and place, where EXPECTED warnings should be put, for example:
96+
# SARIF: means that you put ALL your expected warnings into the special file with the name 'save-warnings.sarif'
97+
# (default) IN_PLACE: means that you need to put your expected warnings into the test resource (and they will be matched by expectedWarningsPattern)
98+
expectedWarningsFormat = "SARIF"
99+
100+
# the format of actual warnings
101+
# (default) PLAIN: means that your tool reports warnings in plain text that. Warnings will be extracted with actualWarningsPattern
102+
# SARIF: means that the output of the tool will be extracted with a SARIF format
103+
actualWarningsFormat = "SARIF"
104+
84105
# e.g. `WARN - 10/14 - Class name is in incorrect case`
85106
# expected regex may allow an empty group for line number
86107
# regex group with lineCaptureGroupIdx may include a number or linePlaceholder and addition/subtraction of a number
@@ -95,6 +116,10 @@ columnCaptureGroup = 3 # (default value)
95116
# index of regex capture group for message text
96117
messageCaptureGroup = 4 # (default value)
97118

119+
# options that control the capture group for patterns of warnings to extract multiline warning
120+
messageCaptureGroupMiddle = 1 # (default value)
121+
messageCaptureGroupEnd = 1 # (default value)
122+
98123
warningTextHasColumn = true # (default value)
99124
warningTextHasLine = true # (default value)
100125
testNameRegex = ".*Test.*" # (default value)
@@ -115,7 +140,7 @@ parsed from the same `$testFile` using `warningsInputPattern`. `batchSeparator`
115140
If line number is not present in the comment, it's assumed to be `current line + 1` in regex group with lineCaptureGroupIdx.
116141
`linePlaceholder` is an optional placeholder for the line number that is recognized as the current line and supports addition and subtraction.
117142

118-
`warningsInputPattern` and `warningsOutputPattern` must include some mandatory capture groups: for line number (if `warningTextHasLine` is true),
143+
`expectedWarningsPattern` and `actualWarningsPattern` must include some mandatory capture groups: for line number (if `warningTextHasLine` is true),
119144
for column number (if `warningTextHasColumn` is true) and for warning text. Their indices can be customized
120145
with `lineCaptureGroup`, `columnCaptureGroup` and `messageCaptureGroup` parameters. These parameters are shared between input and output pattern;
121146
usually you'll want them to be consistent to make testing easier, i.e. if input has line number, then so should output.

0 commit comments

Comments
 (0)