@@ -3,7 +3,8 @@ Plugin that runs the provided executable and compares emitted warnings with expe
3
3
Please note, that it is important for test resources to have specific keywords. For test file it should be ` Test ` .
4
4
5
5
### 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.
7
8
8
9
### Source files
9
10
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:
27
28
```
28
29
// ;warn:3:1: Warning with an explicit set of a line number and column number
29
30
```
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
+ ```
31
38
### Regular expressions in warnings
32
39
Regular expressions can be used in warning messages.
33
40
To configure delimiters, use ` patternForRegexInWarning ` option (default: ` "{{", "}}" ` ):
@@ -74,13 +81,27 @@ you will need the following SAVE configuration:
74
81
execCmd = " ./detekt"
75
82
description = " My suite description"
76
83
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
78
86
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 = " (.*)?\\ */"
80
90
81
91
[warn ]
92
+ # extra execution flags that are added to the exec cmd
82
93
execFlags = " --build-upon-default-config -i"
83
94
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
+
84
105
# e.g. `WARN - 10/14 - Class name is in incorrect case`
85
106
# expected regex may allow an empty group for line number
86
107
# regex group with lineCaptureGroupIdx may include a number or linePlaceholder and addition/subtraction of a number
@@ -95,6 +116,10 @@ columnCaptureGroup = 3 # (default value)
95
116
# index of regex capture group for message text
96
117
messageCaptureGroup = 4 # (default value)
97
118
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
+
98
123
warningTextHasColumn = true # (default value)
99
124
warningTextHasLine = true # (default value)
100
125
testNameRegex = " .*Test.*" # (default value)
@@ -115,7 +140,7 @@ parsed from the same `$testFile` using `warningsInputPattern`. `batchSeparator`
115
140
If line number is not present in the comment, it's assumed to be ` current line + 1 ` in regex group with lineCaptureGroupIdx.
116
141
` linePlaceholder ` is an optional placeholder for the line number that is recognized as the current line and supports addition and subtraction.
117
142
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),
119
144
for column number (if ` warningTextHasColumn ` is true) and for warning text. Their indices can be customized
120
145
with ` lineCaptureGroup ` , ` columnCaptureGroup ` and ` messageCaptureGroup ` parameters. These parameters are shared between input and output pattern;
121
146
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